diff options
author | Alberto Gonzalez Iniesta <agi@inittab.org> | 2014-09-12 12:52:30 +0200 |
---|---|---|
committer | Alberto Gonzalez Iniesta <agi@inittab.org> | 2014-09-12 13:44:57 +0200 |
commit | 1f5bd7321e8029fa05f9e7f46a9a9a2e7568656f (patch) | |
tree | cde9313180cb2cf579556caa6fca5d6bdebbb96a /debian/openvpn-generator | |
parent | 98f974e98ad20013e5dc7cede60fcacf72524cee (diff) |
First works to improve systemd integration
Add openvpn-generator to mimic AUTOSTART feature from SysV init script
Diffstat (limited to 'debian/openvpn-generator')
-rwxr-xr-x | debian/openvpn-generator | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/debian/openvpn-generator b/debian/openvpn-generator new file mode 100755 index 0000000..d6ac1aa --- /dev/null +++ b/debian/openvpn-generator @@ -0,0 +1,40 @@ +#!/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 + |