add certcheck

master
mrbesen 4 years ago
parent b42c0244f1
commit 6b09d55ac7
  1. 7
      bot.sh
  2. 11
      cert.sh
  3. 2
      config.sh

@ -35,3 +35,10 @@ if [ "$mem" -gt "$memlimit" ]; then
send "warnung%20Memory%20Usage%20is%20high%20$mem%25"
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
}

@ -17,3 +17,5 @@ hddlimit="50"
hdd="/dev/sda1"
memlimit="90"
certlimit="1 week"

Loading…
Cancel
Save