summaryrefslogtreecommitdiff
path: root/user/vde2/vde2.pre-up
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-07-27 04:21:53 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-07-27 04:21:53 -0500
commitdde7c77d0c5af6b66a6ca69376135558b7c11e8c (patch)
tree65f6ee81e380d85337ad571d0cc44f65535dcadb /user/vde2/vde2.pre-up
parent2d93668279aed9d04d659e1c353691e3ff19b58d (diff)
downloadpackages-dde7c77d0c5af6b66a6ca69376135558b7c11e8c.tar.gz
packages-dde7c77d0c5af6b66a6ca69376135558b7c11e8c.tar.bz2
packages-dde7c77d0c5af6b66a6ca69376135558b7c11e8c.tar.xz
packages-dde7c77d0c5af6b66a6ca69376135558b7c11e8c.zip
user/vde2: pull in, fix, modernise
Diffstat (limited to 'user/vde2/vde2.pre-up')
-rw-r--r--user/vde2/vde2.pre-up74
1 files changed, 74 insertions, 0 deletions
diff --git a/user/vde2/vde2.pre-up b/user/vde2/vde2.pre-up
new file mode 100644
index 000000000..991b38226
--- /dev/null
+++ b/user/vde2/vde2.pre-up
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+VDE_SWITCH=/usr/bin/vde_switch
+VDE_PLUG=/usr/bin/vde_plug
+SLIRPVDE=/usr/bin/slirpvde
+DPIPE=/usr/bin/dpipe
+RUNDIR=/var/run/vde2
+
+USER=vde2-net
+GROUP=vde2-net
+
+if [ ! -x $VDE_SWITCH ] || [ ! -x $SLIRPVDE ]; then
+ exit 0
+fi
+
+# this is not an interesting stanza for us
+if [ -z "$IF_VDE2_SWITCH" -a -z "$IF_VDE2_PLUG" -a -z "$IF_VDE2_SLIRP" ]; then
+ exit 0
+fi
+
+
+# Create directory if missing
+if [ ! -d $RUNDIR ]; then
+ mkdir -p $RUNDIR
+ chown vde2-net:vde2-net $RUNDIR
+ chmod 2770 $RUNDIR
+fi
+
+# vde2-switch [-|<args>]
+if [ -n "$IF_VDE2_SWITCH" ]; then
+ set -- $IF_VDE2_SWITCH
+ test "$1" = "-" && shift
+ PIDFILE="$RUNDIR/$IFACE.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+ MGMTFILE="$RUNDIR/$IFACE.mgmt"
+
+ if [ "$METHOD" = "manual" ]; then
+ TAPOPTS=""
+ else
+ TAPOPTS="-t $IFACE"
+ fi
+
+ # block to make sure the interface exists, see #568363
+ vde_tunctl -b -t $IFACE 1>/dev/null
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --exec $VDE_SWITCH -- \
+ -s $CTLDIR -m 660 -g $GROUP -p $PIDFILE $TAPOPTS \
+ -M $MGMTFILE --mgmtmode 660 -d "$@"
+fi
+
+# vde2-plug <dpipe_cmd2>
+if [ -n "$IF_VDE2_PLUG" ]; then
+ set -- $IF_VDE2_PLUG
+ PIDFILE="$RUNDIR/$IFACE-plug.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --make-pidfile --background \
+ --exec $DPIPE -- $VDE_PLUG -g $GROUP -m 660 $CTLDIR = "$@"
+fi
+
+# vde2-slirp [-|<args>]
+if [ -n "$IF_VDE2_SLIRP" ]; then
+ set -- $IF_VDE2_SLIRP
+ test "$1" = "-" && shift
+ PIDFILE="$RUNDIR/$IFACE-slirp.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --chuid $USER \
+ --exec $SLIRPVDE -- \
+ -s $CTLDIR -m 660 -p $PIDFILE -d "$@"
+fi