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