3 # $Id: ifdown,v 1.34 2002/05/11 09:50:53 misiek Exp $
5 PATH=/sbin:/usr/sbin:/bin:/usr/bin
7 . /etc/sysconfig/network
8 . /etc/rc.d/init.d/functions
9 . /etc/sysconfig/network-scripts/functions.network
11 # Will be removed in the future
12 if is_yes "$NETWORKING" ; then
13 if [ -z "$IPV4_NETWORKING" ] ; then
14 echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
15 echo "Please upgrade your config"
16 echo "Assuming you want IPv4 networking"
24 nls "Usage: %s <device name>" "ifdown" >&2
28 if [ -f "/etc/sysconfig/interfaces/ifcfg-$DEV" ] ; then
29 CONFIG="/etc/sysconfig/interfaces/ifcfg-$DEV"
34 if [ "$(id -u)" != "0" ]; then
35 if [ -x /sbin/usernetctl ]; then
36 exec /sbin/usernetctl $CONFIG down
38 echo "Users cannot control this device." >&2
44 # set all major variables
47 OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}"
49 # shutdown tleds software
50 if [ "$TLEDS_DEV" = "$DEVICE" -a -x /usr/bin/tleds ]; then
51 /usr/bin/tleds -qk "$DEVICE"
54 if [ -x $OTHERSCRIPT ]; then
55 if [ "$HANDLING" = "0" ]; then
56 exec $OTHERSCRIPT $CONFIG $2
57 elif [ "$HANDLING" = "1" ]; then
58 $OTHERSCRIPT $CONFIG $2
62 # Check to make sure the device is actually up
63 check_device_down && exit 0
65 if [ "$BOOTPROTO" = "bootp" -o "$BOOTPROTO" = "pump" ]; then
66 /sbin/pump -r -i ${DEVICE}
70 if [ "$BOOTPROTO" = "dhcp" ]; then
71 if [ -x /sbin/dhcpcd ];then
72 /sbin/dhcpcd -k ${DEVICE}
74 elif [ -x /sbin/dhclient ];then
75 if [ -f /var/run/dhclient.pid ];then
76 PID=$(cat /var/run/dhclient.pid)
77 if ps ax --no-header|grep -q $PID;then
82 elif [ -x /sbin/dhcpxd ];then
83 /sbin/dhcpxd -k ${DEVICE}
85 elif [ -x /sbin/pump ];then
92 if is_yes $ETH_VLANS && `echo $DEVICE | grep -q ^eth` ; then
93 if echo "${DEVICE}" | grep -q '\.' ; then
95 ip link set ${DEVICE} down
96 ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
97 /sbin/vconfig rem ${DEVICE} 2>&1 > /dev/null
99 # downujemy interfejs nadrzedny do vlanow
100 for VLANDEVICE in `ls /proc/net/vlan | grep ^${DEVICE}` ; do
101 # najpierw wszystkie vlany po kolei
102 ip link set ${VLANDEVICE} down
103 ip addr flush dev ${VLANDEVICE} 2>&1 | grep -v "Nothing to flush"
104 /sbin/vconfig rem ${VLANDEVICE} 2>&1 > /dev/null
106 # a potem dopiero interfejs nadrzedny
107 ip link set ${DEVICE} down
108 ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
111 ip link set ${DEVICE} down
112 ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
115 if [ "$HANDLING" = "4" ]; then
119 if [ -n "$RESULT" ] ; then
120 if [ "$RESULT" -ne "0" ]; then
125 exec /etc/sysconfig/network-scripts/ifdown-post $CONFIG
127 # This must be last line !
128 # vi:syntax=sh:tw=78:ts=8:sw=4