10 lines
804 B
Bash
10 lines
804 B
Bash
|
# 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
|