From: Guus Sliepen Date: Sun, 10 Apr 2016 12:13:44 +0000 (+0200) Subject: Add systemd service files. X-Git-Tag: release-1.0.28~5 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=db8594f6f5cd40cbf3c52e97530459b4bfcba479;p=tinc Add systemd service files. --- diff --git a/Makefile.am b/Makefile.am index b09f5316..c03d0201 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = m4 src doc +SUBDIRS = m4 src doc distro ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index 332b863c..4aee2a36 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,8 @@ AC_PROG_INSTALL AM_PROG_CC_C_O +PKG_PROG_PKG_CONFIG + dnl Check and set OS AC_CANONICAL_HOST @@ -114,6 +116,21 @@ 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"]) + AM_CONDITIONAL(LINUX, test "$linux" = true) AM_CONDITIONAL(BSD, test "$bsd" = true) AM_CONDITIONAL(SOLARIS, test "$solaris" = true) @@ -229,6 +246,6 @@ AC_ARG_ENABLE(jumbograms, ] ) -AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile]) +AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile distro/Makefile]) AC_OUTPUT diff --git a/distro/Makefile.am b/distro/Makefile.am new file mode 100644 index 00000000..4e41f3b9 --- /dev/null +++ b/distro/Makefile.am @@ -0,0 +1,5 @@ +if HAVE_SYSTEMD +systemdsystemunit_DATA = \ + tinc.service \ + tinc@.service +endif diff --git a/distro/tinc.service b/distro/tinc.service new file mode 100644 index 00000000..1f015f0b --- /dev/null +++ b/distro/tinc.service @@ -0,0 +1,16 @@ +# 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 b/distro/tinc@.service new file mode 100644 index 00000000..4bb4d2dd --- /dev/null +++ b/distro/tinc@.service @@ -0,0 +1,17 @@ +[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 +ExecStop=/usr/sbin/tincd -n %i -k +TimeoutStopSec=5 +Restart=always +RestartSec=60 + +[Install] +WantedBy=tinc.service