diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-15 13:10:10 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-15 13:10:10 +0000 |
commit | 36681224a041c8256f2054f62d7b075743c9c1c6 (patch) | |
tree | f908bd3987d49aff62d9c5dad8642c4d77961a8c /main/vde2 | |
parent | 27ea70e01bb3a594eddcc08280bf20718ad859bd (diff) | |
download | aports-36681224a041c8256f2054f62d7b075743c9c1c6.tar.bz2 aports-36681224a041c8256f2054f62d7b075743c9c1c6.tar.xz |
main/vde2: add support for debian style network config
Diffstat (limited to 'main/vde2')
-rw-r--r-- | main/vde2/APKBUILD | 12 | ||||
-rw-r--r-- | main/vde2/vde2.post-down | 37 | ||||
-rw-r--r-- | main/vde2/vde2.pre-up | 74 |
3 files changed, 121 insertions, 2 deletions
diff --git a/main/vde2/APKBUILD b/main/vde2/APKBUILD index b4bf5bd0d..3fadb284b 100644 --- a/main/vde2/APKBUILD +++ b/main/vde2/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Michael Zhou <zhoumichaely@gmail.com> pkgname=vde2 pkgver=2.3.1 -pkgrel=3 +pkgrel=4 pkgdesc="VDE: Virtual Distributed Ethernet. User mode networking for QEMU, UML, etc." url="http://vde.sf.net" arch="all" @@ -12,6 +12,8 @@ subpackages="$pkgname-doc $pkgname-dev $pkgname-libs" source="http://downloads.sourceforge.net/project/vde/vde2/2.3.1/vde2-2.3.1.tar.gz vde.initd vde.confd + vde2.pre-up + vde2.post-down " _builddir="$srcdir"/$pkgname-$pkgver @@ -34,6 +36,10 @@ package() { install -Dm755 "$srcdir"/vde.initd "$pkgdir"/etc/init.d/vde || return 1 install -Dm644 "$srcdir"/vde.confd "$pkgdir"/etc/conf.d/vde || return 1 + install -Dm755 "$srcdir"/vde2.pre-up \ + "$pkgdir"/etc/network/if-pre-up.d/vde2 || return 1 + install -Dm755 "$srcdir"/vde2.post-down \ + "$pkgdir"/etc/network/if-post-down.d/vde2 || return 1 } libs() { @@ -44,4 +50,6 @@ libs() { md5sums="c8c2acb92a72f779e0b484b1543a1cc3 vde2-2.3.1.tar.gz 21c1b8e841978461aa5c87b3f8abf01d vde.initd -318c787df292690c4da5b6ed83dc1893 vde.confd" +318c787df292690c4da5b6ed83dc1893 vde.confd +e484324d93baf668d7ec756f36ebf389 vde2.pre-up +d9a32a3e77e64a265e00df5ab1081672 vde2.post-down" diff --git a/main/vde2/vde2.post-down b/main/vde2/vde2.post-down new file mode 100644 index 000000000..be5f5b31d --- /dev/null +++ b/main/vde2/vde2.post-down @@ -0,0 +1,37 @@ +#!/bin/sh + +VDE_SWITCH=/usr/bin/vde_switch +SLIRPVDE=/usr/bin/slirpvde + +# 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 + +PIDFILE="/var/run/vde2/$IFACE-plug.pid" +CTLFILE="/var/run/vde2/$IFACE.ctl" +if [ -f $PIDFILE ]; then + start-stop-daemon --stop --quiet --pidfile $PIDFILE + rm -f $PIDFILE +fi + +PIDFILE="/var/run/vde2/$IFACE-slirp.pid" +if [ -f $PIDFILE ]; then + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --exec $SLIRPVDE + rm -f $PIDFILE +fi + +PIDFILE="/var/run/vde2/$IFACE.pid" +CTLDIR="/var/run/vde2/$IFACE.ctl" +if [ -f $PIDFILE ]; then + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --exec $VDE_SWITCH + rm -f $PIDFILE + + # set the tap interface to non-persistant, see #568363 + vde_tunctl -b -d $IFACE 1>/dev/null +fi + +rm -rf $CTLDIR +rm -f $CTLDIR.* diff --git a/main/vde2/vde2.pre-up b/main/vde2/vde2.pre-up new file mode 100644 index 000000000..991b38226 --- /dev/null +++ b/main/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 |