diff --git a/.github/workflows/spelling/expect.txt b/.github/workflows/spelling/expect.txt index 5bc85adf..02e18fc2 100644 --- a/.github/workflows/spelling/expect.txt +++ b/.github/workflows/spelling/expect.txt @@ -73,6 +73,7 @@ canmount CBuilder cfg cgi +cgit checkinstall chf chgrp @@ -215,6 +216,7 @@ foced foreach forkcall FQSN +freebsd FRONTEND fsf gerczei @@ -444,6 +446,7 @@ qw qwe rbash RCAPUTO +rcvar README recurseparent recv @@ -477,6 +480,7 @@ rw sbin sbindir screation +SCRIPTFILE scriptversion secondarycache SEENDST @@ -530,6 +534,7 @@ stripprog strptime subdataset SUBDIRS +subr substvars subsys sudo diff --git a/CHANGES b/CHANGES index 39dab665..f92c0e74 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ znapzend (0.21.3) unstable; urgency=medium * Maintenance release: refine splitting of [[user@]host:]dataset[:with-colons][@snap[:with-colons]] strings to work for the realistic majority of use-cases; fix back support of pool root dataset in such spec * Update self-tests with verification that [[user@]host:]dataset[:with-colons][@snap[:with-colons]] string decoding yields expected results * Fixed CI recipes and contents for spell-checker + * Added rc-script and integration documentation for FreeBSD and similar platforms -- Jim Klimov Tue, 9 Jan 2024 13:42:28 +0100 diff --git a/Makefile.am b/Makefile.am index 4a28326c..8e44a1a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,6 +12,8 @@ PM := $(shell find $(srcdir)/lib/ -name "*.pm") MAN = man/znapzend.1 man/znapzendzetup.1 man/znapzendztatz.1 POD = doc/znapzend.pod doc/znapzendzetup.pod doc/znapzendztatz.pod +RM_F = $(RM) -f + GENERATED_EXTRADIST = $(MAN) EXTRA_DIST = VERSION COPYRIGHT README.md LICENSE CHANGES AUTHORS cpanfile $(BIN) $(PM) \ $(GENERATED_EXTRADIST) init/README.md init/org.znapzend.plist.in init/znapzend.default \ @@ -68,7 +70,7 @@ endif # Clean up files that may be generated by the likes of # `DEBUG_ZNAPZEND_SELFTEST_REWRITE=yes ./t/znapzend.t` clean-selftest-rewritten: - $(RM) */*.selftest-rewritten */*/*.selftest-rewritten + $(RM_F) */*.selftest-rewritten */*/*.selftest-rewritten clean-pidfiles: if test -n "`ls znapzend*.pid 2>/dev/null || true`" ; then \ diff --git a/configure.ac b/configure.ac index 3ff22306..3eb88861 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,7 @@ AC_PATH_PROG(PERL, perl, no) AC_PATH_PROG(CURL, curl, no) AC_PATH_PROG(WGET, wget, no) AC_PATH_PROG(POD2MAN, pod2man, no) +AC_PATH_PROG(RM, rm, no) AC_ARG_ENABLE([deb_build], @@ -217,6 +218,7 @@ LIBDIR=${conftemp} AC_DEFINE_UNQUOTED(LIBDIR, "${conftemp}", [Default path for system libraries]) AC_SUBST(LIBDIR) +AC_MSG_NOTICE([Generating "data" files from templates, see below for executable scripts]) AC_CONFIG_FILES([ Makefile thirdparty/Makefile @@ -224,12 +226,22 @@ AC_CONFIG_FILES([ debian/Makefile debian/znapzend.links init/znapzend.service - init/znapzend.sysv - init/znapzend.upstart init/znapzend.xml init/org.znapzend.plist ]) +AC_MSG_NOTICE([Generating templated script files that should be marked executable]) +m4_foreach_w([SCRIPTFILE], [ + init/znapzend.freebsd + init/znapzend.sysv + init/znapzend.upstart +], [ + dnl Autoconf substitutes the token above specified in plain text, + dnl e.g. the brace below is empty and bracket gives verbatim varname + dnl AC_MSG_NOTICE([Script: SCRIPTFILE brace:(${SCRIPTFILE}) bracket:([SCRIPTFILE])]) + AC_CONFIG_FILES(SCRIPTFILE, chmod +x "SCRIPTFILE") +]) + AC_SUBST(VERSION) AC_OUTPUT diff --git a/init/README.md b/init/README.md index c9e3cb05..53bf4438 100644 --- a/init/README.md +++ b/init/README.md @@ -105,3 +105,21 @@ service znapzend start If you want to set parameters for the znapzend daemon separately from the init script, copy ```znapzend.default``` to ```/etc/default/znapzend``` and edit it. + +## FreeBSD + +For systems based on FreeBSD, you can copy the generated ```znapzend.freebsd``` +file to ```/etc/rc.d/znapzend``` and make sure it is executable, and then add +the following line(s) to your ```/etc/rc.conf``` file to enable or disable +znapzend as a service: + +```sh +# znapzend_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable znapzend. +znapzend_enable="YES" +``` + +If you want to set parameters for the znapzend daemon separately from the +rc-script, copy ```znapzend.default``` to ```/etc/defaults/znapzend``` +and edit it. Note that the rc-script in all cases provides a set of its +own ```command_args``` to manage daemonization, logging and PID file use. diff --git a/init/znapzend.freebsd.in b/init/znapzend.freebsd.in new file mode 100644 index 00000000..3694714d --- /dev/null +++ b/init/znapzend.freebsd.in @@ -0,0 +1,37 @@ +#!/bin/sh + +# PROVIDE: znapzend +# REQUIRE: LOGIN +# KEYWORD: shutdown + +# +# Add the following line to /etc/rc.conf to enable znapzend: +# znapzend_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable znapzend. +# + +# This file in znapzend project originated in FreeBSD ports integration at: +# https://cgit.freebsd.org/ports/blame/sysutils/znapzend/files/znapzend.in + +. /etc/rc.subr + +name=znapzend +desc="Znapzend backup daemon" +rcvar=znapzend_enable + +load_rc_config $name + +: ${znapzend_enable:=NO} + +extra_commands=reload +command_interpreter=/usr/local/bin/perl +sig_reload=HUP +pidfile=/var/run/${name}.pid +command=@PREFIX@/bin/${name} +command_args="--daemonize --pidfile=${pidfile} --logto=/var/log/znapzend.log" + +if grep ZNAPZENDOPTIONS= /etc/defaults/znapzend > /dev/null ; then + . /etc/defaults/znapzend && command_args="$command_args $ZNAPZENDOPTIONS" +fi + +run_rc_command "$1"