Updating certbot-renewal script

This commit is contained in:
Tyler Hale 2023-02-06 09:43:50 -07:00
parent bb6f4fa8cc
commit f26dff8664
Signed by: Tyler
GPG key ID: C7CC4B910D88EF96

View file

@ -17,7 +17,7 @@ TARFILE_COMPRESS=$TARFILE'.gz'
if [[ $(hostname -I)[*] =~ $VIRTUAL_IP ]]; then if [[ $(hostname -I)[*] =~ $VIRTUAL_IP ]]; then
echo "Current master - Processing renewals" echo "Current master - Processing renewals"
certbot renew /usr/local/bin/certbot renew
# tar the letsencrypt directory for transferring to other members with symlinks # tar the letsencrypt directory for transferring to other members with symlinks
tar cfP $TARFILE /etc/letsencrypt/ tar cfP $TARFILE /etc/letsencrypt/
@ -36,10 +36,22 @@ if [[ $(hostname -I)[*] =~ $VIRTUAL_IP ]]; then
do do
if [[ ! $(hostname -I)[*] =~ $SERVER ]]; then if [[ ! $(hostname -I)[*] =~ $SERVER ]]; then
# Transfer the files to the backup server # Transfer the files to the backup server
sudo -u $USER scp -i $PRIVATE_KEY $TARFILE_COMPRESS $USER@$SERVER:~ sudo -u $USER scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $PRIVATE_KEY $TARFILE_COMPRESS $USER@$SERVER:~
# Deploy the current letsencrypt config/certs # Deploy the current letsencrypt config/certs
sudo -u $USER ssh -i $PRIVATE_KEY $USER@$SERVER "sudo rm -rf /etc/letsencrypt; sudo tar xzfP $TARFILE_COMPRESS && sudo rm $TARFILE_COMPRESS;sudo systemctl reload haproxy" sudo -u $USER ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $PRIVATE_KEY $USER@$SERVER "sudo rm -rf /etc/letsencrypt; sudo tar xzfP $TARFILE_COMPRESS && sudo rm $TARFILE_COMPRESS;sudo systemctl reload haproxy"
fi fi
done done
rm $TARFILE_COMPRESS
fi
if [ -d "/etc/letsencrypt/live/" ]; then
for Cert in /etc/letsencrypt/live/*/ ;
do
echo Processing $Cert
cd $Cert
cat fullchain.pem privkey.pem | dd status=none of="/etc/haproxy/ssl/$(basename $Cert).pem"
done
systemctl reload haproxy
fi fi