#!/bin/sh # # network This starts and stops network. # PATH=/sbin:/bin:/usr/bin:/usr/sbin # Source function library. . /etc/init.d/functions # Get config. [ -f "/etc/sysconfig/network" ] && . /etc/sysconfig/network CWD=`pwd` cd /etc/sysconfig/network-scripts interfaces=`ls ifcfg-*` # See how we were called. case "$1" in start) for i in $interfaces; do . ./$i ifconfig ${DEVICE} ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK} up if [ "$?" = "0" ]; then echo " bring up $DEVICE successfully" else echo " fail to bring up $DEVICE." fi done route add default gw ${GATEWAY} ;; stop) for i in $interfaces; do . ./$i ifconfig ${DEVICE} down done ;; restart) cd $CWD $0 stop $0 start ;; *) echo $"Usage: $0 {start|stop|restart}" RETVAL=1 esac exit $RETVAL