]>
Commit | Line | Data |
---|---|---|
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 | /etc/rc.d/init.d/static-routes start | |
22 | } | |
23 | ||
24 | DO="${1}" | |
25 | shift | |
26 | ||
27 | if [ -n "${1}" ]; then | |
28 | ALL=0 | |
29 | for i in green red blue orange; do | |
30 | eval "${i}=0" | |
31 | done | |
32 | else | |
33 | ALL=1 | |
34 | for i in green red blue orange; do | |
35 | eval "${i}=1" | |
36 | done | |
37 | fi | |
38 | ||
39 | while [ ! $# = 0 ]; do | |
40 | for i in green red blue orange; do | |
41 | if [ "${i}" == "${1}" ]; then | |
42 | eval "${i}=1" | |
43 | shift | |
44 | fi | |
45 | done | |
46 | done | |
47 | ||
48 | case "${DO}" in | |
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 | |
93 | ||
94 | # Stopping dnsmasq if network all networks shutdown | |
95 | [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop | |
96 | ||
97 | exit 0 | |
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 | ;; | |
115 | esac | |
116 | ||
117 | # End /etc/rc.d/init.d/network |