blob: cd9a16f8494c62e1e7c0a6e336e6c8c4619d0311 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
--- scripts/qemu-ifup.orig 2007-04-28 12:43:42.514362441 -0500
+++ scripts/qemu-ifup 2007-04-28 14:30:36.507875100 -0500
@@ -1,5 +1,19 @@
#!/bin/sh
-
-switch=$(/sbin/ip route list | awk '/^default / { print $NF }')
-/sbin/ifconfig $1 0.0.0.0 up
-/usr/sbin/brctl addif ${switch} $1
+cmd=""
+if [ "$EUID" != 0 ]; then
+ if [ -x "/usr/bin/sudo" ]; then
+ cmd="/usr/bin/sudo "
+ else
+ echo "You must have sudo or root privileges to bring up a network interface"
+ exit 0
+ fi
+fi
+echo "Bringing up interface $1"
+switch=$(/sbin/ip route list | awk '/^default / { print $5 }')
+if [[ $(/sbin/ifconfig | grep -c $1) -gt 0 ]]; then
+ ${cmd}/sbin/brctl delif ${switch} $1
+ ${cmd}/sbin/ifconfig $1 down
+fi
+${cmd}/usr/bin/tunctl -u $(/usr/bin/whoami) -t $1
+${cmd}/sbin/ifconfig $1 0.0.0.0 promisc up
+${cmd}/sbin/brctl addif ${switch} $1
|