Add automatic certiicate renewal, fixes #1 #3

Merged
ejparker merged 6 commits from renewal into prod 2025-03-22 20:18:18 -05:00
Showing only changes of commit aa02ee6103 - Show all commits

View file

@ -1,4 +1,12 @@
#! /bin/bash
function reload() {
#reload/restart relevant services
if [ -d /etc/nginx/certs/ ]
then
systemctl reload nginx
fi
}
dom=`date +%d`
today=`date +%Y%m%d`
log=/var/log/certbot-renewal.log
@ -14,6 +22,7 @@ do
then
echo Certificate for $f is expired, renewing >> $log
certbot renew --cert-name $f >> /var/log/certbot-renewal.log
reload()
continue
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)
@ -26,6 +35,7 @@ do
then
echo Date falls within renewal window for $f, attempting renewal >> $log
certbot renew --cert-name $f >> $log
reload()
break
fi
done