]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/network
network: Remove redundant insertion of wireless rules.
[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 /etc/rc.d/init.d/dnsmasq start
45 /etc/rc.d/init.d/static-routes start
46 }
47
48 DO="${1}"
49 shift
50
51 if [ -n "${1}" ]; then
52 ALL=0
53 for i in green red blue orange; do
54 eval "${i}=0"
55 done
56 else
57 ALL=1
58 for i in green red blue orange; do
59 eval "${i}=1"
60 done
61 fi
62
63 while [ ! $# = 0 ]; do
64 for i in green red blue orange; do
65 if [ "${i}" == "${1}" ]; then
66 eval "${i}=1"
67 shift
68 fi
69 done
70 done
71
72 case "${DO}" in
73 start)
74 [ "${ALL}" == "1" ] && init_networking
75
76 # Starting interfaces...
77 # GREEN
78 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
79
80 # BLUE
81 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
82 /etc/rc.d/init.d/networking/blue start
83
84 # ORANGE
85 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
86 /etc/rc.d/init.d/networking/orange start
87
88 # RED
89 if [ "$red" == "1" ]; then
90 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
91 # Remove possible leftover files
92 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
93 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
94 fi
95 fi
96 ;;
97
98 stop)
99 # Stopping interfaces...
100 # GREEN
101 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
102
103 # BLUE
104 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
105 /etc/rc.d/init.d/networking/blue stop
106
107 # ORANGE
108 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
109 /etc/rc.d/init.d/networking/orange stop
110
111 # RED
112 if [ "$red" == "1" ]; then
113 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
114 /etc/rc.d/init.d/networking/red stop
115 fi
116 fi
117
118 # Stopping dnsmasq if network all networks shutdown
119 [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop
120
121 exit 0
122 ;;
123
124 restart)
125 for i in green red blue orange; do
126 if [ "${!i}" == "1" ]; then
127 ARGS+=" ${i}"
128 fi
129 done
130 ${0} stop ${ARGS}
131 sleep 1
132 ${0} start ${ARGS}
133 ;;
134
135 *)
136 echo "Usage: ${0} {start|stop|restart} [device(s)]"
137 exit 1
138 ;;
139 esac
140
141 # End /etc/rc.d/init.d/network