add certcheck
This commit is contained in:
parent
b42c0244f1
commit
6b09d55ac7
7
bot.sh
7
bot.sh
|
@ -35,3 +35,10 @@ if [ "$mem" -gt "$memlimit" ]; then
|
||||||
send "warnung%20Memory%20Usage%20is%20high%20$mem%25"
|
send "warnung%20Memory%20Usage%20is%20high%20$mem%25"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#CheckCerts
|
||||||
|
. cert.sh
|
||||||
|
checkCert "/etc/letsencrypt/live/mrbesen.de/cert.pem"
|
||||||
|
if [ "$?" -gt "0" ]; then
|
||||||
|
echo "cert expired!"
|
||||||
|
send "warnung%20cert%20expires%20soon"
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
function checkCert {
|
||||||
|
valid=$(openssl x509 -enddate -noout -in "$1" | cut -b 10-)
|
||||||
|
valids=$(date -d "${valid}" +%s)
|
||||||
|
limit=$(date -d "-${certlimit}" +%s)
|
||||||
|
|
||||||
|
if [ "${valids}" -lt "${limit}" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
Loading…
Reference in New Issue