2005-02-15 16:30:01 +00:00
|
|
|
#!/bin/bash
|
2004-09-10 14:16:06 +00:00
|
|
|
#
|
|
|
|
# Issue warning e-mails if SSL certificates expire, using
|
2005-04-26 12:39:15 +00:00
|
|
|
# certwatch(1). Set NOCERTWATCH=yes in /etc/sysconfig/httpd
|
2005-04-26 09:20:45 +00:00
|
|
|
# to disable. Pass additional options to certwatch in the
|
2005-04-26 12:39:15 +00:00
|
|
|
# CERTWATCH_OPTS variable; see the man page for details.
|
2004-09-10 14:16:06 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
[ -r /etc/sysconfig/httpd ] && . /etc/sysconfig/httpd
|
|
|
|
|
|
|
|
# Use configured httpd binary
|
|
|
|
httpd=${HTTPD-/usr/sbin/httpd}
|
|
|
|
|
|
|
|
# Sanity checks
|
|
|
|
test -z "${NOCERTWATCH}" || exit 0
|
|
|
|
test -x ${httpd} || exit 0
|
|
|
|
test -x /usr/bin/certwatch || exit 0
|
|
|
|
test -r /etc/httpd/conf/httpd.conf || exit 0
|
|
|
|
test -x /usr/sbin/sendmail || exit 0
|
|
|
|
test -x /etc/httpd/modules/mod_ssl.so || exit 0
|
2005-02-15 16:30:01 +00:00
|
|
|
test -x /bin/sort || exit 0
|
2004-09-10 14:16:06 +00:00
|
|
|
|
2005-02-15 16:30:01 +00:00
|
|
|
set -o pipefail # pick up exit code of httpd not sort
|
|
|
|
|
2005-04-26 12:39:15 +00:00
|
|
|
certs=`${httpd} ${OPTIONS} -t -DDUMP_CERTS 2>/dev/null | /bin/sort -u`
|
2004-09-10 14:16:06 +00:00
|
|
|
RETVAL=$?
|
|
|
|
test $RETVAL -eq 0 || exit 0
|
|
|
|
|
|
|
|
for c in $certs; do
|
|
|
|
# Check whether a warning message is needed, then issue one if so.
|
2005-04-26 09:20:45 +00:00
|
|
|
/usr/bin/certwatch $CERTWATCH_OPTS -q "$c" &&
|
|
|
|
/usr/bin/certwatch $CERTWATCH_OPTS "$c" | /usr/sbin/sendmail -oem -oi -t 2>/dev/null
|
2004-09-10 14:16:06 +00:00
|
|
|
done
|