From 07e2dff0f3f9b1007b26e28a932b5bc2dc6d5a20 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Wed, 4 Jun 2025 09:35:37 +0100 Subject: add a FreeBSD periodic script --- 900.lfacme.sh | 29 +++++++++++++++++++++++++++++ Makefile | 19 +++++++++++++++++-- README | 4 ++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 900.lfacme.sh diff --git a/900.lfacme.sh b/900.lfacme.sh new file mode 100644 index 0000000..dabb890 --- /dev/null +++ b/900.lfacme.sh @@ -0,0 +1,29 @@ +#! /bin/sh +# This source code is released into the public domain. +# +# Run lfacme-renew to renew ACME certificates. + +if [ -r /etc/defaults/periodic.conf ]; then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + +PATH=$PATH:/usr/local/bin:/usr/local/sbin +export PATH + +# Exit if lfacme isn't installed but the periodic script was left over +# for some reason. +if ! [ -x /usr/local/sbin/lfacme-renew ]; then + exit 0 +fi + +case "$daily_lfacme_enable" in +[Yy][Ee][Ss]) + printf 'Renewing ACME certificates with lfacme:\n' + + /usr/local/sbin/lfacme-renew + ;; + +*) + ;; +esac diff --git a/Makefile b/Makefile index 74edacf..bdbb426 100644 --- a/Makefile +++ b/Makefile @@ -39,12 +39,16 @@ MAN5= acme.conf.5 \ MAN8= lfacme-renew.8 \ lfacme-setup.8 +PERIODICDIR= /usr/local/etc/periodic/daily +PERIODICMODE?= 0755 +PERIODIC= 900.lfacme.sh + default: all all: @echo "Nothing to do." -install: install-lib install-bin install-conf install-hook install-man +install: install-lib install-bin install-conf install-hook install-man install-periodic install-lib: @echo 'create ${LIBDIR}'; install -d ${LIBDIR} @@ -96,5 +100,16 @@ install-man: install -C -m ${MANMODE} "$$man" "${MAN8DIR}/$$man"; \ done +install-periodic: + @if [ $$(uname) = "FreeBSD" ]; then \ + echo 'create ${PERIODICDIR}'; install -d ${PERIODICDIR}; \ + for periodic in ${PERIODIC}; do \ + basename=$${periodic%*.sh}; \ + echo "install ${PERIODICDIR}/$$basename"; \ + install -C -m ${PERIODICMODE} "$$periodic" \ + "${PERIODICDIR}/$$basename"; \ + done; \ + fi + .PHONY: default all install install-lib install-bin install-conf \ - install-hook install-man + install-hook install-man install-periodic diff --git a/README b/README index 9db4933..328d5d3 100644 --- a/README +++ b/README @@ -41,6 +41,10 @@ is assumed. DESTDIR is prepend to PREFIX when installing files, and may be used when creating packages. +a FreeBSD periodic(8) script is provided as "900.lfacme.sh" and will be +installed automatically on FreeBSD. to run lfacme-renew once a day to +renew certificates, set "daily_lfacme_enable=YES" in /etc/periodic.conf. + usage ----- -- cgit v1.2.3