Revert "sysctl: activate conntrack accounting."
[people/teissler/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
3a90a80c
AF
30
31 if [ -e /var/ipfire/main/disable_nf_sip ]; then
32 rmmod nf_nat_sip
33 rmmod nf_conntrack_sip
adc91020
MT
34 rmmod nf_nat_h323
35 rmmod nf_conntrack_h323
3a90a80c
AF
36 fi
37
6fc15159
MT
38 boot_mesg "Setting up firewall"
39 /etc/rc.d/init.d/firewall start; evaluate_retval
40
c130ab12
AF
41# boot_mesg "Setting up traffic accounting"
42# /etc/rc.d/helper/writeipac.pl || failed=1
43# /usr/sbin/fetchipac -S || failed=1
44# (exit ${failed})
45# evaluate_retval
6fc15159
MT
46
47 boot_mesg "Setting up DMZ pinholes"
48 /usr/local/bin/setdmzholes; evaluate_retval
49
50 if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
51 boot_mesg "Setting up wireless firewall rules"
900832fa 52 /usr/local/bin/wirelessctrl; evaluate_retval
6fc15159
MT
53 fi
54
55 /etc/rc.d/init.d/dnsmasq start
b5c30aea 56 /etc/rc.d/init.d/static-routes start
6fc15159
MT
57}
58
37263bc1
MT
59DO="${1}"
60shift
069680ac 61
37263bc1 62if [ -n "${1}" ]; then
d1e90efc
MT
63 ALL=0
64 for i in green red blue orange; do
65 eval "${i}=0"
66 done
37263bc1 67else
d1e90efc
MT
68 ALL=1
69 for i in green red blue orange; do
70 eval "${i}=1"
71 done
37263bc1 72fi
069680ac 73
37263bc1 74while [ ! $# = 0 ]; do
d1e90efc
MT
75 for i in green red blue orange; do
76 if [ "${i}" == "${1}" ]; then
77 eval "${i}=1"
78 shift
79 fi
80 done
37263bc1 81done
3fd5feeb 82
37263bc1 83case "${DO}" in
d1e90efc
MT
84 start)
85 [ "${ALL}" == "1" ] && init_networking
86
87 # Starting interfaces...
88 # GREEN
89 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
90
91 # BLUE
92 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
93 /etc/rc.d/init.d/networking/blue start
94
95 # ORANGE
96 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
97 /etc/rc.d/init.d/networking/orange start
98
99 # RED
100 if [ "$red" == "1" ]; then
101 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
102 # Remove possible leftover files
103 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
104 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
105 fi
106 fi
107 ;;
108
109 stop)
110 # Stopping interfaces...
111 # GREEN
112 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
113
114 # BLUE
115 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
116 /etc/rc.d/init.d/networking/blue stop
117
118 # ORANGE
119 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
120 /etc/rc.d/init.d/networking/orange stop
121
122 # RED
123 if [ "$red" == "1" ]; then
124 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
125 /etc/rc.d/init.d/networking/red stop
126 fi
127 fi
7be0be70
AF
128
129 # Stopping dnsmasq if network all networks shutdown
130 [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop
a4109682
AF
131
132 exit 0
d1e90efc
MT
133 ;;
134
135 restart)
136 for i in green red blue orange; do
137 if [ "${!i}" == "1" ]; then
138 ARGS+=" ${i}"
139 fi
140 done
141 ${0} stop ${ARGS}
142 sleep 1
143 ${0} start ${ARGS}
144 ;;
145
146 *)
147 echo "Usage: ${0} {start|stop|restart} [device(s)]"
148 exit 1
149 ;;
3fd5feeb
MT
150esac
151
152# End /etc/rc.d/init.d/network