Add systemd service files.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 10 Apr 2016 12:13:44 +0000 (14:13 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 10 Apr 2016 12:13:44 +0000 (14:13 +0200)
Makefile.am
configure.ac
distro/Makefile.am [new file with mode: 0644]
distro/tinc.service [new file with mode: 0644]
distro/tinc@.service [new file with mode: 0644]

index b09f53164359501aa1cd1983fc941c10dfd161f3..c03d02012060d1029a08f4ff6a3ff83c27bfe1ad 100644 (file)
@@ -2,7 +2,7 @@
 
 AUTOMAKE_OPTIONS = gnu
 
 
 AUTOMAKE_OPTIONS = gnu
 
-SUBDIRS = m4 src doc
+SUBDIRS = m4 src doc distro
 
 ACLOCAL_AMFLAGS = -I m4 
 
 
 ACLOCAL_AMFLAGS = -I m4 
 
index 332b863cdbdbcfc0809185202041ad14ce6c5475..4aee2a367606f619043d8fe3bf2e309d44176392 100644 (file)
@@ -21,6 +21,8 @@ AC_PROG_INSTALL
 
 AM_PROG_CC_C_O
 
 
 AM_PROG_CC_C_O
 
+PKG_PROG_PKG_CONFIG
+
 dnl Check and set OS
 
 AC_CANONICAL_HOST
 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)
 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
 
 AC_OUTPUT
diff --git a/distro/Makefile.am b/distro/Makefile.am
new file mode 100644 (file)
index 0000000..4e41f3b
--- /dev/null
@@ -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 (file)
index 0000000..1f015f0
--- /dev/null
@@ -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 (file)
index 0000000..4bb4d2d
--- /dev/null
@@ -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