Add automatic certiicate renewal, fixes #1 #3
1 changed files with 10 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue