]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/network
02df4bc975701bd3fcfa8e92add15fa53f63f007
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / network
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/network
4 #
5 # Description : Network Control Script
6 #
7 # Authors : Michael Tremer - mitch@ipfire.org
8 #
9 # Version : 01.00
10 #
11 # Notes : Written for IPFire by its team
12 #
13 ########################################################################
14
15 . /etc/sysconfig/rc
16 . ${rc_functions}
17 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
18
19 init_networking() {
20 boot_mesg "Loading firewall modules into the kernel"
21 modprobe iptable_nat || failed=1
22 for i in $(find /lib/modules/$(uname -r) -name nf_conntrack*); do
23 modprobe $(basename $i | cut -d. -f1) || failed=1
24 done
25 for i in $(find /lib/modules/$(uname -r) -name nf_nat*); do
26 modprobe $(basename $i | cut -d. -f1) || failed=1
27 done
28 (exit ${failed})
29 evaluate_retval
30
31 # Enable netfilter accounting
32 sysctl net.netfilter.nf_conntrack_acct=1 > /dev/null
33
34 if [ -e /var/ipfire/main/disable_nf_sip ]; then
35 rmmod nf_nat_sip
36 rmmod nf_conntrack_sip
37 rmmod nf_nat_h323
38 rmmod nf_conntrack_h323
39 fi
40
41 boot_mesg "Setting up firewall"
42 /etc/rc.d/init.d/firewall start; evaluate_retval
43
44 # boot_mesg "Setting up traffic accounting"
45 # /etc/rc.d/helper/writeipac.pl || failed=1
46 # /usr/sbin/fetchipac -S || failed=1
47 # (exit ${failed})
48 # evaluate_retval
49
50
51 if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
52 boot_mesg "Setting up wireless firewall rules"
53 /usr/local/bin/wirelessctrl; evaluate_retval
54 fi
55
56 /etc/rc.d/init.d/dnsmasq start
57 /etc/rc.d/init.d/static-routes start
58 }
59
60 DO="${1}"
61 shift
62
63 if [ -n "${1}" ]; then
64 ALL=0
65 for i in green red blue orange; do
66 eval "${i}=0"
67 done
68 else
69 ALL=1
70 for i in green red blue orange; do
71 eval "${i}=1"
72 done
73 fi
74
75 while [ ! $# = 0 ]; do
76 for i in green red blue orange; do
77 if [ "${i}" == "${1}" ]; then
78 eval "${i}=1"
79 shift
80 fi
81 done
82 done
83
84 case "${DO}" in
85 start)
86 [ "${ALL}" == "1" ] && init_networking
87
88 # Starting interfaces...
89 # GREEN
90 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
91
92 # BLUE
93 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
94 /etc/rc.d/init.d/networking/blue start
95
96 # ORANGE
97 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
98 /etc/rc.d/init.d/networking/orange start
99
100 # RED
101 if [ "$red" == "1" ]; then
102 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
103 # Remove possible leftover files
104 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
105 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
106 fi
107 fi
108 ;;
109
110 stop)
111 # Stopping interfaces...
112 # GREEN
113 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
114
115 # BLUE
116 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
117 /etc/rc.d/init.d/networking/blue stop
118
119 # ORANGE
120 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
121 /etc/rc.d/init.d/networking/orange stop
122
123 # RED
124 if [ "$red" == "1" ]; then
125 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
126 /etc/rc.d/init.d/networking/red stop
127 fi
128 fi
129
130 # Stopping dnsmasq if network all networks shutdown
131 [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop
132
133 exit 0
134 ;;
135
136 restart)
137 for i in green red blue orange; do
138 if [ "${!i}" == "1" ]; then
139 ARGS+=" ${i}"
140 fi
141 done
142 ${0} stop ${ARGS}
143 sleep 1
144 ${0} start ${ARGS}
145 ;;
146
147 *)
148 echo "Usage: ${0} {start|stop|restart} [device(s)]"
149 exit 1
150 ;;
151 esac
152
153 # End /etc/rc.d/init.d/network