#!/bin/bash
-BACULACRT=/etc/bacula/bacula-fd.pem.old
+BACULACRT=/etc/bacula/bacula-fd.pem
+DAYS=$(expr 30 \* 86400)
-test -f $BACULACRT || echo "Ne mogu otvoriti datoteku $BACULACRT!"
+if [ ! -f $BACULACRT ]; then
+ mailx -s "BACULA: Ne mogu otvoriti datoteku $BACULACRT!" root <<EOF
+
+ Datoteka $BACULACRT nije dostupna ili je korisnik 'bacula' ne može otvoriti!
+
+ Molimo provjerite status certifikata i po potrebi ga osvježite po uputama na adresi:
+ https://sysportal.carnet.hr/node/834
+
+
+EOF
+ exit 1
+fi
-DAYS=$(expr 30 \* 86400)
SSL=$(openssl x509 -checkend $DAYS -in $BACULACRT)
if [ $? -eq 1 ]; then
- echo -n "Valjanost certifikata za Baculu je istekla ili će isteći na dan: "
- date --date="$(openssl x509 -in $BACULACRT -noout -enddate | cut -d= -f 2)" --iso-8601
- echo ""; echo "Certifikat obnovite po uputama na https://sysportal.carnet.hr/node/834"
+ mailx -s "BACULA: Valjanost certifikata za Baculu je ISTEKLA!" root <<EOF
+
+ Valjanost certifikata za Baculu je istekla ili će isteći na dan: $(date --date="$(openssl x509 -in $BACULACRT -noout -enddate | cut -d= -f 2)" --iso-8601)
+
+ Certifikat obnovite po uputama na https://sysportal.carnet.hr/node/834
+
+EOF
+ exit 1
fi
exit 0