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