]> pd.if.org Git - startuptools/blob - scripts/ifdown
fix empty module list handling
[startuptools] / scripts / ifdown
1 #!/bin/sh
2
3 net=$1
4
5 saveifs="$IFS"
6 IFS=';'
7
8 test -f /etc/networks/$net || (echo "unknown network configuration '$net'" >&2 && exit 1)
9  
10 ifdown_post() {
11         return 0
12 }
13
14 ifdown_pre() {
15         return 0
16 }
17
18 . /etc/networks/$net
19
20 if [ "$enable" = 'no' ]; then exit 0; fi
21
22 ifdown_pre
23
24 #ip link set dev $dev up
25
26 for r in $route; do
27         IFS="$saveifs"
28         ip route del $r
29         IFS=';'
30 done
31
32 if [ "$addr" = 'dhcp' ]; then
33         /sbin/dhcpcd -q -k $dev
34 else
35         for address in $addr; do
36                 IFS="$saveifs"
37                 ip addr del $address dev $dev
38                 IFS=';'
39         done
40 fi
41
42 # how do we determine if we should bring the link down?
43 # there could be other configurations that also set up IP
44 # addresses.  Also, what happens exactly if the primary
45 # ip address is removed, but not the secondary ones also?
46
47 # for now, just leave the link up, I don't think it hurts
48 # anything
49
50 ifdown_post