Created
January 13, 2018 17:38
-
-
Save adrianmihalko/fb25d7841751297f929280b060ec9706 to your computer and use it in GitHub Desktop.
Letsencrypt update script, restart service if success and notify with ssmtp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SERVER="Ubuntu (192.168.1.54)" | |
EMAIL='hello@gmail.com' | |
ALERTMESSAGE='/tmp/ALERTMESSAGE_cert.tmp' | |
if /usr/bin/openssl x509 -checkend 86400 -noout -in /etc/letsencrypt/live/my.domain.eu/fullchain.pem | |
then | |
echo "Certificate is good for another day!" | |
else | |
echo "To: $EMAIL" > $ALERTMESSAGE | |
echo "From: $FROM" >> $ALERTMESSAGE | |
echo "Subject: LetsEncrypt SSL Renew on $SERVER" >> $ALERTMESSAGE | |
echo "" >> $ALERTMESSAGE | |
echo "Certificate has expired or will do so within 24 hours!" >> $ALERTMESSAGE | |
echo "Start LetsEncrypt" >> $ALERTMESSAGE | |
/home/username/scripts/letsencrypt/letsencrypt-auto renew --renew-hook "systemctl restart unifi.service" >> $ALERTMESSAGE | |
/usr/sbin/ssmtp $EMAIL < $ALERTMESSAGE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment