]>
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 MT |
23 | ALL=0 |
24 | for i in green red blue orange; do | |
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 MT |
44 | start) |
45 | [ "${ALL}" == "1" ] && init_networking | |
46 | ||
47 | # Starting interfaces... | |
48 | # GREEN | |
49 | [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start | |
50 | ||
51 | # BLUE | |
52 | [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ | |
53 | /etc/rc.d/init.d/networking/blue start | |
54 | ||
55 | # ORANGE | |
56 | [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ | |
57 | /etc/rc.d/init.d/networking/orange start | |
58 | ||
59 | # RED | |
60 | if [ "$red" == "1" ]; then | |
61 | if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then | |
62 | # Remove possible leftover files | |
63 | rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} | |
64 | [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start | |
65 | fi | |
66 | fi | |
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 | ||
90 | restart) | |
91 | for i in green red blue orange; do | |
92 | if [ "${!i}" == "1" ]; then | |
93 | ARGS+=" ${i}" | |
94 | fi | |
95 | done | |
96 | ${0} stop ${ARGS} | |
97 | sleep 1 | |
98 | ${0} start ${ARGS} | |
99 | ;; | |
100 | ||
101 | *) | |
102 | echo "Usage: ${0} {start|stop|restart} [device(s)]" | |
103 | exit 1 | |
104 | ;; | |
3fd5feeb MT |
105 | esac |
106 | ||
d1e90efc MT |
107 | init_networking() { |
108 | ||
109 | boot_mesg "Loading firewall modules into the kernel" | |
110 | modprobe iptable_nat || failed=1 | |
111 | for i in $(find /lib/modules/$(uname -r) -name ip_conntrack*); do | |
112 | modprobe $i || failed=1 | |
113 | done | |
114 | for i in $(find /lib/modules/$(uname -r) -name ip_nat*); do | |
115 | modprobe $i || failed=1 | |
116 | done | |
117 | (exit ${failed}) | |
118 | evaluate_retval | |
119 | ||
120 | boot_mesg "Setting up firewall" | |
121 | /etc/rc.d/init.d/firewall start; evaluate_retval | |
122 | ||
123 | boot_mesg "Setting up traffic accounting" | |
124 | /etc/rc.d/helper/writeipac.pl || failed=1 | |
125 | /usr/sbin/fetchipac -S || failed=1 | |
126 | (exit ${failed}) | |
127 | evaluate_retval | |
128 | ||
129 | boot_mesg "Setting up DMZ pinholes" | |
130 | /usr/local/bin/setdmzholes; evaluate_retval | |
131 | ||
132 | if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then | |
133 | boot_mesg "Setting up wireless firewall rules" | |
134 | /usr/local/bin/restartwireless; evaluate_retval | |
135 | fi | |
136 | ||
137 | /etc/rc.d/init.d/dnsmasq start | |
138 | } | |
139 | ||
3fd5feeb | 140 | # End /etc/rc.d/init.d/network |