aboutsummaryrefslogtreecommitdiffstats
path: root/main/tunnel/tunnel
diff options
context:
space:
mode:
Diffstat (limited to 'main/tunnel/tunnel')
-rw-r--r--main/tunnel/tunnel26
1 files changed, 26 insertions, 0 deletions
diff --git a/main/tunnel/tunnel b/main/tunnel/tunnel
new file mode 100644
index 0000000000..a710f6b644
--- /dev/null
+++ b/main/tunnel/tunnel
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Tunnel interface configuration script
+# Copyright (c) 2017 Kaarle Ritvanen
+
+PARAMS=$(set | sed -E '
+ s/^IF_TUNNEL_([A-Z0-9_]+)=(.+)/\1\n\2/
+ ta
+ d
+ :a
+ h
+ y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ P
+ g
+ s/.*\n//
+ ')
+
+[ "$PARAMS" ] || exit 0
+
+if [ $MODE = start ]; then
+ eval ip tunnel add $IFACE $PARAMS
+elif [ $MODE = stop ]; then
+ ip tunnel del $IFACE
+else
+ exit 1
+fi