Ajout de commandes pour nettoyer Let's Encrypt

This commit is contained in:
Matthieu Patout 2021-04-01 16:59:59 +02:00
parent c547089631
commit 5aab3a5e25
1 changed files with 10 additions and 0 deletions

10
le-cleaning.sh Normal file
View File

@ -0,0 +1,10 @@
# Commands to clean domains managed by Let's Encrypt
# Removal of expired domains
cat /var/log/letsencrypt/letsencrypt.log | grep "Detail: DNS problem: NXDOMAIN looking up A for" > /tmp/failresolv.lst
cat /tmp/failresolv.lst | sed 's/^Detail: DNS problem: NXDOMAIN looking up A for //' | sed 's/ - check that a DNS record exists for this domain//' | sed 's/www.//' | sort | uniq > failresolv.lst
for domain in $(cat failresolv.lst); do certbot delete --cert-name $domain ; done
# Removing broken configurations
cat /var/log/letsencrypt/letsencrypt.log | grep "conf is broken" > /tmp/broken.lst
cat /tmp/broken.lst | sed 's/^.*\/etc\/letsencrypt\/renewal\///' | sed 's/.conf is broken. Skipping.//' | sort | uniq > broken.lst
for domain in $(cat broken.lst); do certbot delete --cert-name $domain ; done