summaryrefslogtreecommitdiff
path: root/filesystems/zrepl/files/500.zrepl.in
blob: b7f1b3abb4d370e82e1102f9d6086dab96b5da9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

# Check zrepl SSL certificates for impending expiration each week
#
# Add the following lines to /etc/periodic.conf:
#
# weekly_zrepl_enable (bool):	Set to "NO" by default
# weekly_zrepl_warntime (int): Set to one month's worth of seconds by default

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

# 30 days in seconds
: ${weekly_zrepl_warntime="2592000"}

rc=0
case "$weekly_zrepl_enable" in
    [Yy][Ee][Ss])
	echo
	echo "Check Zrepl certificates for upcoming expiration:"

	for cert in `/usr/bin/find %%ETCDIR%% -maxdepth 1 -name *.crt`; do
		/usr/bin/openssl x509 --in "${cert}" \
			-checkend "${weekly_zrepl_warntime}"

		if [ $? -gt 0 ]; then
			echo "${cert} will expire soon"
			/usr/bin/openssl x509 --in "${cert}" -noout -enddate
			rc=3
		fi
	done
	;;
    *)  rc=0;;
esac

exit $rc