]>
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 | |
37263bc1 MT |
19 | DO="${1}" |
20 | shift | |
069680ac | 21 | |
37263bc1 | 22 | if [ -n "${1}" ]; then |
d1e90efc | 23 | ALL=0 |
d51e4906 | 24 | for i in green red blue orange; do |
d1e90efc MT |
25 | eval "${i}=0" |
26 | done | |
37263bc1 | 27 | else |
d1e90efc MT |
28 | ALL=1 |
29 | for i in green red blue orange; do | |
30 | eval "${i}=1" | |
31 | done | |
37263bc1 | 32 | fi |
069680ac | 33 | |
37263bc1 | 34 | while [ ! $# = 0 ]; do |
d1e90efc MT |
35 | for i in green red blue orange; do |
36 | if [ "${i}" == "${1}" ]; then | |
37 | eval "${i}=1" | |
38 | shift | |
39 | fi | |
40 | done | |
37263bc1 | 41 | done |
3fd5feeb | 42 | |
37263bc1 | 43 | case "${DO}" in |
d1e90efc | 44 | start) |
d1e90efc MT |
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 | |
d51e4906 | 64 | fi |
1d4897f3 | 65 | |
68e69b67 MT |
66 | # Create IPsec interfaces |
67 | /usr/local/bin/ipsec-interfaces | |
68 | ||
1d4897f3 | 69 | /etc/rc.d/init.d/static-routes start |
d1e90efc MT |
70 | ;; |
71 | ||
72 | stop) | |
73 | # Stopping interfaces... | |
74 | # GREEN | |
75 | [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop | |
76 | ||
77 | # BLUE | |
78 | [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ | |
79 | /etc/rc.d/init.d/networking/blue stop | |
80 | ||
81 | # ORANGE | |
82 | [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ | |
83 | /etc/rc.d/init.d/networking/orange stop | |
84 | ||
85 | # RED | |
86 | if [ "$red" == "1" ]; then | |
87 | if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then | |
88 | /etc/rc.d/init.d/networking/red stop | |
89 | fi | |
90 | fi | |
7be0be70 | 91 | |
a4109682 | 92 | exit 0 |
d1e90efc MT |
93 | ;; |
94 | ||
95 | restart) | |
96 | for i in green red blue orange; do | |
97 | if [ "${!i}" == "1" ]; then | |
98 | ARGS+=" ${i}" | |
99 | fi | |
100 | done | |
101 | ${0} stop ${ARGS} | |
102 | sleep 1 | |
103 | ${0} start ${ARGS} | |
104 | ;; | |
105 | ||
106 | *) | |
107 | echo "Usage: ${0} {start|stop|restart} [device(s)]" | |
108 | exit 1 | |
109 | ;; | |
3fd5feeb MT |
110 | esac |
111 | ||
112 | # End /etc/rc.d/init.d/network |