Fixed connection tracking bug (also in Core 27).
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / network
CommitLineData
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 17eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
bf7c473f 18
6fc15159 19init_networking() {
6fc15159
MT
20 boot_mesg "Loading firewall modules into the kernel"
21 modprobe iptable_nat || failed=1
5e0f55e7 22 for i in $(find /lib/modules/$(uname -r) -name nf_conntrack*); do
50418f38 23 modprobe $(basename $i | cut -d. -f1) || failed=1
6fc15159 24 done
5e0f55e7 25 for i in $(find /lib/modules/$(uname -r) -name nf_nat*); do
50418f38 26 modprobe $(basename $i | cut -d. -f1) || failed=1
6fc15159
MT
27 done
28 (exit ${failed})
29 evaluate_retval
30
31 boot_mesg "Setting up firewall"
32 /etc/rc.d/init.d/firewall start; evaluate_retval
33
c130ab12
AF
34# boot_mesg "Setting up traffic accounting"
35# /etc/rc.d/helper/writeipac.pl || failed=1
36# /usr/sbin/fetchipac -S || failed=1
37# (exit ${failed})
38# evaluate_retval
6fc15159
MT
39
40 boot_mesg "Setting up DMZ pinholes"
41 /usr/local/bin/setdmzholes; evaluate_retval
42
43 if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
44 boot_mesg "Setting up wireless firewall rules"
900832fa 45 /usr/local/bin/wirelessctrl; evaluate_retval
6fc15159
MT
46 fi
47
48 /etc/rc.d/init.d/dnsmasq start
49}
50
37263bc1
MT
51DO="${1}"
52shift
069680ac 53
37263bc1 54if [ -n "${1}" ]; then
d1e90efc
MT
55 ALL=0
56 for i in green red blue orange; do
57 eval "${i}=0"
58 done
37263bc1 59else
d1e90efc
MT
60 ALL=1
61 for i in green red blue orange; do
62 eval "${i}=1"
63 done
37263bc1 64fi
069680ac 65
37263bc1 66while [ ! $# = 0 ]; do
d1e90efc
MT
67 for i in green red blue orange; do
68 if [ "${i}" == "${1}" ]; then
69 eval "${i}=1"
70 shift
71 fi
72 done
37263bc1 73done
3fd5feeb 74
37263bc1 75case "${DO}" in
d1e90efc
MT
76 start)
77 [ "${ALL}" == "1" ] && init_networking
78
79 # Starting interfaces...
80 # GREEN
81 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
82
83 # BLUE
84 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
85 /etc/rc.d/init.d/networking/blue start
86
87 # ORANGE
88 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
89 /etc/rc.d/init.d/networking/orange start
90
91 # RED
92 if [ "$red" == "1" ]; then
93 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
94 # Remove possible leftover files
95 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
96 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
97 fi
98 fi
99 ;;
100
101 stop)
102 # Stopping interfaces...
103 # GREEN
104 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
105
106 # BLUE
107 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
108 /etc/rc.d/init.d/networking/blue stop
109
110 # ORANGE
111 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
112 /etc/rc.d/init.d/networking/orange stop
113
114 # RED
115 if [ "$red" == "1" ]; then
116 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
117 /etc/rc.d/init.d/networking/red stop
118 fi
119 fi
7be0be70
AF
120
121 # Stopping dnsmasq if network all networks shutdown
122 [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop
a4109682
AF
123
124 exit 0
d1e90efc
MT
125 ;;
126
127 restart)
128 for i in green red blue orange; do
129 if [ "${!i}" == "1" ]; then
130 ARGS+=" ${i}"
131 fi
132 done
133 ${0} stop ${ARGS}
134 sleep 1
135 ${0} start ${ARGS}
136 ;;
137
138 *)
139 echo "Usage: ${0} {start|stop|restart} [device(s)]"
140 exit 1
141 ;;
3fd5feeb
MT
142esac
143
144# End /etc/rc.d/init.d/network