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