]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/net/ifdown
OpenSwan-Build-Fix.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / net / ifdown
1 #!/bin/sh
2 ########################################################################
3 # Begin $network_devices/ifdown
4 #
5 # Description : Interface Down
6 #
7 # Authors : Nathan Coulson - nathan@linuxfromscratch.org
8 # Kevin P. Fleming - kpfleming@linuxfromscratch.org
9 # Michael Tremer - mitch@ipfire.org
10 #
11 # Version : 01.00
12 #
13 # Notes :
14 #
15 ########################################################################
16
17 . /etc/sysconfig/rc
18 . ${rc_functions}
19 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
20
21 if [ "$name" == "green" ]; then
22 DEVICE="${GREEN_DEV}"
23 elif [ "$name" == "blue" ]; then
24 DEVICE="${BLUE_DEV}"
25 elif [ "$name" == "orange" ]; then
26 DEVICE="${ORANGE_DEV}"
27 elif [ "$name" == "red" ]; then
28 DEVICE="${RED_DEV}"
29 fi
30
31 if ip link show ${DEVICE} > /dev/null 2>&1
32 then
33 if [ "$name" == "green" ]; then
34 NAME=${name} ADDRESS=${GREEN_ADDRESS} NETMASK=${GREEN_NETMASK}\
35 NETADDRESS=${GREEN_NETADDRESS} BROADCAST=${GREEN_BROADCAST} \
36 /etc/rc.d/init.d/net/common/ipv4-static ${GREEN_DEV} down
37
38 elif [ "$name" == "blue" ]; then
39 NAME=${name} ADDRESS=${BLUE_ADDRESS} NETMASK=${BLUE_NETMASK}\
40 NETADDRESS=${BLUE_NETADDRESS} BROADCAST=${BLUE_BROADCAST} \
41 /etc/rc.d/init.d/net/common/ipv4-static ${BLUE_DEV} down
42
43 elif [ "$name" == "orange" ]; then
44 NAME=${name} ADDRESS=${ORANGE_ADDRESS} NETMASK=${ORANGE_NETMASK}\
45 NETADDRESS=${ORANGE_NETADDRESS} BROADCAST=${ORANGE_BROADCAST} \
46 /etc/rc.d/init.d/net/common/ipv4-static ${ORANGE_DEV} down
47
48 elif [ "$name" == "red" ]; then
49 if [ "${RED_TYPE}" == "PPPOE" ]; then
50 NAME=${name} /etc/rc.d/init.d/net/red/pppoe ${RED_DEV} down
51 elif [ "${RED_TYPE}" == "PPTP" ]; then
52 echo
53 elif [ "${RED_TYPE}" == "DHCP" ]; then
54 NAME=${name} DHCP_HOSTNAME=${RED_DHCP_HOSTNAME} \
55 PRINTIP=yes PRINTALL=yes \
56 /etc/rc.d/init.d/net/common/dhcpcd ${RED_DEV} down
57 elif [ "${RED_TYPE}" == "STATIC" ]; then
58 NAME=${name} ADDRESS=${RED_ADDRESS} NETMASK=${RED_NETMASK}\
59 NETADDRESS=${RED_NETADDRESS} BROADCAST=${RED_BROADCAST} \
60 DNS1=${DNS1} DNS2=${DNS2} GATEWAY=${DEFAULT_GATEWAY} \
61 /etc/rc.d/init.d/net/common/ipv4-static ${RED_DEV} down
62 fi
63
64 ### Cleanup the system when red goes down ###
65 /usr/local/bin/dialctrl.pl down
66 rm -f /var/ipfire/red/{active,iface,*-ipaddress,dns*}
67
68 fi
69 else
70 boot_mesg "Interface ${DEVICE} doesn't exist." ${WARNING}
71 echo_warning
72 fi
73
74 link_status=`ip link show $DEVICE 2> /dev/null`
75 if [ -n "${link_status}" ]; then
76 if echo "${link_status}" | grep -q UP; then
77 boot_mesg "Bringing down the ${DEVICE} interface..."
78 ip link set ${DEVICE} down
79 evaluate_retval
80 fi
81 fi
82
83 # End $network_devices/ifdown