]> git.pld-linux.org Git - projects/rc-scripts.git/blame - sysconfig/network-scripts/ifdown
compare HANDLING as string not as integer (avoid problems in bash)
[projects/rc-scripts.git] / sysconfig / network-scripts / ifdown
CommitLineData
12de71be 1#!/bin/sh
b0443108 2#
24d305ed 3# $Id: ifdown,v 1.24.2.3 2001/03/19 15:48:18 misiek Exp $
b0443108 4#
7742e157
AF
5PATH=/sbin:/usr/sbin:/bin:/usr/bin
6
a04d924e
AM
7. /etc/sysconfig/network
8. /etc/rc.d/init.d/functions
9. /etc/sysconfig/network-scripts/.functions
10
111f7a0d 11DEV=$1
7742e157 12
111f7a0d 13[ -z "$DEV" ] && {
a04d924e 14 nls "usage: %s <device name>" "ifdown" >&2
7742e157
AF
15 exit 1
16}
17
03f9cfee
JR
18if [ -f "/etc/sysconfig/interfaces/ifcfg-$DEV" ] ; then
19 CONFIG="/etc/sysconfig/interfaces/ifcfg-$DEV"
20else
21 CONFIG="$DEV"
111f7a0d
AF
22fi
23
a04d924e 24if [ "$(id -u)" != "0" ]; then
3699119a
JK
25 if [ -x /sbin/usernetctl ]; then
26 exec /sbin/usernetctl $CONFIG down
27 fi
28 echo "Users cannot control this device." >&2
29 exit 1
30fi
31
7742e157
AF
32source_config
33
a04d924e
AM
34# set all major variables
35setup_ip_param
38198f50 36
7742e157
AF
37OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}"
38
a04d924e
AM
39# shutdown tleds software
40if [ "$TLEDS_DEV" = "$DEVICE" -a -x /usr/bin/tleds ]; then
41 /usr/bin/tleds -qk "$DEVICE"
42fi
43
289d7762 44if [ -x $OTHERSCRIPT ]; then
24d305ed 45 if [ "$HANDLING" = "0" ]; then
a04d924e 46 exec $OTHERSCRIPT $CONFIG $2
24d305ed 47 elif [ "$HANDLING" = "1" ]; then
a04d924e 48 $OTHERSCRIPT $CONFIG $2
035f0806 49 fi
7742e157
AF
50fi
51
a04d924e
AM
52# Check to make sure the device is actually up
53check_device_down && exit 0
54
55if [ "$BOOTMETHOD" = "bootp" -o "$BOOTMETHOD" = "pump" ]; then
56 /sbin/pump -r -i ${DEVICE}
21e8e9bc 57 RESULT=$?
7742e157
AF
58fi
59
a04d924e
AM
60if [ "$BOOTMETHOD" = "dhcp" ]; then
61 if [ -x /sbin/dhcpcd ];then
62 /sbin/dhcpcd -k ${DEVICE}
21e8e9bc 63 RESULT=$?
a04d924e
AM
64 elif [ -x /sbin/dhclient ];then
65 if [ -f /var/run/dhclient.pid ];then
66 PID=$(cat /var/run/dhclient.pid)
67 if ps ax --no-header|grep -q $PID;then
68 kill $PID
21e8e9bc 69 RESULT=$?
a04d924e
AM
70 fi
71 fi
72 elif [ -x /sbin/dhcpxd ];then
73 /sbin/dhcpxd -k ${DEVICE}
21e8e9bc 74 RESULT=$?
a04d924e
AM
75 elif [ -x /sbin/pump ];then
76 pump -r -i ${DEVICE}
21e8e9bc 77 RESULT=$?
898eb5ff 78 fi
4ac87c24
AM
79fi
80
a04d924e
AM
81ip link set ${DEVICE} down
82ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
83
24d305ed 84if [ "$HANDLING" = "4" ]; then
a04d924e
AM
85 exit 0
86fi
7742e157 87
21e8e9bc
AM
88if [ "$RESULT" -ne "0" ]; then
89 return $RESULT
90fi
91
92exec /etc/sysconfig/network-scripts/ifdown-post $CONFIG
a04d924e
AM
93
94# This must be last line !
95# vi:syntax=sh:tw=78:ts=8:sw=4
96
This page took 0.048721 seconds and 4 git commands to generate.