]>
Commit | Line | Data |
---|---|---|
12de71be | 1 | #!/bin/sh |
b0443108 | 2 | # |
b0443108 | 3 | # |
7742e157 AF |
4 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
5 | ||
f5446505 MM |
6 | run_pre_down() { :; } |
7 | ||
fa8aca70 JR |
8 | . /etc/sysconfig/network |
9 | . /etc/rc.d/init.d/functions | |
f67ce454 | 10 | . /lib/rc-scripts/functions.network |
fa8aca70 JR |
11 | |
12 | # Will be removed in the future | |
13 | if is_yes "$NETWORKING" ; then | |
5e6dfc29 JR |
14 | if [ -z "$IPV4_NETWORKING" ] ; then |
15 | echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!" | |
16 | echo "Please upgrade your config" | |
17 | echo "Assuming you want IPv4 networking" | |
18 | IPV4_NETWORKING=yes | |
19 | fi | |
fa8aca70 JR |
20 | fi |
21 | ||
111f7a0d | 22 | DEV=$1 |
7742e157 | 23 | |
111f7a0d | 24 | [ -z "$DEV" ] && { |
5e6dfc29 JR |
25 | nls "Usage: %s <device name>" "ifdown" >&2 |
26 | exit 1 | |
7742e157 AF |
27 | } |
28 | ||
03f9cfee | 29 | if [ -f "/etc/sysconfig/interfaces/ifcfg-$DEV" ] ; then |
5e6dfc29 | 30 | CONFIG="/etc/sysconfig/interfaces/ifcfg-$DEV" |
03f9cfee | 31 | else |
5e6dfc29 | 32 | CONFIG="$DEV" |
111f7a0d AF |
33 | fi |
34 | ||
fa8aca70 | 35 | if [ "$(id -u)" != "0" ]; then |
5e6dfc29 JR |
36 | if [ -x /sbin/usernetctl ]; then |
37 | exec /sbin/usernetctl $CONFIG down | |
38 | fi | |
39 | echo "Users cannot control this device." >&2 | |
40 | exit 1 | |
3699119a JK |
41 | fi |
42 | ||
7742e157 AF |
43 | source_config |
44 | ||
fa8aca70 JR |
45 | # set all major variables |
46 | setup_ip_param | |
1c4ce04c | 47 | |
f5446505 MM |
48 | # anything you need done first |
49 | run_pre_down | |
50 | ||
f67ce454 | 51 | OTHERSCRIPT="/lib/rc-scripts/ifdown-${DEVICETYPE}" |
fa8aca70 JR |
52 | |
53 | # shutdown tleds software | |
54 | if [ "$TLEDS_DEV" = "$DEVICE" -a -x /usr/bin/tleds ]; then | |
5e6dfc29 | 55 | /usr/bin/tleds -qk "$DEVICE" |
fa8aca70 | 56 | fi |
74a7f2e4 | 57 | |
fa8aca70 | 58 | if [ -x $OTHERSCRIPT ]; then |
5e6dfc29 JR |
59 | if [ "$HANDLING" = "0" ]; then |
60 | exec $OTHERSCRIPT $CONFIG $2 | |
61 | elif [ "$HANDLING" = "1" ]; then | |
62 | $OTHERSCRIPT $CONFIG $2 | |
63 | fi | |
4ac87c24 AM |
64 | fi |
65 | ||
8772739e | 66 | if is_yes "$ENABLE_6TO4"; then |
67 | tun6to4=tun6to4_$DEVICE | |
68 | /sbin/ip -6 route flush dev $tun6to4 2>/dev/null | |
69 | if [ $? = 0 ]; then # the tunnel has been set up in ifup | |
70 | /sbin/ip link set dev $tun6to4 down | |
71 | /sbin/ip tunnel del $tun6to4 | |
72 | fi | |
73 | fi | |
74 | ||
f1dba8bc ER |
75 | if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" -a "$BOOTPROTO" != "static" ]; then |
76 | if is_yes "$IPV4_NETWORKING"; then | |
77 | set_dhcpclient | |
78 | ||
79 | case ${DHCP_CLIENT##*/} in | |
80 | pump) | |
72ecb335 | 81 | $DHCP_CLIENT -r -i ${DEVICE} |
f1dba8bc ER |
82 | RESULT=$? |
83 | ;; | |
84 | dhcpcd) | |
72ecb335 | 85 | $DHCP_CLIENT -k ${DEVICE} |
f1dba8bc | 86 | RESULT=$? |
3c2730dd | 87 | sleep 1 |
f1dba8bc ER |
88 | ;; |
89 | dhcpxd) | |
72ecb335 | 90 | $DHCP_CLIENT -k ${DEVICE} |
f1dba8bc ER |
91 | RESULT=$? |
92 | ;; | |
93 | dhclient) | |
1eb7d29d JK |
94 | if [ -f "/var/run/dhclient.$DEVICE.pid" ] ; then |
95 | $DHCP_CLIENT -r -pf /var/run/dhclient.$DEVICE.pid -lf /var/lib/dhclient/dhclient.$DEVICE.leases 2>/dev/null | |
96 | RESULT=$? | |
97 | elif [ -f /var/run/dhclient.pid ]; then | |
98 | # may be left by older rc-scripts | |
f1dba8bc | 99 | PID=$(cat /var/run/dhclient.pid) |
d880b35f | 100 | if kill -0 $PID 2>/dev/null; then |
f1dba8bc ER |
101 | kill $PID |
102 | RESULT=$? | |
103 | fi | |
5e6dfc29 | 104 | fi |
f1dba8bc | 105 | ;; |
f3df266c JK |
106 | avahi-autoipd) |
107 | $DHCP_CLIENT -k ${DEVICE} | |
108 | RESULT=$? | |
109 | ;; | |
f1dba8bc | 110 | esac |
5e6dfc29 | 111 | fi |
7742e157 AF |
112 | fi |
113 | ||
43ed6f13 | 114 | if is_yes "${WLAN_WPA}"; then |
115 | killproc --pidfile "wpa_supplicant-${DEVICE}.pid" wpa_supplicant > /dev/null 2>&1 | |
116 | rm -f "/var/run/wpa_supplicant-${DEVICE}.pid" | |
49ee1da7 | 117 | fi |
5e6dfc29 | 118 | |
08ece317 AM |
119 | # Check to make sure the device is actually up |
120 | check_device_down && exit 0 | |
121 | ||
53a5f488 AM |
122 | if [ -n "${SUBDEVICE}" ]; then |
123 | ip addr del ${IP4ADDR} label ${SUBDEVICE} dev ${DEVICE} | |
5e6dfc29 | 124 | else |
2450b5fc | 125 | LC_ALL=C ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush" |
d066e443 | 126 | |
8eae0d9c MM |
127 | if is_yes "$SLAVE"; then |
128 | ip link set ${DEVICE} nomaster | |
129 | fi | |
53a5f488 AM |
130 | |
131 | ip link set ${DEVICE} down | |
5e6dfc29 | 132 | fi |
7742e157 | 133 | |
fa8aca70 | 134 | if [ "$HANDLING" = "4" ]; then |
5e6dfc29 | 135 | exit 0 |
4ac87c24 AM |
136 | fi |
137 | ||
5969ebf1 | 138 | if [ -n "$RESULT" ] ; then |
5e6dfc29 | 139 | if [ "$RESULT" -ne "0" ]; then |
64195bf4 | 140 | exit $RESULT |
5e6dfc29 | 141 | fi |
1c4ce04c | 142 | fi |
7742e157 | 143 | |
f67ce454 | 144 | exec /lib/rc-scripts/ifdown-post $CONFIG |