First works to improve systemd integration

Add openvpn-generator to mimic AUTOSTART feature from SysV init script
parent 98f974e9
......@@ -3,6 +3,9 @@ openvpn (2.3.4-1) unstable; urgency=medium
* Upload to unstable.
* New upstream release. (Closes: #752568)
* Add Turkish debconf translation. (Closes: #759879)
* Replace openvpn-systemd-helper with a systemd generator.
Thanks Ondřej Surý, Ansgar Burchardt and postgresql-common for
the ideas, help and inspiration.
-- Alberto Gonzalez Iniesta <agi@inittab.org> Tue, 02 Sep 2014 12:06:06 +0200
......
......@@ -7,6 +7,11 @@
# The VPN name refers to the VPN configutation file name.
# i.e. "home" would be /etc/openvpn/home.conf
#
# If you're running systemd, changing this variable will
# require running "systemctl daemon-reload" followed by
# a restart of the openvpn service (if you removed entries
# you may have to stop those manually)
#
#AUTOSTART="all"
#AUTOSTART="none"
#AUTOSTART="home office"
......
#!/bin/sh
# This systemd generator creates dependency symlinks that make all OpenVPN
# tunnels listed in /etc/default/openvpn's AUTOSTART be started/stopped/reloaded
# when openvpn.service is started/stopped/reloaded.
set -eu
GENDIR="$1"
WANTDIR="$1/openvpn.service.wants"
SERVICEFILE="/lib/systemd/system/openvpn@.service"
AUTOSTART="all"
CONFIG_DIR=/etc/openvpn
mkdir -p "$WANTDIR"
if test -e /etc/default/openvpn ; then
. /etc/default/openvpn
fi
# No VPNs automatically started
if test "x$AUTOSTART" = "xnone" ; then
exit 0
fi
if test "x$AUTOSTART" = "xall" -o -z "$AUTOSTART" ; then
for CONFIG in `cd $CONFIG_DIR; ls *.conf 2> /dev/null`; do
NAME=${CONFIG%%.conf}
ln -s "$SERVICEFILE" "$WANTDIR/openvpn@$NAME.service"
done
else
for NAME in $AUTOSTART ; do
if test -e $CONFIG_DIR/$NAME.conf ; then
ln -s "$SERVICEFILE" "$WANTDIR/openvpn@$NAME.service"
fi
done
fi
exit 0
debian/openvpn@.service /lib/systemd/system
debian/openvpn.conf /usr/lib/tmpfiles.d
debian/openvpn.service /lib/systemd/system
debian/openvpn-systemd-helper /usr/sbin
debian/openvpn-generator /lib/systemd/system-generators
# This service is actually a systemd target,
# but we are using a service since targets cannot be reloaded.
[Unit]
Description=OpenVPN service
After=network.target
......@@ -5,9 +8,8 @@ After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/openvpn-systemd-helper start
ExecStop=/usr/sbin/openvpn-systemd-helper stop
ExecReload=/usr/sbin/openvpn-systemd-helper reload
ExecStart=/bin/true
ExecStop=/bin/true
WorkingDirectory=/etc/openvpn
[Install]
......
[Unit]
Description=OpenVPN connection to %i
After=network.target
PartOf=openvpn.service
ReloadPropagatedFrom=openvpn.service
[Service]
Type=forking
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment