X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=sbin%2Fgrml-bridge;h=0cfffc5fcb3096dca9c4b1cf3a2c8aca92e3ca8a;hb=af7e79258099000fb08013a77e1e83680ca4a59f;hp=c7decc7037b6455c78e5141d7f1bbd767adcfc01;hpb=d9b20539ba8824abdf7a72c73f45f4e940d61e60;p=grml-network.git diff --git a/sbin/grml-bridge b/sbin/grml-bridge index c7decc7..0cfffc5 100755 --- a/sbin/grml-bridge +++ b/sbin/grml-bridge @@ -4,33 +4,25 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Mit Mär 26 23:02:52 CET 2008 [mika] ################################################################################ -# exit on any error -set -e - CONFIG_FILE=/etc/grml/routersetup . /etc/grml/lsb-functions . /etc/grml/script-functions -check4root +check4root || exit 1 -if ! [ -r "$CONFIG_FILE" ] ; then - eerror "$CONFIG_FILE could not be read." - exit 1 +if [ -r "$CONFIG_FILE" ] ; then + . "$CONFIG_FILE" +else + ewarn "Could not read $CONFIG_FILE" fi -. "$CONFIG_FILE" - -if [ -z "$BRIDGE_DEVICES" ] ; then - eerror "Bridge devices (\$BRIDGE_DEVICES) not set in $CONFIG_FILE" - exit 1 -fi - -[ -n "$BRCTL" ] || BRCTL=brctl -[ -n "$STP" ] || STP=on -[ -n "$BRIDGE_NAME" ] || BRIDGE_NAME=br0 +# defaults if unconfigured +[ -n "$BRCTL" ] || BRCTL=brctl +[ -n "$BRIDGE_STP" ] || BRIDGE_STP=on +[ -n "$BRIDGE_NAME" ] || BRIDGE_NAME=br0 +[ -n "$BRIDGE_DEVICES" ] || BRIDGE_DEVICES='eth0 eth1' check4progs $BRCTL || exit 1 @@ -45,13 +37,21 @@ case "$1" in no|false) ;; *) - einfo "Setting Spanning-Tree Protocol (STP) to status" - brctl stp "$BRIDGE_NAME" $STP + einfo "Setting Spanning-Tree Protocol (STP) to status $BRIDGE_STP" + brctl stp "$BRIDGE_NAME" "$BRIDGE_STP" eend $? ;; esac - einfo "Enabling promiscous mode on: " + 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 promiscuous mode on: " eindent for i in $BRIDGE_DEVICES ; do einfo "$i" @@ -80,7 +80,7 @@ case "$1" in ip a a $BRIDGE_IP dev $BRIDGE_NAME ;; NONE) - einfo "Leaving $BRIDGE_NAME uconfigured" + einfo "Leaving $BRIDGE_NAME unconfigured" ;; esac eoutdent @@ -92,7 +92,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: " @@ -103,7 +105,7 @@ case "$1" in done eoutdent - einfo "Disabling promiscous mode on: " + einfo "Disabling promiscuous mode on: " eindent for i in $BRIDGE_DEVICES ; do einfo "$i " @@ -115,6 +117,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