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.in [moved from systemd/tinc.service with 92% similarity]
systemd/tinc@.service.in [moved from systemd/tinc@.service with 73% similarity]

index a1bfe12..b350847 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 > $@
similarity index 92%
rename from systemd/tinc.service
rename to systemd/tinc.service.in
index d911fa7..b671042 100644 (file)
@@ -14,7 +14,7 @@ Type=oneshot
 RemainAfterExit=yes
 ExecStart=/bin/true
 ExecReload=/bin/true
-WorkingDirectory=/etc/tinc
+WorkingDirectory=@sysconfdir@/tinc
 
 [Install]
 WantedBy=multi-user.target
similarity index 73%
rename from systemd/tinc@.service
rename to systemd/tinc@.service.in
index d1f711d..2d695ca 100644 (file)
@@ -8,9 +8,9 @@ ReloadPropagatedFrom=tinc.service
 
 [Service]
 Type=simple
-WorkingDirectory=/etc/tinc/%i
-ExecStart=/usr/sbin/tincd -n %i -D
-ExecReload=/usr/sbin/tinc -n %i reload
+WorkingDirectory=@sysconfdir@/tinc/%i
+ExecStart=@sbindir@/tincd -n %i -D
+ExecReload=@sbindir@/tinc -n %i reload
 KillMode=mixed
 Restart=on-failure
 RestartSec=5