--- trunk/magellan-initscripts/etc/rc.d/init.d/network 2004/12/31 18:40:23 19 +++ trunk/magellan-initscripts/etc/rc.d/init.d/network 2004/12/31 18:41:21 20 @@ -10,73 +10,73 @@ #%after: source /etc/sysconfig/rc -source $rc_functions +source ${rc_functions} checkconfig() { - if [ -z $NETWORKING ] + if [ -z "${NETWORKING}" ] then echo "NETWORKING missing in net.${interface}, aborted" exit 1 fi - case $NETWORKING in + case "${NETWORKING}" in static) - if [ -z $IP ] + if [ -z "${IP}" ] then echo "IP missing in net.${interface}, aborted" exit 1 fi - if [ -z $NETMASK ] + if [ -z "${NETMASK}" ] then echo -n "NETMASK missing in net.${interface}, " echo "using 255.255.255.0" NETMASK=255.255.255.0 fi - if [ -z $BROADCAST ] + if [ -z "${BROADCAST}" ] then echo -n "BROADCAST missing in net.${interface}, " echo "using default address" fi ;; + dhcp) - if [ -z $DHCP_PROG ] + if [ -z "${DHCP_PROG}" ] then echo "DHCP_PROG missing in net.${interface}, aborted" exit 1 fi ;; + esac } case "$1" in start) - for file in $(grep -il "ONBOOT=\"yes\"" $network_settings/net.*) + for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*) do - interface=$(basename $file | sed s/net.//) - case "$interface" in + interface=$(basename ${file} | sed s/net.//) + case "${interface}" in *~) ;; *) - #$network_devices/ifup $interface - source $network_settings/net.${interface} || exit 1 + source ${network_settings}/net.${interface} || exit 1 checkconfig - case $NETWORKING in + case "${NETWORKING}" in dhcp) echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..." - $CURS_UP - $SET_WWCOL + ${CURS_UP} + ${SET_WWCOL} echo "[DHCP]" - #modprobe $interface - loadproc $DHCP_PROG $DHCP_START + loadproc ${DHCP_PROG} ${DHCP_START} ;; static) echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..." - $CURS_UP - $SET_WWCOL + ${CURS_UP} + ${SET_WWCOL} echo "[STATIC]" - ifconfig $interface $IP netmask $NETMASK broadcast $BROADCAST + ifconfig ${interface} ${IP} netmask ${NETMASK} broadcast ${BROADCAST} evaluate_retval ;; esac @@ -84,11 +84,11 @@ esac done - if [ "$GATEWAY" != "" ] + if [ -n "${GATEWAY}" -a -n "${GATEWAY_IF}" ] then echo -e ${COLOREDSTAR}"Setting up default gateway ..." - route add default gateway $GATEWAY metric 1 \ - dev $GATEWAY_IF + route add default gateway ${GATEWAY} metric 1 \ + dev ${GATEWAY_IF} evaluate_retval fi @@ -97,37 +97,37 @@ ;; stop) - if [ "$GATEWAY" != "" ] + if [ -n "${GATEWAY}" ] then echo -e ${COLOREDSTAR}"Removing default gateway ..." route del -net default evaluate_retval fi - for file in $(grep -il "ONBOOT=\"yes\"" $network_settings/net.*) + for file in $(grep -il "ONBOOT=\"yes\"" ${network_settings}/net.*) do - interface=$(basename $file | sed s/net.//) - case "$interface" in + interface=$(basename ${file} | sed s/net.//) + case "${interface}" in *~) ;; *) #$network_devices/ifdown $interface - source $network_settings/net.${interface} || exit 1 + source ${network_settings}/net.${interface} || exit 1 checkconfig echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..." - ifconfig eth0 down + ifconfig ${interface} down evaluate_retval #shutdown dhcp-daemon - if [ $NETWORKING == dhcp ] + if [ "${NETWORKING}" == dhcp ] then my_runlevel="`runlevel | cut -d ' ' -f2`" - if [ "$my_runlevel" -ne "0" -a "$my_runlevel" -ne "6" ] + if [ -n "$(pidof ${DHCP_PROG})" ] then echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..." - $CURS_UP - $SET_WWCOL - echo "[${DHCP_PROG}]" - $DHCP_PROG $DHCP_STOP + ${CURS_UP} + ${SET_WWCOL} + echo "[$(basename ${DHCP_PROG})]" + ${DHCP_PROG} ${DHCP_STOP} evaluate_retval fi fi