From 49c1a82ec12e97da85ad1896514d5b964c08f7f4 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Jan 2024 13:45:53 +0000 Subject: [PATCH 1/9] Import init/znapzend.freebsd.in from FreeBSD ports Snatched from https://cgit.freebsd.org/ports/tree/sysutils/znapzend/files/znapzend.in?id=e5474f0f70649c210a347a94c9c0bcf1124c2952 as is for the first step Signed-off-by: Jim Klimov --- init/znapzend.freebsd.in | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 init/znapzend.freebsd.in diff --git a/init/znapzend.freebsd.in b/init/znapzend.freebsd.in new file mode 100644 index 00000000..a997c935 --- /dev/null +++ b/init/znapzend.freebsd.in @@ -0,0 +1,30 @@ +#!/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. +# + +. /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" + +run_rc_command "$1" From 1b557d8acb578a1543e3ba52bfba105dc1c1d72b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Jan 2024 13:47:53 +0000 Subject: [PATCH 2/9] init/znapzend.freebsd.in: tie into znapzend autoconf Signed-off-by: Jim Klimov --- configure.ac | 1 + init/znapzend.freebsd.in | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3ff22306..2e8affae 100644 --- a/configure.ac +++ b/configure.ac @@ -223,6 +223,7 @@ AC_CONFIG_FILES([ lib/Makefile debian/Makefile debian/znapzend.links + init/znapzend.freebsd init/znapzend.service init/znapzend.sysv init/znapzend.upstart diff --git a/init/znapzend.freebsd.in b/init/znapzend.freebsd.in index a997c935..4cf16c5c 100644 --- a/init/znapzend.freebsd.in +++ b/init/znapzend.freebsd.in @@ -24,7 +24,7 @@ extra_commands=reload command_interpreter=/usr/local/bin/perl sig_reload=HUP pidfile=/var/run/${name}.pid -command=%%PREFIX%%/bin/${name} +command=@PREFIX@/bin/${name} command_args="--daemonize --pidfile=${pidfile} --logto=/var/log/znapzend.log" run_rc_command "$1" From 1e110c8b612d583a9bfc97d15cc02bd6bc95103f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Jan 2024 13:54:09 +0000 Subject: [PATCH 3/9] init/README.md: suggest how to use znapzend.freebsd Signed-off-by: Jim Klimov --- init/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/init/README.md b/init/README.md index c9e3cb05..27a55843 100644 --- a/init/README.md +++ b/init/README.md @@ -105,3 +105,16 @@ 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" +``` From 4a2afce49a58f91bef850fa02eccfc9bd72b0f6e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Jan 2024 13:59:20 +0000 Subject: [PATCH 4/9] init/znapzend.freebsd.in: give credit where credit is due Signed-off-by: Jim Klimov --- init/znapzend.freebsd.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init/znapzend.freebsd.in b/init/znapzend.freebsd.in index 4cf16c5c..40d8fe9d 100644 --- a/init/znapzend.freebsd.in +++ b/init/znapzend.freebsd.in @@ -10,6 +10,9 @@ # 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 From ca3a18a382ed59cd9d456bd4f63bd51e632db9b8 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Jan 2024 14:03:54 +0000 Subject: [PATCH 5/9] init/znapzend.freebsd.in: add support for site-local /etc/defaults/znapzend configuration Signed-off-by: Jim Klimov --- init/README.md | 5 +++++ init/znapzend.freebsd.in | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/init/README.md b/init/README.md index 27a55843..53bf4438 100644 --- a/init/README.md +++ b/init/README.md @@ -118,3 +118,8 @@ znapzend as a service: # 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 index 40d8fe9d..3694714d 100644 --- a/init/znapzend.freebsd.in +++ b/init/znapzend.freebsd.in @@ -30,4 +30,8 @@ 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" From 245b70d64b49d23a5ce7c95787756f79befa8ed1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Jan 2024 14:07:22 +0000 Subject: [PATCH 6/9] Makefile.am: do not fail "make clean" if selftest-rewritten files were not created Signed-off-by: Jim Klimov --- Makefile.am | 4 +++- configure.ac | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) 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 2e8affae..a5eff36f 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], From 736d9e170e774a909d8ee45a0c58c8ee4af289ed Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Jan 2024 14:28:04 +0000 Subject: [PATCH 7/9] configure.ac: some init/*.in templates are for executable script files autoconf magic courtesy of NUT project Signed-off-by: Jim Klimov --- configure.ac | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index a5eff36f..3eb88861 100644 --- a/configure.ac +++ b/configure.ac @@ -218,20 +218,30 @@ 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 lib/Makefile debian/Makefile debian/znapzend.links - init/znapzend.freebsd 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 From 098432a2a2fa47cf05b801cd8a289e8b997c7203 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Jan 2024 14:40:38 +0000 Subject: [PATCH 8/9] .github/workflows/spelling/expect.txt: update for FreeBSD integration PR #631 --- .github/workflows/spelling/expect.txt | 5 +++++ 1 file changed, 5 insertions(+) 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 From a3c2ed62a5c7d0748679c758738dc8f23e90754e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 22 Jan 2024 13:23:41 +0100 Subject: [PATCH 9/9] CHANGES: update for FreeBSD integration bits --- CHANGES | 1 + 1 file changed, 1 insertion(+) 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