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