]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
systemd: Use automake tools to install unit files
authorChristian Hesse <mail@eworm.de>
Tue, 24 Jan 2017 14:39:46 +0000 (15:39 +0100)
committerDavid Sommerseth <davids@openvpn.net>
Wed, 25 Jan 2017 18:41:34 +0000 (19:41 +0100)
If systemd is enabled we install unit files to $libdir/systemd/system
(or the path specified by SYSTEMD_UNIT_DIR).
The unit files are generated on the fly with matching $sbindir.

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170124143947.27385-1-list@eworm.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13940.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit ca5b4c2aad2370be7862660d274b7485f2d0af71)

.gitignore
configure.ac
distro/Makefile.am
distro/systemd/Makefile.am [new file with mode: 0644]
distro/systemd/openvpn-client@.service.in [moved from distro/systemd/openvpn-client@.service with 90% similarity]
distro/systemd/openvpn-server@.service.in [moved from distro/systemd/openvpn-server@.service with 91% similarity]

index e6da21c63432958efab552b33f734fb0e4369dd6..30e289bbed65294e710062dbfe95609702a2d6eb 100644 (file)
@@ -51,6 +51,7 @@ config-msvc-local.h
 config-msvc-version.h
 doc/openvpn.8.html
 distro/rpm/openvpn.spec
+distro/systemd/*.service
 sample/sample-keys/sample-ca/
 vendor/.build
 vendor/dist
index 8783109f801ed767fb709b372af2aa6fab921c6c..48d8f0cdb31c71e36f636b1064495fdc7539f38d 100644 (file)
@@ -378,6 +378,7 @@ AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests
 AC_ARG_VAR([MAN2HTML], [path to man2html utility])
 AC_ARG_VAR([GIT], [path to git utility])
 AC_ARG_VAR([SYSTEMD_ASK_PASSWORD], [path to systemd-ask-password utility])
+AC_ARG_VAR([SYSTEMD_UNIT_DIR], [Path of systemd unit directory @<:@default=LIBDIR/systemd/system@:>@])
 AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
 AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
 AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
@@ -1099,6 +1100,12 @@ if test "$enable_systemd" = "yes" ; then
     OPTIONAL_SYSTEMD_LIBS="${libsystemd_LIBS}"
     AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd integration])
     LIBS="${saved_LIBS}"
+
+    if test -n "${SYSTEMD_UNIT_DIR}"; then
+        systemdunitdir="${SYSTEMD_UNIT_DIR}"
+    else
+        systemdunitdir="\${libdir}/systemd/system"
+    fi
 fi
 
 
@@ -1275,6 +1282,8 @@ sampledir="\$(docdir)/sample"
 AC_SUBST([plugindir])
 AC_SUBST([sampledir])
 
+AC_SUBST([systemdunitdir])
+
 VENDOR_SRC_ROOT="\$(abs_top_srcdir)/vendor/"
 VENDOR_DIST_ROOT="\$(abs_top_builddir)/vendor/dist"
 VENDOR_BUILD_ROOT="\$(abs_top_builddir)/vendor/.build"
@@ -1313,6 +1322,7 @@ AC_CONFIG_FILES([
        distro/Makefile
        distro/rpm/Makefile
        distro/rpm/openvpn.spec
+       distro/systemd/Makefile
        include/Makefile
        src/Makefile
        src/compat/Makefile
index 7a9ffd0fbc715d0c007167752deb9dc793c8feae..eb0e5540b1d6a0e4127388b8dbd47821c58c2780 100644 (file)
@@ -12,6 +12,4 @@
 MAINTAINERCLEANFILES = \
        $(srcdir)/Makefile.in
 
-SUBDIRS = rpm
-
-EXTRA_DIST = systemd/openvpn-client@.service systemd/openvpn-server@.service
+SUBDIRS = rpm systemd
diff --git a/distro/systemd/Makefile.am b/distro/systemd/Makefile.am
new file mode 100644 (file)
index 0000000..b10c6ed
--- /dev/null
@@ -0,0 +1,26 @@
+#
+#  OpenVPN -- An application to securely tunnel IP networks
+#             over a single UDP port, with support for SSL/TLS-based
+#             session authentication and key exchange,
+#             packet encryption, packet authentication, and
+#             packet compression.
+#
+#  Copyright (C) 2017 OpenVPN Technologies, Inc. <sales@openvpn.net>
+#
+
+%.service: %.service.in Makefile
+       $(AM_V_GEN)sed -e 's|\@sbindir\@|$(sbindir)|' \
+               $< > $@.tmp && mv $@.tmp $@
+
+EXTRA_DIST = \
+       openvpn-client@.service.in \
+       openvpn-server@.service.in
+
+if ENABLE_SYSTEMD
+systemdunit_DATA = \
+       openvpn-client@.service \
+       openvpn-server@.service
+endif
+
+MAINTAINERCLEANFILES = \
+       $(srcdir)/Makefile.in
similarity index 90%
rename from distro/systemd/openvpn-client@.service
rename to distro/systemd/openvpn-client@.service.in
index 5618af3a37baaa35deeae4eca1b3bf267aadc686..d9337729a7bc6ec7bc672ee78628faba180694cb 100644 (file)
@@ -12,7 +12,7 @@ PrivateTmp=true
 RuntimeDirectory=openvpn-client
 RuntimeDirectoryMode=0710
 WorkingDirectory=/etc/openvpn/client
-ExecStart=/usr/sbin/openvpn --suppress-timestamps --nobind --config %i.conf
+ExecStart=@sbindir@/openvpn --suppress-timestamps --nobind --config %i.conf
 CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE
 LimitNPROC=10
 DeviceAllow=/dev/null rw
similarity index 91%
rename from distro/systemd/openvpn-server@.service
rename to distro/systemd/openvpn-server@.service.in
index b9b4dba18bbdb666b43bc2e973caaa382fda709a..da5c78e1a1fe21fc86da78ba861313f5c77f7455 100644 (file)
@@ -12,7 +12,7 @@ PrivateTmp=true
 RuntimeDirectory=openvpn-server
 RuntimeDirectoryMode=0710
 WorkingDirectory=/etc/openvpn/server
-ExecStart=/usr/sbin/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf
+ExecStart=@sbindir@/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf
 CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE
 LimitNPROC=10
 DeviceAllow=/dev/null rw