Last active
June 25, 2020 08:58
-
-
Save JoernSchoenyan/78b960226ae99283965988cdb6e2cc38 to your computer and use it in GitHub Desktop.
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 | |
MEIN_HOSTNAME= | |
MAILADRESSE= | |
data=`echo | openssl s_client -servername $MEIN_HOSTNAME -connect $MEIN_HOSTNAME:993 2>/dev/null | openssl x509 -noout -dates | grep notAfter | sed -e 's#notAfter=##'` | |
ssldate=`date -d "${data}" '+%s'` | |
nowdate=`date '+%s'` | |
diff="$((${ssldate}-${nowdate}))" | |
if test "${diff}" -lt "$((7*24*3600))"; | |
then | |
if test "${diff}" -lt "0"; | |
then | |
echo "Das Zertifikat für unseren Mailserver ist abgelaufen!" | /usr/sbin/sendmail $MAILADRESSE | |
else | |
echo "Das Zertifikat fuer unseren Mailserver laeuft in $((${diff}/3600/24)) Tagen ab!" | /usr/sbin/sendmail $MAILADRESSE | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment