summaryrefslogtreecommitdiff
path: root/usr/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usr/lib')
-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