]>
Commit | Line | Data |
---|---|---|
3fd5feeb MT |
1 | #!/bin/sh |
2 | ######################################################################## | |
3 | # Begin $rc_base/init.d/network | |
4 | # | |
5 | # Description : Network Control Script | |
6 | # | |
d1e90efc | 7 | # Authors : Michael Tremer - mitch@ipfire.org |
3fd5feeb | 8 | # |
9c16cd92 | 9 | # Version : 01.00 |
3fd5feeb MT |
10 | # |
11 | # Notes : Written for IPFire by its team | |
12 | # | |
13 | ######################################################################## | |
14 | ||
15 | . /etc/sysconfig/rc | |
16 | . ${rc_functions} | |
bf7c473f | 17 | eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) |
bf7c473f | 18 | |
6fc15159 | 19 | init_networking() { |
6fc15159 MT |
20 | /etc/rc.d/init.d/dnsmasq start |
21 | } | |
22 | ||
37263bc1 MT |
23 | DO="${1}" |
24 | shift | |
069680ac | 25 | |
37263bc1 | 26 | if [ -n "${1}" ]; then |
d1e90efc | 27 | ALL=0 |
d51e4906 | 28 | for i in green red blue orange; do |
d1e90efc MT |
29 | eval "${i}=0" |
30 | done | |
37263bc1 | 31 | else |
d1e90efc MT |
32 | ALL=1 |
33 | for i in green red blue orange; do | |
34 | eval "${i}=1" | |
35 | done | |
37263bc1 | 36 | fi |
069680ac | 37 | |
37263bc1 | 38 | while [ ! $# = 0 ]; do |
d1e90efc MT |
39 | for i in green red blue orange; do |
40 | if [ "${i}" == "${1}" ]; then | |
41 | eval "${i}=1" | |
42 | shift | |
43 | fi | |
44 | done | |
37263bc1 | 45 | done |
3fd5feeb | 46 | |
37263bc1 | 47 | case "${DO}" in |
d1e90efc MT |
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 | |
d51e4906 | 70 | fi |
1d4897f3 TE |
71 | |
72 | /etc/rc.d/init.d/static-routes start | |
d1e90efc MT |
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 | |
7be0be70 AF |
94 | |
95 | # Stopping dnsmasq if network all networks shutdown | |
96 | [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop | |
a4109682 AF |
97 | |
98 | exit 0 | |
d1e90efc MT |
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 | ;; | |
3fd5feeb MT |
116 | esac |
117 | ||
118 | # End /etc/rc.d/init.d/network |