From 3125e393084124442e409bef697847a1f87fc531 Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez Iniesta Date: Fri, 14 Mar 2014 13:02:21 +0100 Subject: Add systemd support --- debian/changelog | 7 +++++++ debian/openvpn.if-down.d | 11 +++++++++-- debian/openvpn.if-up.d | 11 +++++++++-- debian/openvpn.install | 1 + debian/openvpn@.service | 13 +++++++++++++ debian/rules | 2 +- 6 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 debian/openvpn.install create mode 100644 debian/openvpn@.service diff --git a/debian/changelog b/debian/changelog index e9fc3f4..17733bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +openvpn (2.3.2-8) unstable; urgency=medium + + * Add support for systemd. (Closes: #700888) + Add openvpn@.service and --enable-systemd to ./configure. + + -- Alberto Gonzalez Iniesta Fri, 14 Mar 2014 12:59:57 +0100 + openvpn (2.3.2-7) unstable; urgency=low * Fix postinst when no *.pid files exist in /run/sendsigs.omit.d/. diff --git a/debian/openvpn.if-down.d b/debian/openvpn.if-down.d index 4610786..77cfb79 100644 --- a/debian/openvpn.if-down.d +++ b/debian/openvpn.if-down.d @@ -1,6 +1,8 @@ #!/bin/sh -OPENVPN=/etc/init.d/openvpn +OPENVPN=/usr/sbin/openvpn +OPENVPN_INIT=/etc/init.d/openvpn +SYSTEMCTL=/bin/systemctl if [ ! -x $OPENVPN ]; then exit 0 @@ -8,6 +10,11 @@ fi if [ -n "$IF_OPENVPN" ]; then for vpn in $IF_OPENVPN; do - $OPENVPN stop $vpn + ## check systemd present + if [ -x $SYSTEMCTL ]; then + $SYSTEMCTL stop openvpn@$vpn + else + $OPENVPN_INIT stop $vpn + fi done fi diff --git a/debian/openvpn.if-up.d b/debian/openvpn.if-up.d index 539112a..a6548a5 100644 --- a/debian/openvpn.if-up.d +++ b/debian/openvpn.if-up.d @@ -1,6 +1,8 @@ #!/bin/sh -OPENVPN=/etc/init.d/openvpn +OPENVPN=/usr/sbin/openvpn +OPENVPN_INIT=/etc/init.d/openvpn +SYSTEMCTL=/bin/systemctl if [ ! -x $OPENVPN ]; then exit 0 @@ -8,6 +10,11 @@ fi if [ -n "$IF_OPENVPN" ]; then for vpn in $IF_OPENVPN; do - $OPENVPN start $vpn + ## check systemd present + if [ -x $SYSTEMCTL ]; then + $SYSTEMCTL start openvpn@$vpn + else + $OPENVPN_INIT start $vpn + fi done fi diff --git a/debian/openvpn.install b/debian/openvpn.install new file mode 100644 index 0000000..f1b4436 --- /dev/null +++ b/debian/openvpn.install @@ -0,0 +1 @@ +debian/openvpn@.service /lib/systemd/system diff --git a/debian/openvpn@.service b/debian/openvpn@.service new file mode 100644 index 0000000..a7ec1ee --- /dev/null +++ b/debian/openvpn@.service @@ -0,0 +1,13 @@ +[Unit] +Description=OpenVPN connection to %i +After=network.target + +[Service] +Type=forking +ExecStart=/usr/sbin/openvpn --daemon ovpn-%i --status /run/openvpn/%i.status 10 --cd /etc/openvpn --config /etc/openvpn/%i.conf +WorkingDirectory=/etc/openvpn + +[Install] +WantedBy=multi-user.target + + diff --git a/debian/rules b/debian/rules index 95f835d..c5d982d 100755 --- a/debian/rules +++ b/debian/rules @@ -14,7 +14,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all dh $@ override_dh_auto_configure: - dh_auto_configure -- $(shell dpkg-buildflags --export=configure) --enable-password-save --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --with-ifconfig-path=/sbin/ifconfig $(ROUTE_ARGS) --with-plugindir=\$${prefix}/lib/openvpn --includedir=\$${prefix}/include/openvpn --enable-pkcs11 --enable-x509-alt-username + dh_auto_configure -- $(shell dpkg-buildflags --export=configure) --enable-password-save --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --with-ifconfig-path=/sbin/ifconfig $(ROUTE_ARGS) --with-plugindir=\$${prefix}/lib/openvpn --includedir=\$${prefix}/include/openvpn --enable-pkcs11 --enable-x509-alt-username --enable-systemd override_dh_auto_build: -- cgit v1.2.3