/[pdpsoft]/trunk/egi-pilot/onlineCA/DS/ansible/roles/delegserver/templates/ca_checker.sh.j2
ViewVC logotype

Contents of /trunk/egi-pilot/onlineCA/DS/ansible/roles/delegserver/templates/ca_checker.sh.j2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3085 - (show annotations) (download)
Mon Aug 15 10:57:55 2016 UTC (5 years, 5 months ago) by msalle
File size: 1175 byte(s)
Sync ca_checker.sh with novalocal and kaasvat versions

1 #!/bin/sh
2
3 send_mail() {
4
5 # send mail about the state change
6 echo -e "OpenSSL s_client output: \n\n${1}" | \
7 mailx -s "ca_checker state has changed" {{ contact }}
8 }
9
10 STATE_DIR=/var/cache/ca_checker
11 STATE_FILE=${STATE_DIR}/state
12
13 # check the existance of the state dir
14 if [ ! -d ${STATE_DIR} ]; then
15 mkdir -m 700 ${STATE_DIR}
16 fi
17
18 # excute openssl command
19 OUTPUT=$( (echo "0" ; echo -e "VERSION=MYPROXYv2\nCOMMAND=CA TEST") | \
20 openssl s_client -CApath {{oa4mp_server_certificates_dir}} \
21 -connect {{ myproxy_ca_host }}:{{ myproxy_ca_port }} \
22 -quiet -no_ign_eof -prexit 2>&1)
23 OPENSSL_RET=$?
24
25 # evaluate openssl results
26 if [ -w ${STATE_FILE} ]; then
27
28 # compare existing state with output
29 STATE=$(cat ${STATE_FILE})
30 if [ "${STATE}" != "${OUTPUT}" ]; then
31 send_mail "${OUTPUT}"
32 echo "${OUTPUT}" > ${STATE_FILE}
33 fi
34
35 else
36
37 # send mail if this is the first run and CA is down
38 if [ ${OPENSSL_RET} -ne 0 ]; then
39 send_mail "${OUTPUT}"
40 fi
41
42 # save state if it does not exist
43 echo "${OUTPUT}" > ${STATE_FILE}
44
45 fi
46

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28