#!/bin/bash # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/network,v 1.3 2005-03-15 19:07:56 niro Exp $ #%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 *~) ;; *) 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]" 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 [ -n "${GATEWAY}" -a -n "${GATEWAY_IF}" ] 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 [ -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.*) 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 ${interface} down evaluate_retval #shutdown dhcp-daemon if [ "${NETWORKING}" == dhcp ] then my_runlevel="`runlevel | cut -d ' ' -f2`" if [ -n "$(pidof ${DHCP_PROG})" ] then echo -e ${COLOREDSTAR}"Stopping the dhcp-daemon ..." ${CURS_UP} ${SET_WWCOL} echo "[$(basename ${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