]>
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 | 20 | /etc/rc.d/init.d/dnsmasq start |
b5c30aea | 21 | /etc/rc.d/init.d/static-routes start |
6fc15159 MT |
22 | } |
23 | ||
37263bc1 MT |
24 | DO="${1}" |
25 | shift | |
069680ac | 26 | |
37263bc1 | 27 | if [ -n "${1}" ]; then |
d1e90efc MT |
28 | ALL=0 |
29 | for i in green red blue orange; do | |
30 | eval "${i}=0" | |
31 | done | |
37263bc1 | 32 | else |
d1e90efc MT |
33 | ALL=1 |
34 | for i in green red blue orange; do | |
35 | eval "${i}=1" | |
36 | done | |
37263bc1 | 37 | fi |
069680ac | 38 | |
37263bc1 | 39 | while [ ! $# = 0 ]; do |
d1e90efc MT |
40 | for i in green red blue orange; do |
41 | if [ "${i}" == "${1}" ]; then | |
42 | eval "${i}=1" | |
43 | shift | |
44 | fi | |
45 | done | |
37263bc1 | 46 | done |
3fd5feeb | 47 | |
37263bc1 | 48 | case "${DO}" in |
d1e90efc MT |
49 | start) |
50 | [ "${ALL}" == "1" ] && init_networking | |
51 | ||
52 | # Starting interfaces... | |
53 | # GREEN | |
54 | [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start | |
55 | ||
56 | # BLUE | |
57 | [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ | |
58 | /etc/rc.d/init.d/networking/blue start | |
59 | ||
60 | # ORANGE | |
61 | [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ | |
62 | /etc/rc.d/init.d/networking/orange start | |
63 | ||
64 | # RED | |
65 | if [ "$red" == "1" ]; then | |
66 | if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then | |
67 | # Remove possible leftover files | |
68 | rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} | |
69 | [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start | |
70 | fi | |
71 | fi | |
72 | ;; | |
73 | ||
74 | stop) | |
75 | # Stopping interfaces... | |
76 | # GREEN | |
77 | [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop | |
78 | ||
79 | # BLUE | |
80 | [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ | |
81 | /etc/rc.d/init.d/networking/blue stop | |
82 | ||
83 | # ORANGE | |
84 | [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ | |
85 | /etc/rc.d/init.d/networking/orange stop | |
86 | ||
87 | # RED | |
88 | if [ "$red" == "1" ]; then | |
89 | if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then | |
90 | /etc/rc.d/init.d/networking/red stop | |
91 | fi | |
92 | fi | |
7be0be70 AF |
93 | |
94 | # Stopping dnsmasq if network all networks shutdown | |
95 | [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop | |
a4109682 AF |
96 | |
97 | exit 0 | |
d1e90efc MT |
98 | ;; |
99 | ||
100 | restart) | |
101 | for i in green red blue orange; do | |
102 | if [ "${!i}" == "1" ]; then | |
103 | ARGS+=" ${i}" | |
104 | fi | |
105 | done | |
106 | ${0} stop ${ARGS} | |
107 | sleep 1 | |
108 | ${0} start ${ARGS} | |
109 | ;; | |
110 | ||
111 | *) | |
112 | echo "Usage: ${0} {start|stop|restart} [device(s)]" | |
113 | exit 1 | |
114 | ;; | |
3fd5feeb MT |
115 | esac |
116 | ||
117 | # End /etc/rc.d/init.d/network |