--- trunk/magellan-initscripts/etc/rc.d/init.d/network 2009/11/05 12:57:14 931 +++ trunk/magellan-initscripts/etc/rc.d/init.d/network 2010/07/14 11:02:11 1092 @@ -64,6 +64,13 @@ local BRIDGE_INTERFACES local BRIDGE_STP + local BRIDGE_AGEING_TIME + local BRIDGE_PRIORITY + local BRIDGE_FORWARD_DELAY + local BRIDGE_HELLO_TIME + local BRIDGE_MAX_MESSAGE_AGE + local BRIDGE_PATH_COST + local BRIDGE_PORT_PRIORITY source ${file} eval value=\$$(echo ${var}) @@ -103,9 +110,12 @@ dhcp) if [[ -z ${DHCP_PROG} ]] then - echo "DHCP_PROG missing in net.${interface}, aborted" - exit 1 + echo -n "DHCP_PROG missing in net.${interface}," + echo "using default programm" + DHCP_PROG="/sbin/dhcpcd" fi + [[ -z ${DHCP_START} ]] && DHCP_START="-t 10" + [[ -z ${DHCP_STOP} ]] && DHCP_STOP="-k" ;; esac @@ -256,6 +266,73 @@ esac } +config_bridge_options() +{ + local iface="$1" + local i + local port + local cost + local prio + + # enable spanning-tree protocol + case ${BRIDGE_STP} in + on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;; + *) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; + esac + + # configure ageing time + if [[ ! -z ${BRIDGE_AGEING_TIME} ]] + then + brctl setageing "${iface}" "${BRIDGE_AGEING_TIME}" + fi + + # configure bridge priority + if [[ ! -z ${BRIDGE_PRIORITY} ]] + then + brctl setbridgeprio "${iface}" "${BRIDGE_PRIORITY}" + fi + + # configure forward delay + if [[ ! -z ${BRIDGE_FORWARD_DELAY} ]] + then + brctl setfd "${iface}" "${BRIDGE_FORWARD_DELAY}" + fi + + # configure hello time + if [[ ! -z ${BRIDGE_HELLO_TIME} ]] + then + brctl sethello "${iface}" "${BRIDGE_HELLO_TIME}" + fi + + # configure maximal message age + if [[ ! -z ${BRIDGE_MAX_MESSAGE_AGE} ]] + then + brctl setmaxage "${iface}" "${BRIDGE_MAX_MESSAGE_AGE}" + fi + + # configure path cost for every port + if [[ ! -z ${BRIDGE_PATH_COST} ]] + then + for i in ${BRIDGE_PATH_COST} + do + port="${i%=*}" + cost="${i#*=}" + [[ ! -z ${port} ]] && brctl pathcost "${iface}" "${port}" "${cost}" + done + fi + + # configure port priority for every port + if [[ ! -z ${BRIDGE_PORT_PRIORITY} ]] + then + for i in ${BRIDGE_PORT_PRIORITY} + do + port="${i%=*}" + prio="${i#*=}" + [[ ! -z ${port} ]] && brctl setportprio "${iface}" "${port}" "${prio}" + done + fi +} + config_bridge_devices() { local iface="$1" @@ -291,31 +368,28 @@ case ${method} in add) # setup the bridge device - brctl addbr ${iface} + brctl addbr "${iface}" for bport in ${BRIDGE_INTERFACES} do # enter promiscous mode - ifconfig ${bport} 0.0.0.0 promisc + ifconfig "${bport}" 0.0.0.0 promisc # now setup the bridge - brctl addif ${iface} ${bport} + brctl addif "${iface}" "${bport}" done - # enable spanning-tree protocol - case ${BRIDGE_STP} in - on|off) brctl stp ${iface} ${BRIDGE_STP} ;; - *) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; - esac + # configure all other options + config_bridge_options "${iface}" ;; remove) for bport in ${BRIDGE_INTERFACE} do # bring the interface down - ifconfig ${bport} down + ifconfig "${bport}" down # remove the interface from the bridge - brctl delif ${iface} ${bport} + brctl delif "${iface}" "${bport}" done # bring the bridge down - brctl delbr ${iface} + brctl delbr "${iface}" ;; esac @@ -349,7 +423,7 @@ \#*|"") continue ;; esac echo -e ${COLOREDSTAR}"${message}" - route ${method} ${route} + route "${method}" "${route}" evaluate_retval done fi @@ -361,9 +435,9 @@ if [[ -z $1 ]] then - ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) + ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) else - if [[ -e ${network_settings}/net.$1 ]] + if [[ -e ${rc_network_settings}/net.$1 ]] then ALL_INTERFACES="$1" else @@ -378,11 +452,11 @@ for iface in ${ALL_INTERFACES} do # checkconfig - source ${network_settings}/net.${iface} || exit 1 + source ${rc_network_settings}/net.${iface} || exit 1 checkconfig # setup mac - if [ -n "${FORCE_MAC_TO}" ] + if [[ -n ${FORCE_MAC_TO} ]] then echo -e ${COLOREDSTAR}"Faking MAC to ${FORCE_MAC_TO} for ${COLBLUE}${iface}${COLDEFAULT} ... " ifconfig "${iface}" hw ether "${FORCE_MAC_TO}" @@ -392,7 +466,7 @@ # setup bridges if [[ ${iface} = br[0-9]* ]] then - config_bridge_devices ${iface} add + config_bridge_devices "${iface}" add fi # now configure wireless_extensions @@ -409,7 +483,7 @@ ${CURS_UP} ${SET_WWCOL} echo "[DHCP]" - loadproc ${DHCP_PROG} ${DHCP_START} "${iface}" + loadproc "${DHCP_PROG}" "${DHCP_START}" "${iface}" ;; static|STATIC) ${CURS_UP} @@ -424,19 +498,27 @@ if [[ -n ${GATEWAY} ]] then echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." - route add default gateway ${GATEWAY} metric 1 dev ${iface} + route add default gateway "${GATEWAY}" metric 1 dev "${iface}" evaluate_retval unset GATEWAY fi # setup /etc/resolv.conf + # whipe out the old one + echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf + # include head + if [ -f /etc/resolv.conf.head ] + then + cat /etc/resolv.conf.head >> /etc/resolv.conf + else + echo "# /etc/resolv.conf.head can replace this line" >> /etc/resolv.conf + fi + # add given nameserver if [[ -n ${NAMESERVER} ]] then echo -e ${COLOREDSTAR}"Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..." - - # whipe out the old one - echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf + for dns in ${NAMESERVER} do echo "nameserver ${dns}" >> /etc/resolv.conf @@ -444,6 +526,13 @@ unset NAMESERVER fi + # include tail + if [ -f /etc/resolv.conf.tail ] + then + cat /etc/resolv.conf.tail >> /etc/resolv.conf + else + echo "# /etc/resolv.conf.tail can replace this line" >> /etc/resolv.conf + fi done # setup user routes @@ -454,9 +543,9 @@ { if [[ -z $1 ]] then - ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) + ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) else - if [[ -e ${network_settings}/net.$1 ]] + if [[ -e ${rc_network_settings}/net.$1 ]] then ALL_INTERFACES="$1" else @@ -470,7 +559,7 @@ # get list of all devices for iface in ${ALL_INTERFACES} do - source ${network_settings}/net.${iface} || exit 1 + source ${rc_network_settings}/net.${iface} || exit 1 checkconfig if [[ -n ${GATEWAY} ]] @@ -487,7 +576,7 @@ # remove bridges if [[ ${iface} = br[0-9]* ]] then - config_bridge_devices ${iface} remove + config_bridge_devices "${iface}" remove fi # shutdown dhcp-daemon