sysutils/zrepl: warn of impending SSL certificate expiration

Add a periodic script that will warn of impending certifiate expiration.

PR:		257464
Approved by:	dries (maintainer, ports)
Sponsored by:	Axcient
This commit is contained in:
Alan Somers 2021-07-27 16:08:38 -06:00
parent 4bcf376e27
commit 0de11ff4ff
4 changed files with 57 additions and 2 deletions

View File

@ -1,7 +1,7 @@
PORTNAME= zrepl PORTNAME= zrepl
DISTVERSIONPREFIX= v DISTVERSIONPREFIX= v
DISTVERSION= 0.6.0 DISTVERSION= 0.6.0
PORTREVISION= 1 PORTREVISION= 2
CATEGORIES= sysutils CATEGORIES= sysutils
MAINTAINER= driesm@FreeBSD.org MAINTAINER= driesm@FreeBSD.org
@ -19,7 +19,7 @@ GO_BUILDFLAGS= -ldflags "\
-s -w\ -s -w\
-X ${GO_MODULE}/version.${PORTNAME}Version=${DISTVERSIONFULL}" -X ${GO_MODULE}/version.${PORTNAME}Version=${DISTVERSIONFULL}"
SUB_FILES= pkg-message SUB_FILES= pkg-message 500.zrepl
OPTIONS_DEFINE= EXAMPLES MANPAGES OPTIONS_DEFINE= EXAMPLES MANPAGES
OPTIONS_DEFAULT= MANPAGES OPTIONS_DEFAULT= MANPAGES
@ -40,6 +40,9 @@ post-install:
${INSTALL_DATA} ${FILESDIR}/newsyslog.conf ${STAGEDIR}${EXAMPLESDIR}/newsyslog.conf ${INSTALL_DATA} ${FILESDIR}/newsyslog.conf ${STAGEDIR}${EXAMPLESDIR}/newsyslog.conf
${INSTALL_DATA} ${FILESDIR}/syslog.conf ${STAGEDIR}${EXAMPLESDIR}/syslog.conf ${INSTALL_DATA} ${FILESDIR}/syslog.conf ${STAGEDIR}${EXAMPLESDIR}/syslog.conf
${INSTALL_DATA} ${FILESDIR}/zrepl.yml ${STAGEDIR}${ETCDIR}/zrepl.yml.sample ${INSTALL_DATA} ${FILESDIR}/zrepl.yml ${STAGEDIR}${ETCDIR}/zrepl.yml.sample
${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/weekly
${INSTALL_SCRIPT} ${WRKDIR}/500.zrepl \
${STAGEDIR}${PREFIX}/etc/periodic/weekly/500.zrepl
post-install-EXAMPLES-on: post-install-EXAMPLES-on:
@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}/hooks @${MKDIR} ${STAGEDIR}${EXAMPLESDIR}/hooks

View File

@ -0,0 +1,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

View File

@ -22,6 +22,16 @@ DANGER - SNAPSHOT PRUNING REQUIRES EXPLICIT KEEP RULES:
For any ZFS snapshot that you want to keep, at least one rule must match. For any ZFS snapshot that you want to keep, at least one rule must match.
This also applies to snapshots taken by means other than zrepl This also applies to snapshots taken by means other than zrepl
(e.g. snapshots taken manually or via boot environment tools). (e.g. snapshots taken manually or via boot environment tools).
In order to automatically warn the operator of impending certificate
expiration, add this line to /etc/periodic.conf:
weekly_zrepl_enable="YES"
More config details in the zrepl periodic script:
%%LOCALBASE%%/etc/periodic/weekly/500.zrepl
EOM EOM
} }
] ]

View File

@ -1,4 +1,5 @@
bin/zrepl bin/zrepl
etc/periodic/weekly/500.zrepl
@sample %%ETCDIR%%/zrepl.yml.sample @sample %%ETCDIR%%/zrepl.yml.sample
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/bandwidth_limit.yml %%PORTEXAMPLES%%%%EXAMPLESDIR%%/bandwidth_limit.yml
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/grafana-prometheus-zrepl.json %%PORTEXAMPLES%%%%EXAMPLESDIR%%/grafana-prometheus-zrepl.json