summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-emulation/qemu-softmmu/files/qemu-ifdown')
-rwxr-xr-xapp-emulation/qemu-softmmu/files/qemu-ifdown20
1 files changed, 20 insertions, 0 deletions
diff --git a/app-emulation/qemu-softmmu/files/qemu-ifdown b/app-emulation/qemu-softmmu/files/qemu-ifdown
new file mode 100755
index 000000000000..c173e43a9813
--- /dev/null
+++ b/app-emulation/qemu-softmmu/files/qemu-ifdown
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if [ -x /sbin/brctl ]; then
+ BRCTL="/sbin/brctl"
+elif [ -x /usr/sbin/brctl ]; then
+ BRCTL="/usr/sbin/brctl"
+else
+ echo "no bridge utils installed"
+ exit 1
+fi
+
+if [ -x /sbin/ip ]; then
+ switch=( $(/sbin/ip route list | awk '/^default / { sub(/.* dev /, ""); print $1 }') )
+ ${BRCTL} delif ${switch} $1
+ /sbin/ip link set $1 down
+else
+ switch=( $(/bin/netstat -rn | awk '/^0\.0\.0\.0/ { print $NF }') )
+ ${BRCTL} delif ${switch} $1
+ /sbin/ifconfig $1 down
+fi