chiark / gitweb /
contrib/, vars.am: systemd service definitions.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 20 Jul 2014 13:53:18 +0000 (14:53 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 21 Jul 2014 00:27:16 +0000 (01:27 +0100)
contrib/Makefile.am
contrib/tripe-service.service.in [new file with mode: 0644]
contrib/tripe.service.in [new file with mode: 0644]
debian/tripe.install
vars.am

index 8dfc710..3bd4591 100644 (file)
@@ -53,6 +53,31 @@ tripe-upstart: tripe-upstart.in Makefile
        $(SUBST) $(srcdir)/tripe-upstart.in >$@.new $(SUBSTITUTIONS) && \
                mv $@.new $@
 
+## Systemd units.
+noinst_DATA            += tripe.service
+EXTRA_DIST             += tripe.service.in
+CLEANFILES             += tripe.service
+
+tripe.service: tripe.service.in Makefile
+       $(SUBST) $(srcdir)/tripe.service.in >$@.new $(SUBSTITUTIONS) && \
+               mv $@.new $@
+
+noinst_DATA            += tripe-connect.service tripe-conntrack.service
+EXTRA_DIST             += tripe-service.service.in
+CLEANFILES             += tripe-connect.service tripe-conntrack.service
+
+tripe-connect.service: tripe-service.service.in Makefile
+       $(SUBST) $(srcdir)/tripe-service.service.in >$@.new \
+                       $(SUBSTITUTIONS) service=connect \
+                       descr="manage peer connections" && \
+               mv $@.new $@
+
+tripe-conntrack.service: tripe-service.service.in Makefile
+       $(SUBST) $(srcdir)/tripe-service.service.in >$@.new \
+                       $(SUBSTITUTIONS) service=conntrack \
+                       descr="track network connectivity" && \
+               mv $@.new $@
+
 ## `greet' utility for stimulating passive connections.
 if HAVE_PYTHON
 noinst_SCRIPTS         += greet
diff --git a/contrib/tripe-service.service.in b/contrib/tripe-service.service.in
new file mode 100644 (file)
index 0000000..bdecb1c
--- /dev/null
@@ -0,0 +1,20 @@
+;;; -*-conf-windows-*-
+;;;
+;;; systemd service configuration for tripe services [@service@]
+
+[Unit]
+Description=Tripe service @service@: @descr@
+Documentation=man:@service@(8)
+
+ConditionPathExists=@pkglibdir@/services/@service@
+
+After=tripe.service
+Requires=tripe.service
+
+[Install]
+WantedBy=tripe.service
+
+[Service]
+Type=simple
+
+ExecStart=@pkglibdir@/services/@service@
diff --git a/contrib/tripe.service.in b/contrib/tripe.service.in
new file mode 100644 (file)
index 0000000..7261c1a
--- /dev/null
@@ -0,0 +1,65 @@
+;;; -*-conf-windows-*-
+;;;
+;;; systemd service configuration for the main tripe server.
+
+[Unit]
+Description=Tripe virtual private network server
+Documentation=man:tripe(8)
+
+ConditionPathExists=@sbindir@/tripe
+ConditionPathExists=@bindir@/tripectl
+
+After=syslog.target network.target
+
+[Install]
+WantedBy=multi-user.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/tripectl.pid
+
+ExecStart=/bin/sh -e -c ' \
+       . @initconfig@ && \
+       logopt= && \
+       case $${syslogp-nil} in nil) ;; *) logopt="$$logopt -l" ;; esac && \
+       case $${logfile+t},$${syslogp-nil} in \
+         t,*) logopt="$$logopt -f$$logfile" ;; \
+         ,nil) logopt="$$logopt -f@logfile@" ;; \
+       esac && \
+       exec @bindir@/tripectl -D -s -p@sbindir@/tripe \
+         -P/var/run/tripectl.pid \
+         $$logopt \
+         $${keytag+-S-t$$keytag} \
+         $${addr+-S-b$$addr} $${port+-S-p$$port} \
+         $${user+-U$$user} $${group+-G$$group} \
+         $${sockmode+-S-m$$sockmode} \
+         $${trace+-S-t$$trace} \
+         $${tunnel+-S-n$$tunnel} \
+         $$miscopts'
+
+ExecReload=@bindir@/tripectl RELOAD
+ExecStop=@bindir@/tripectl QUIT
+
+ExecStartPre=/bin/sh -e -c ' \
+       if { test -f /proc/misc && grep -q tun /proc/misc; } || \
+          modprobe -q tun; \
+       then \
+         : good; \
+       else \
+         echo >&2 "tripe needs the TUN/TAP driver"; exit 1; \
+       fi; \
+       if test -c /dev/net/tun; then \
+         : good; \
+       else \
+         echo >&2 "tripe needs /dev/net/tun, which is missing"; \
+         exit 1; \
+       fi'
+
+ExecStartPost=/bin/sh -e -c ' \
+       for i in 1 2 3 4 give-up; do \
+         @bindir@/tripectl HELP >/dev/null 2>&1 && break; \
+         sleep 1; \
+       done; \
+       case $$i in \
+         give-up) echo >&2 "tripe daemon failed to start"; exit 1 ;; \
+       esac'
index 6f8001a..b435f6d 100644 (file)
@@ -13,3 +13,6 @@ debian/build/contrib/ipif-peers               /usr/share/doc/tripe/examples
 debian/build/contrib/tripe-upstart     /usr/share/doc/tripe/examples
 debian/build/contrib/greet             /usr/share/doc/tripe/examples
 debian/build/contrib/knock             /usr/share/doc/tripe/examples
+debian/build/contrib/tripe.service     /usr/share/doc/tripe/examples
+debian/build/contrib/tripe-conntrack.service /usr/share/doc/tripe/examples
+debian/build/contrib/tripe-connect.service /usr/share/doc/tripe/examples
diff --git a/vars.am b/vars.am
index 251a205..f7d3eff 100644 (file)
--- a/vars.am
+++ b/vars.am
@@ -61,7 +61,7 @@ SUBSTITUTIONS = \
                libdir=$(libdir) includedir=$(includedir) \
                bindir=$(bindir) sbindir=$(sbindir) \
                configdir=$(configdir) socketdir=$(socketdir) \
-               initconfig=$(initconfig) \
+               initconfig=$(initconfig) pkglibdir=$(pkglibdir) \
                pidfile=$(pidfile) logfile=$(logfile) \
                PACKAGE=$(PACKAGE) VERSION=$(VERSION) \
                PYTHON=$(PYTHON)