3ada58cc45102a4078425f94efd30b6f5d00e6b7
[bacula-cn.git] / bacula-check-cert
1 #!/bin/bash
2
3 BACULACRT=/etc/bacula/bacula-fd.pem
4 DAYS=$(expr 30 \* 86400)
5
6 if [ ! -r $BACULACRT ]; then 
7         mailx -s "BACULA: Ne mogu otvoriti datoteku $BACULACRT!" -a 'Content-Type: text/plain; charset="utf-8"' root <<EOF
8
9                 Datoteka $BACULACRT nije dostupna ili je korisnik 'bacula' ne može otvoriti!
10
11                 Molimo provjerite status certifikata i po potrebi ga osvježite po uputama na adresi:
12
13                 https://sysportal.carnet.hr/node/834
14
15
16 EOF
17         exit 1
18 fi
19
20
21 SSL=$(openssl x509 -checkend $DAYS -in $BACULACRT)
22
23 if [ $? -eq 1 ];  then
24         mailx -s "BACULA: Certifikat za Baculu zahtijeva PROVJERU!" -a 'Content-Type: text/plain; charset="utf-8"' root <<EOF
25         
26         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)
27         
28         Certifikat obnovite po uputama na https://sysportal.carnet.hr/node/834
29         
30 EOF
31         exit 1
32 fi
33
34 exit 0