AM_PROG_CC_C_O
-PKG_PROG_PKG_CONFIG
-
dnl Check and set OS
AC_CANONICAL_HOST
]
)
-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)
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
-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 > $@
--- /dev/null
+[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