Created
March 31, 2017 12:18
-
-
Save martinvirtel/472b4728314edaed8d74b14a5b8a157c to your computer and use it in GitHub Desktop.
Letsencrypt: Send E-Mail if certificate validity is less than 10 days
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
#! /bin/bash | |
LOG=/tmp/letsencrypt-renewal-attempt | |
/usr/local/sbin/certbot-auto renew >$LOG 2>&1 | |
service nginx reload >>$LOG 2>&1 | |
# | |
# Check SSL Certificate is valid for at least $DAYS | |
# | |
DAYS=10 | |
HOST=werkzeugkasten.dpa-newslab.com | |
openssl s_client -showcerts -connect $HOST:443 </dev/null 2>/dev/null|openssl x509 -noout -checkend $(echo $((24*60*60*$DAYS)) ) || \ | |
cat <<__END__ | msmtp mvirtel@wherever_this_shoud_go | |
Subject: Certificate Check for $HOST failed | |
From: ubuntu@werkzeugkasten.dpa-newslab.com | |
$HOST SSL Certificate check failed. Certificate valitiy could be less than $DAYS days. | |
Message generated by $0. | |
Certificate Renewal Logfile: | |
$(cat $LOG) | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment