summaryrefslogtreecommitdiff
path: root/usr/lib/systemd/system-generator/anytun-generator
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2016-07-08 04:03:37 +0200
committerChristian Pointner <equinox@anytun.org>2016-07-08 04:03:37 +0200
commitb9aa07cbcf584a2d5bc9f9f2bd74cca2057e0494 (patch)
treea90d25b462437a484d502841f45dc36ded44997e /usr/lib/systemd/system-generator/anytun-generator
parentfixed requires= wants= and also= (diff)
added systemd generator
Diffstat (limited to 'usr/lib/systemd/system-generator/anytun-generator')
-rwxr-xr-xusr/lib/systemd/system-generator/anytun-generator23
1 files changed, 23 insertions, 0 deletions
diff --git a/usr/lib/systemd/system-generator/anytun-generator b/usr/lib/systemd/system-generator/anytun-generator
new file mode 100755
index 0000000..8e04ba9
--- /dev/null
+++ b/usr/lib/systemd/system-generator/anytun-generator
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# This systemd generator creates dependency symlinks that make all anytun
+# tunnels listed in /etc/anytun/autostart be started/stopped/reloaded
+# when anytun.service is started/stopped/reloaded.
+
+set -eu
+
+GENDIR="$1"
+WANTDIR="$1/anytun.service.wants"
+SERVICEFILE="/lib/systemd/system/anytun@.service"
+AUTOSTART="all"
+CONFIG_DIR=/usr/local/etc/anytun
+
+mkdir -p "$WANTDIR"
+
+if [ -f $CONFIG_DIR/autostart ] ; then
+ for NAME in `sed 's/#.*//' < $CONFIG_DIR/autostart | grep -e '\w'`; do
+ ln -s "$SERVICEFILE" "$WANTDIR/anytun@$NAME.service"
+ done
+fi
+
+exit 0