#!/bin/bash #%rlevels: 0:k 1:k 2:k 3:s 4:s 5:s 6:k #%start: 20 #%stop: 80 #deps #%needs: #%before: #%after: source /etc/sysconfig/rc source $rc_functions checkconfig() { if [ -z $NETWORKING ] then echo "NETWORKING missing in net.${interface}, aborted" exit 1 fi case $NETWORKING in static) if [ -z $IP ] then echo "IP missing in net.${interface}, aborted" exit 1 fi 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 ] then echo -n "BROADCAST missing in net.${interface}, " echo "using default address" fi ;; dhcp) 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.*) do interface=$(basename $file | sed s/net.//) case "$interface" in *~) ;; *) #$network_devices/ifup $interface source $network_settings/net.${interface} || exit 1 checkconfig case $NETWORKING in dhcp) echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..." $CURS_UP $SET_WWCOL echo "[DHCP]" #modprobe $interface loadproc $DHCP_PROG $DHCP_START ;; static) echo -e ${COLOREDSTAR}"Bringing up interface ${COLBLUE}${interface}${COLDEFAULT} ..." $CURS_UP $SET_WWCOL echo "[STATIC]" ifconfig $interface $IP netmask $NETMASK broadcast $BROADCAST evaluate_retval ;; esac ;; esac done if [ "$GATEWAY" != "" ] then echo -e ${COLOREDSTAR}"Setting up default gateway ..." route add default gateway $GATEWAY metric 1 \ dev $GATEWAY_IF evaluate_retval fi update_svcstatus $1 splash svc_started "$(basename $0)" 0 ;; stop) if [ "$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.*) do interface=$(basename $file | sed s/net.//) case "$interface" in *~) ;; *) #$network_devices/ifdown $interface source $network_settings/net.${interface} || exit 1 checkconfig echo -e ${COLOREDSTAR}"Bringing down interface ${COLBLUE}${interface}${COLDEFAULT} ..." ifconfig eth0 down evaluate_retval #shutdown dhcp-daemon if [ $NETWORKING == dhcp ] then my_runlevel="`runlevel | cut -d ' ' -f2`" if [ "$my_runlevel" -ne "0" -a "$my_runlevel" -ne "6" ] then echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..." $CURS_UP $SET_WWCOL echo "[${DHCP_PROG}]" $DHCP_PROG $DHCP_STOP evaluate_retval fi fi ;; esac done update_svcstatus $1 splash svc_stopped "$(basename $0)" 0 ;; restart) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac