Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline init for FreeBSD #631

Merged
merged 9 commits into from
Jan 22, 2024
5 changes: 5 additions & 0 deletions .github/workflows/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ canmount
CBuilder
cfg
cgi
cgit
checkinstall
chf
chgrp
Expand Down Expand Up @@ -215,6 +216,7 @@ foced
foreach
forkcall
FQSN
freebsd
FRONTEND
fsf
gerczei
Expand Down Expand Up @@ -444,6 +446,7 @@ qw
qwe
rbash
RCAPUTO
rcvar
README
recurseparent
recv
Expand Down Expand Up @@ -477,6 +480,7 @@ rw
sbin
sbindir
screation
SCRIPTFILE
scriptversion
secondarycache
SEENDST
Expand Down Expand Up @@ -530,6 +534,7 @@ stripprog
strptime
subdataset
SUBDIRS
subr
substvars
subsys
sudo
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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 <jimklimov@gmail.com> Tue, 9 Jan 2024 13:42:28 +0100

Expand Down
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
16 changes: 14 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -217,19 +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.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
Expand Down
18 changes: 18 additions & 0 deletions init/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
37 changes: 37 additions & 0 deletions init/znapzend.freebsd.in
Original file line number Diff line number Diff line change
@@ -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"
Loading