]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/init.d/network
Merge remote-tracking branch 'mfischer/newt' into next
[ipfire-2.x.git] / src / initscripts / init.d / network
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/network
4 #
5 # Description : Network Control Script
6 #
7 # Authors : Michael Tremer - mitch@ipfire.org
8 #
9 # Version : 01.00
10 #
11 # Notes : Written for IPFire by its team
12 #
13 ########################################################################
14
15 . /etc/sysconfig/rc
16 . ${rc_functions}
17 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
18
19 init_networking() {
20 /etc/rc.d/init.d/dnsmasq start
21 }
22
23 DO="${1}"
24 shift
25
26 if [ -n "${1}" ]; then
27 ALL=0
28 for i in green red blue orange; do
29 eval "${i}=0"
30 done
31 else
32 ALL=1
33 for i in green red blue orange; do
34 eval "${i}=1"
35 done
36 fi
37
38 while [ ! $# = 0 ]; do
39 for i in green red blue orange; do
40 if [ "${i}" == "${1}" ]; then
41 eval "${i}=1"
42 shift
43 fi
44 done
45 done
46
47 case "${DO}" in
48 start)
49 [ "${ALL}" == "1" ] && init_networking
50
51 # Starting interfaces...
52 # GREEN
53 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
54
55 # BLUE
56 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
57 /etc/rc.d/init.d/networking/blue start
58
59 # ORANGE
60 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
61 /etc/rc.d/init.d/networking/orange start
62
63 # RED
64 if [ "$red" == "1" ]; then
65 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
66 # Remove possible leftover files
67 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
68 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
69 fi
70 fi
71
72 /etc/rc.d/init.d/static-routes start
73 ;;
74
75 stop)
76 # Stopping interfaces...
77 # GREEN
78 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
79
80 # BLUE
81 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
82 /etc/rc.d/init.d/networking/blue stop
83
84 # ORANGE
85 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
86 /etc/rc.d/init.d/networking/orange stop
87
88 # RED
89 if [ "$red" == "1" ]; then
90 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
91 /etc/rc.d/init.d/networking/red stop
92 fi
93 fi
94
95 # Stopping dnsmasq if network all networks shutdown
96 [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop
97
98 exit 0
99 ;;
100
101 restart)
102 for i in green red blue orange; do
103 if [ "${!i}" == "1" ]; then
104 ARGS+=" ${i}"
105 fi
106 done
107 ${0} stop ${ARGS}
108 sleep 1
109 ${0} start ${ARGS}
110 ;;
111
112 *)
113 echo "Usage: ${0} {start|stop|restart} [device(s)]"
114 exit 1
115 ;;
116 esac
117
118 # End /etc/rc.d/init.d/network