From: Guus Sliepen Date: Sat, 6 Jan 2018 15:58:54 +0000 (+0100) Subject: Make systemd service file handling identical to tinc 1.1. X-Git-Tag: release-1.0.34~7 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a563e6dd8c88865351c05ebc72de86dac7a839d5;p=oweals%2Ftinc.git Make systemd service file handling identical to tinc 1.1. This removes hardcoded paths from systemd unit files, and sets the default systemd unit path to ${libdir}/systemd/system. The configure option is now renamed to --with-systemd[=PATH]. These changes now also ensure that make distcheck runs without any errors. Closes #160 on GitHub. --- diff --git a/configure.ac b/configure.ac index 85e51e9..ff57755 100644 --- a/configure.ac +++ b/configure.ac @@ -21,8 +21,6 @@ AC_PROG_INSTALL AM_PROG_CC_C_O -PKG_PROG_PKG_CONFIG - dnl Check and set OS AC_CANONICAL_HOST @@ -116,20 +114,16 @@ AC_ARG_WITH(windows2000, ] ) -AC_ARG_WITH([systemdsystemunitdir], - [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],, - [with_systemdsystemunitdir=auto]) -AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [ - def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) - - AS_IF([test "x$def_systemdsystemunitdir" = "x"], - [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], - [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) - with_systemdsystemunitdir=no], - [with_systemdsystemunitdir="$def_systemdsystemunitdir"])]) -AS_IF([test "x$with_systemdsystemunitdir" != "xno"], - [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]) -AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) +AC_ARG_WITH(systemd, + AS_HELP_STRING([--with-systemd@<:@=DIR@:>@], [install systemd service files @<:@to DIR if specified@:>@]), + [ systemd=true; systemd_path="$with_systemd" ], + [ systemd=false ] +) + +AS_IF([test "x$with_systemd" = "xyes"], [systemd_path="\${libdir}/systemd/system"], + [AS_IF([test "x$with_systemd" = "xno"], [systemd=false])]) + +AC_SUBST(systemd_path, $systemd_path) AM_CONDITIONAL(LINUX, test "$linux" = true) AM_CONDITIONAL(BSD, test "$bsd" = true) @@ -139,6 +133,7 @@ AM_CONDITIONAL(CYGWIN, test "$cygwin" = true) AM_CONDITIONAL(UML, test "$uml" = true) AM_CONDITIONAL(VDE, test "$vde" = true) AM_CONDITIONAL(TUNEMU, test "$tunemu" = true) +AM_CONDITIONAL(WITH_SYSTEMD, test "$systemd" = true) AC_CACHE_SAVE diff --git a/distro/Makefile.am b/distro/Makefile.am index 286c7b7..dac2b73 100644 --- a/distro/Makefile.am +++ b/distro/Makefile.am @@ -1,9 +1,18 @@ -EXTRA_DIST = \ - tinc.service \ - tinc@.service - -if HAVE_SYSTEMD -systemdsystemunit_DATA = \ - tinc.service \ - tinc@.service +EXTRA_DIST = tinc.service.in tinc@.service.in + +CLEANFILES = tinc.service tinc@.service + +if WITH_SYSTEMD +systemddir = @systemd_path@ +nodist_systemd_DATA = tinc.service tinc@.service endif + +substitute = sed \ + -e s,'@sbindir\@',"$(sbindir)",g \ + -e s,'@sysconfdir\@',"$(sysconfdir)",g + +tinc.service: $(srcdir)/tinc.service.in + $(AM_V_GEN)$(substitute) $(srcdir)/tinc.service.in > $@ + +tinc@.service: $(srcdir)/tinc@.service.in + $(AM_V_GEN)$(substitute) $(srcdir)/tinc@.service.in > $@ diff --git a/distro/tinc.service b/distro/tinc.service deleted file mode 100644 index 1f015f0..0000000 --- a/distro/tinc.service +++ /dev/null @@ -1,16 +0,0 @@ -# This is a mostly empty service, but allows commands like stop, start, reload -# to propagate to all tinc@ service instances. - -[Unit] -Description=Tinc VPN -After=network.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/bin/true -ExecReload=/bin/true -WorkingDirectory=/etc/tinc - -[Install] -WantedBy=multi-user.target diff --git a/distro/tinc.service.in b/distro/tinc.service.in new file mode 100644 index 0000000..b671042 --- /dev/null +++ b/distro/tinc.service.in @@ -0,0 +1,20 @@ +# This is a mostly empty service, but allows commands like stop, start, reload +# to propagate to all tinc@ service instances. + +[Unit] +Description=Tinc VPN +Documentation=info:tinc +Documentation=man:tinc(8) man:tinc.conf(5) +Documentation=http://tinc-vpn.org/docs/ +After=network.target +Wants=network.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/true +ExecReload=/bin/true +WorkingDirectory=@sysconfdir@/tinc + +[Install] +WantedBy=multi-user.target diff --git a/distro/tinc@.service b/distro/tinc@.service deleted file mode 100644 index 5869442..0000000 --- a/distro/tinc@.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=Tinc net %i -PartOf=tinc.service -ReloadPropagatedFrom=tinc.service - -[Service] -Type=simple -WorkingDirectory=/etc/tinc/%i -ExecStart=/usr/sbin/tincd -n %i -D -ExecReload=/usr/sbin/tincd -n %i -kHUP -KillMode=mixed -TimeoutStopSec=5 -Restart=always -RestartSec=60 - -[Install] -WantedBy=tinc.service diff --git a/distro/tinc@.service.in b/distro/tinc@.service.in new file mode 100644 index 0000000..8fbf551 --- /dev/null +++ b/distro/tinc@.service.in @@ -0,0 +1,20 @@ +[Unit] +Description=Tinc net %i +Documentation=info:tinc +Documentation=man:tinc(8) man:tinc.conf(5) +Documentation=http://tinc-vpn.org/docs/ +PartOf=tinc.service +ReloadPropagatedFrom=tinc.service + +[Service] +Type=simple +WorkingDirectory=@sysconfdir@/tinc/%i +ExecStart=@sbindir@/tincd -n %i -D +ExecReload=@sbindir@/tincd -n %i -kHUP +KillMode=mixed +Restart=on-failure +RestartSec=5 +TimeoutStopSec=5 + +[Install] +WantedBy=tinc.service