#!/bin/sh # # network Bring up/down networking # # chkconfig: 2345 10 90 # description: Activates/Deactivates all network interfaces configured to \ # start at boot time. # probe: true # Source function library. . /etc/rc.d/init.d/functions . /etc/rc.d/init.d/functions.network [ ! -f /etc/sysconfig/network ] && exit 0 . /etc/sysconfig/network # Check that networking is up. [ "${NETWORKING}" == "no" -o "${NETWORKING}" == "" ] && exit 0 [ -x /sbin/ifconfig ] || exit 0 ###### # initialize networking: # - check IPv4, IPv6, IPX can be handled by system # - setup default IPv{4,6} interfaces policy like: # - forwarding, # - spoofig protection, # - icmp echo ignore broadcasts, # - setup lo interface network_init() { [ -f /etc/sysconfig/interfaces/ifcfg-lo ] && /sbin/ifup lo boot } ###### # deinitialize networking # - down lo interface. network_deinit() { [ -f /etc/sysconfig/interfaces/ifcfg-lo ] && /sbin/ifdown lo boot } interfaces="`cd /etc/sysconfig/interfaces && ls -1 ifcfg-* | grep -v ifcfg-lo | xargs 2> /dev/null`" tunnels="`cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | xargs 2> /dev/null`" # See how we were called. case "$1" in start) network_init for i in $tunnels do [ -f /etc/sysconfig/interfaces/$i ] && /sbin/tnlup $i boot done for i in $interfaces; do [ -f $i ] && /sbin/ifup $i boot done touch /var/lock/subsys/network ;; stop) for i in $interfaces; do [ -f $i ] && /sbin/ifdown $i boot done for i in $tunnels do [ -f /etc/sysconfig/interfaces/$i ] && /sbin/tnldown $i boot done network_deinit rm -f /var/lock/subsys/network ;; status) echo "Configured devices:" echo lo $interfaces echo "Currently active devices:" echo `/sbin/ifconfig | grep ^[a-z] | awk '{print $1}'` ;; restart) $0 stop $0 start ;; *) echo "Usage: network {start|stop|restart|status}" exit 1 esac exit 0