reload nginx when cert tries to renew

This commit is contained in:
Beth Parker 2025-03-22 20:14:26 -05:00
parent fb45d990e1
commit aa02ee6103

View file

@ -1,4 +1,12 @@
#! /bin/bash #! /bin/bash
function reload() {
#reload/restart relevant services
if [ -d /etc/nginx/certs/ ]
then
systemctl reload nginx
fi
}
dom=`date +%d` dom=`date +%d`
today=`date +%Y%m%d` today=`date +%Y%m%d`
log=/var/log/certbot-renewal.log log=/var/log/certbot-renewal.log
@ -14,6 +22,7 @@ do
then then
echo Certificate for $f is expired, renewing >> $log echo Certificate for $f is expired, renewing >> $log
certbot renew --cert-name $f >> /var/log/certbot-renewal.log certbot renew --cert-name $f >> /var/log/certbot-renewal.log
reload()
continue continue
fi fi
#convert hostname into day of month between 0 and 28 to renew on specific day of month (reduce chance of running out of cert renewals) #convert hostname into day of month between 0 and 28 to renew on specific day of month (reduce chance of running out of cert renewals)
@ -26,6 +35,7 @@ do
then then
echo Date falls within renewal window for $f, attempting renewal >> $log echo Date falls within renewal window for $f, attempting renewal >> $log
certbot renew --cert-name $f >> $log certbot renew --cert-name $f >> $log
reload()
break break
fi fi
done done