netcardconfig: use 'udevadm info' instead of 'udevinfo'
[grml-network.git] / sbin / grml-bridge
index 1a4b9c8..b15ad98 100755 (executable)
@@ -4,7 +4,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Mit Okt 11 23:02:51 CEST 2006 [moemoe]
+# Latest change: Mit Mär 26 23:02:52 CET 2008 [mika]
 ################################################################################
 
 # exit on any error
@@ -45,12 +45,20 @@ case "$1" in
                 no|false)
                     ;;
                 *)
-                    einfo "Setting Spanning-Tree Protocol (STP) to status"
+                    einfo "Setting Spanning-Tree Protocol (STP) to status $STP"
                     brctl stp "$BRIDGE_NAME" $STP
                     eend $?
                     ;;
             esac
 
+            einfo "Bringing network device up: "
+            eindent
+               for i in $BRIDGE_DEVICES ; do
+                   einfo "$i"
+                   ifconfig "$i" 0.0.0.0 up ; eend $?
+               done
+            eoutdent
+
             einfo "Enabling promiscous mode on: "
             eindent
                for i in $BRIDGE_DEVICES ; do
@@ -73,7 +81,7 @@ case "$1" in
                case $BRIDGE_CONFIG in
                        DHCP)
                          einfo "starting dhclient for $BRIDGE_NAME"
-                         dhclient -e -pf /var/run/dhclient.$BRIDGE_NAME.pid -lf /var/run/dhclient.$BRIDGE_NAME.leases $BRIDGE_NAME
+                         dhclient -pf /var/run/dhclient.$BRIDGE_NAME.pid -lf /var/run/dhclient.$BRIDGE_NAME.leases $BRIDGE_NAME
                        ;;
                        FIXED)
                          einfo "Setting IP for $BRIDGE_NAME to $BRIDGE_IP"
@@ -92,7 +100,9 @@ case "$1" in
         eindent
             if [ $BRIDGE_CONFIG = DHCP ]; then
                einfo "Terminating dhclient for $BRIDGE_NAME"
-               kill $(cat /var/run/dhclient.$BRIDGE_NAME.pid);
+               if [ -r "/var/run/dhclient.$BRIDGE_NAME.pid" ] ; then
+                 kill "$(cat /var/run/dhclient.$BRIDGE_NAME.pid)" || /bin/true
+               fi
             fi
             einfo "Removing network devices from $BRIDGE_NAME: "
 
@@ -115,6 +125,7 @@ case "$1" in
             ip link set "$BRIDGE_NAME" down; eend $?
 
             einfo "Removing bridge device"
+            ifconfig "$BRIDGE_NAME" down || /bin/true
             brctl delbr "$BRIDGE_NAME"
             eend $?
         eoutdent