#!/bin/sh # # description: Activates/Deactivates all network interfaces configured to # start at boot time. # # Modified by Hugo Villeneuve # # Source functions library source /etc/rc.d/init.d/functions log_script_name "$0 $*" # Load global network parameters source /etc/sysconfig/network/network-parameters # Check that the ip program is present and executable. if [ ! -x /sbin/ip ]; then msg_log "*** ERROR: /sbin/ip not found." exit ${EXIT_CODE_FAILURE} fi CWD=`pwd` cd /etc/sysconfig/network # See how we were called. case "$1" in start) for i in ${INTERFACES_UP}; do if LANG=C egrep -L "^ONBOOT=\"?[Yy][Ee][Ss]\"?" ifconfig.$i >/dev/null 2>&1 ; then cmd_run_log_box_warn "Ethernet Adapter <$i> init" /etc/rc.d/init.d/ifup "$i" fi done ;; stop) for i in ${INTERFACES_DN} ; do if LC_ALL= LANG= ip link show dev $i 2> /dev/null | grep -q "UP" >/dev/null 2>&1 ; then cmd_run_log_box_warn "Ethernet Adapter <$i> stop" /etc/rc.d/init.d/ifdown "$i" fi done ;; restart) cd $CWD $0 stop $0 start ;; status) echo "Active devices:" /sbin/ip -oneline addr show up | grep inet \ | sed 's/\(^.*\): \([a-zA-Z0-9]*\) *inet \([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/ \2 (\3)/' ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit ${EXIT_CODE_FAILURE} esac exit $?