SourceForge.net Logo

B.28. /etc/sysconfig/network/ifdown

#!/bin/ash
# 
# GPL $Id: ifdown,v 1.1.1.1 2005/02/28 18:22:49 cvonk Exp $
# system network script bring down a network interface

error_exit() {
    echo "ifdown: error: $@" >&2; exit 1
}

DEV=$1
if [ ! -f /etc/sysconfig/network/$DEV.conf ] ; then
    error_exit "missing dev config" >&2
fi
. /etc/sysconfig/network/$DEV.conf

case "$BOOTPROTO" in
    dhcp)
	if ! killall udhcpc ; then
	    error_exit "failed to kill udhcpc on $DEV"
	fi
	;;
    pppoe)
	if /usr/sbin/adsl-stop /etc/sysconfig/network/$DEV.conf ; then
	    error_exit "failed to stop PPPoE"
	fi
	;;
    *|static)
	if [ $DEV = eth1 ] ; then
	    ip route delete
	fi
	if ! ip address delete $IPADDR/$NETMASKBITS brd + dev $DEV ; then
	    error_exit "failed to remove $IPADDR/$NETMASKBITS on $DEV."
	fi
	;;
esac


# if ! ip link set down dev $DEV ; then
#     error_exit "cannot disable interface $dev."
# fi
# 

Example B.28. /etc/sysconfig/network/ifdown