]> pd.if.org Git - startuptools/blob - scripts/ifdown
fix shell errors with IFS
[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 #if [ $enable -eq 0 ]; then exit 0; fi
22
23 ifdown_pre
24
25 #ip link set dev $dev up
26
27 for r in $route; do
28         IFS="$saveifs"
29         ip route del $r
30         IFS=';'
31 done
32
33 for address in $addr do
34         IFS="$saveifs"
35         ip addr del $address dev $dev
36         IFS=';'
37 done
38
39 # how do we determine if we should bring the link down?
40 # there could be other configurations that also set up IP
41 # addresses.  Also, what happens exactly if the primary
42 # ip address is removed, but not the secondary ones also?
43
44 # for now, just leave the link up, I don't think it hurts
45 # anything
46
47 ifdown_post