Remove hardcoded paths from systemd unit files.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 6 Jan 2018 15:17:35 +0000 (16:17 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 6 Jan 2018 15:17:35 +0000 (16:17 +0100)
Closes #160 on GitHub.

systemd/Makefile.am
systemd/tinc.service [deleted file]
systemd/tinc.service.in [new file with mode: 0644]
systemd/tinc@.service [deleted file]
systemd/tinc@.service.in [new file with mode: 0644]

index a1bfe124a32a64e53066d444c012aef812e4b75d..b350847af4a145ff306ae525b4bec3c7b3f0dafb 100644 (file)
@@ -1,4 +1,18 @@
+EXTRA_DIST = tinc.service.in tinc@.service.in
+
+CLEANFILES = tinc.service tinc@.service
+
 if WITH_SYSTEMD
 systemddir = @systemd_path@
 dist_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/systemd/tinc.service b/systemd/tinc.service
deleted file mode 100644 (file)
index d911fa7..0000000
+++ /dev/null
@@ -1,20 +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
-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=/etc/tinc
-
-[Install]
-WantedBy=multi-user.target
diff --git a/systemd/tinc.service.in b/systemd/tinc.service.in
new file mode 100644 (file)
index 0000000..b671042
--- /dev/null
@@ -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/systemd/tinc@.service b/systemd/tinc@.service
deleted file mode 100644 (file)
index d1f711d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-[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=/etc/tinc/%i
-ExecStart=/usr/sbin/tincd -n %i -D
-ExecReload=/usr/sbin/tinc -n %i reload
-KillMode=mixed
-Restart=on-failure
-RestartSec=5
-TimeoutStopSec=5
-
-[Install]
-WantedBy=tinc.service
diff --git a/systemd/tinc@.service.in b/systemd/tinc@.service.in
new file mode 100644 (file)
index 0000000..2d695ca
--- /dev/null
@@ -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@/tinc -n %i reload
+KillMode=mixed
+Restart=on-failure
+RestartSec=5
+TimeoutStopSec=5
+
+[Install]
+WantedBy=tinc.service