1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php -f
|
2 |
|
|
<?php
|
3 |
1b8df11b
|
Bill Marquette
|
/* $Id$ */
|
4 |
5b237745
|
Scott Ullrich
|
/*
|
5 |
|
|
rc.bootup
|
6 |
e5cd29a0
|
Scott Ullrich
|
part of pfSense by Scott Ullrich
|
7 |
|
|
originally based on m0n0wall (http://m0n0.ch/wall)
|
8 |
|
|
|
9 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10 |
|
|
All rights reserved.
|
11 |
e5cd29a0
|
Scott Ullrich
|
|
12 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
13 |
|
|
modification, are permitted provided that the following conditions are met:
|
14 |
e5cd29a0
|
Scott Ullrich
|
|
15 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
16 |
|
|
this list of conditions and the following disclaimer.
|
17 |
e5cd29a0
|
Scott Ullrich
|
|
18 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
19 |
|
|
notice, this list of conditions and the following disclaimer in the
|
20 |
|
|
documentation and/or other materials provided with the distribution.
|
21 |
e5cd29a0
|
Scott Ullrich
|
|
22 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
32 |
|
|
*/
|
33 |
|
|
|
34 |
|
|
require_once("globals.inc");
|
35 |
9eb4ec60
|
Scott Ullrich
|
require_once("pfsense-utils.inc");
|
36 |
5b237745
|
Scott Ullrich
|
|
37 |
|
|
/* let the other functions know we're booting */
|
38 |
7f347359
|
Colin Smith
|
$pkg_interface = 'console';
|
39 |
5b237745
|
Scott Ullrich
|
$g['booting'] = TRUE;
|
40 |
|
|
touch("{$g['varrun_path']}/booting");
|
41 |
|
|
|
42 |
2c35ed91
|
Scott Ullrich
|
if($g['platform'] == "cdrom") {
|
43 |
7822d966
|
Colin Smith
|
$motd = trim(file_get_contents("/etc/motd"));
|
44 |
2c35ed91
|
Scott Ullrich
|
if(strlen($motd) > 2) echo "\n{$motd}\n\n";
|
45 |
|
|
}
|
46 |
5f89728d
|
Scott Ullrich
|
|
47 |
5b237745
|
Scott Ullrich
|
/* parse the configuration and include all functions used below */
|
48 |
|
|
require_once("config.inc");
|
49 |
f102f9a2
|
Scott Ullrich
|
|
50 |
5b237745
|
Scott Ullrich
|
require_once("functions.inc");
|
51 |
e5cd29a0
|
Scott Ullrich
|
|
52 |
74dbce1f
|
Scott Ullrich
|
echo "Loading configuration... ";
|
53 |
b6f3f5c6
|
Colin Smith
|
parse_config_bootup();
|
54 |
74dbce1f
|
Scott Ullrich
|
echo "done.\n";
|
55 |
b6f3f5c6
|
Colin Smith
|
|
56 |
afde8c22
|
Scott Ullrich
|
$lan_if = $config['interfaces']['lan']['if'];
|
57 |
aa01f2f2
|
Scott Ullrich
|
$wan_if = get_real_wan_interface();
|
58 |
|
|
|
59 |
28d38aa4
|
Scott Ullrich
|
/*
|
60 |
22d0b8e5
|
Bill Marquette
|
* Determine if we need to throw a interface exception
|
61 |
28d38aa4
|
Scott Ullrich
|
* and ask the user to reassign interfaces. This will
|
62 |
|
|
* avoid a reboot and thats a good thing.
|
63 |
|
|
*/
|
64 |
aa01f2f2
|
Scott Ullrich
|
$do_assign = 0;
|
65 |
61c25e53
|
Scott Ullrich
|
/* we need to ignore the vlan interface checks) */
|
66 |
12a6188d
|
Scott Ullrich
|
if(stristr($lan_if,"vlan") == false and stristr($wan_if,"vlan") == false) {
|
67 |
61c25e53
|
Scott Ullrich
|
if(does_interface_exist($lan_if) == false) {
|
68 |
|
|
echo "\n\n\nLAN {$lan_if} interface mismatch.";
|
69 |
6395d5fa
|
Scott Ullrich
|
$do_assign = 1;
|
70 |
61c25e53
|
Scott Ullrich
|
}
|
71 |
|
|
if($config['interfaces']['wan']['ipaddr'] <> "pppoe" && $config['interfaces']['wan']['ipaddr'] <> "pptp" && $do_assign == 0) {
|
72 |
|
|
if(does_interface_exist($wan_if) == false) {
|
73 |
|
|
echo "\n\n\nWAN {$wan_if} interface mismatch.";
|
74 |
|
|
$do_assign = 1;
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
if($do_assign == 1) {
|
78 |
|
|
$noreboot = true;
|
79 |
|
|
echo " -- Running interface assignment option.\n";
|
80 |
|
|
set_networking_interfaces_ports();
|
81 |
|
|
}
|
82 |
6ee4c02f
|
Scott Ullrich
|
}
|
83 |
aa01f2f2
|
Scott Ullrich
|
|
84 |
d6f1dbe3
|
Colin Smith
|
/* convert config and clean backups */
|
85 |
74dbce1f
|
Scott Ullrich
|
echo "Updating configuration... ";
|
86 |
5b237745
|
Scott Ullrich
|
convert_config();
|
87 |
74dbce1f
|
Scott Ullrich
|
echo "done.\n";
|
88 |
bad59dd6
|
Colin Smith
|
|
89 |
74dbce1f
|
Scott Ullrich
|
echo "Cleaning backup cache... ";
|
90 |
d6f1dbe3
|
Colin Smith
|
cleanup_backupcache(true);
|
91 |
74dbce1f
|
Scott Ullrich
|
echo "done.\n";
|
92 |
dd2ab8f8
|
Scott Ullrich
|
|
93 |
3ff9d424
|
Scott Ullrich
|
/* read in /etc/sysctl.conf and set values if needed */
|
94 |
|
|
system_setup_sysctl();
|
95 |
|
|
|
96 |
5b237745
|
Scott Ullrich
|
/* run any early shell commands specified in config.xml */
|
97 |
|
|
system_do_shell_commands(1);
|
98 |
e5cd29a0
|
Scott Ullrich
|
|
99 |
5b237745
|
Scott Ullrich
|
/* save dmesg output to file */
|
100 |
|
|
system_dmesg_save();
|
101 |
e5cd29a0
|
Scott Ullrich
|
|
102 |
5b237745
|
Scott Ullrich
|
/* set up our timezone */
|
103 |
|
|
system_timezone_configure();
|
104 |
e5cd29a0
|
Scott Ullrich
|
|
105 |
5b237745
|
Scott Ullrich
|
/* set up our hostname */
|
106 |
|
|
system_hostname_configure();
|
107 |
e5cd29a0
|
Scott Ullrich
|
|
108 |
5b237745
|
Scott Ullrich
|
/* make hosts file */
|
109 |
|
|
system_hosts_generate();
|
110 |
e5cd29a0
|
Scott Ullrich
|
|
111 |
5b237745
|
Scott Ullrich
|
/* generate resolv.conf */
|
112 |
|
|
system_resolvconf_generate();
|
113 |
e5cd29a0
|
Scott Ullrich
|
|
114 |
5b237745
|
Scott Ullrich
|
/* configure loopback interface */
|
115 |
|
|
interfaces_loopback_configure();
|
116 |
e5cd29a0
|
Scott Ullrich
|
|
117 |
caeb3b46
|
Scott Ullrich
|
/* start devd (dhclient now uses it */
|
118 |
|
|
start_devd();
|
119 |
|
|
|
120 |
5b237745
|
Scott Ullrich
|
/* set up VLAN virtual interfaces */
|
121 |
|
|
interfaces_vlan_configure();
|
122 |
e5cd29a0
|
Scott Ullrich
|
|
123 |
5b237745
|
Scott Ullrich
|
/* set up LAN interface */
|
124 |
74dbce1f
|
Scott Ullrich
|
echo "Configuring LAN interface... ";
|
125 |
dd2ab8f8
|
Scott Ullrich
|
mute_kernel_msgs();
|
126 |
5b237745
|
Scott Ullrich
|
interfaces_lan_configure();
|
127 |
dd2ab8f8
|
Scott Ullrich
|
unmute_kernel_msgs();
|
128 |
74dbce1f
|
Scott Ullrich
|
echo "done.\n";
|
129 |
e5cd29a0
|
Scott Ullrich
|
|
130 |
5b237745
|
Scott Ullrich
|
/* set up WAN interface */
|
131 |
74dbce1f
|
Scott Ullrich
|
echo "Configuring WAN interface... ";
|
132 |
dd2ab8f8
|
Scott Ullrich
|
mute_kernel_msgs();
|
133 |
5b237745
|
Scott Ullrich
|
interfaces_wan_configure();
|
134 |
dd2ab8f8
|
Scott Ullrich
|
unmute_kernel_msgs();
|
135 |
74dbce1f
|
Scott Ullrich
|
echo "done.\n";
|
136 |
e5cd29a0
|
Scott Ullrich
|
|
137 |
5b237745
|
Scott Ullrich
|
/* set up Optional interfaces */
|
138 |
fc6b5a4d
|
Scott Ullrich
|
echo "Configuring OPT interfaces... ";
|
139 |
32438cec
|
Colin Smith
|
mute_kernel_msgs();
|
140 |
5b237745
|
Scott Ullrich
|
interfaces_optional_configure();
|
141 |
dd2ab8f8
|
Scott Ullrich
|
unmute_kernel_msgs();
|
142 |
74dbce1f
|
Scott Ullrich
|
echo "done.\n";
|
143 |
dd2ab8f8
|
Scott Ullrich
|
|
144 |
24d15c0c
|
Scott Ullrich
|
/* start pflog */
|
145 |
|
|
filter_pflog_start();
|
146 |
c6e604d8
|
Scott Ullrich
|
|
147 |
|
|
/* bring up carp interfaces */
|
148 |
|
|
interfaces_carp_bringup();
|
149 |
|
|
|
150 |
24d15c0c
|
Scott Ullrich
|
/* setup altq + pf */
|
151 |
fc6b5a4d
|
Scott Ullrich
|
echo "Configuring firewall... ";
|
152 |
1c872736
|
Scott Ullrich
|
//mute_kernel_msgs();
|
153 |
4e6f9d37
|
Scott Ullrich
|
filter_configure_sync();
|
154 |
1c872736
|
Scott Ullrich
|
//unmute_kernel_msgs();
|
155 |
74dbce1f
|
Scott Ullrich
|
echo "done.\n";
|
156 |
e5cd29a0
|
Scott Ullrich
|
|
157 |
24d15c0c
|
Scott Ullrich
|
/* start OpenVPN server & clients */
|
158 |
|
|
ovpn_configure();
|
159 |
e5cd29a0
|
Scott Ullrich
|
|
160 |
5b237745
|
Scott Ullrich
|
/* set up static routes */
|
161 |
|
|
system_routing_configure();
|
162 |
e5cd29a0
|
Scott Ullrich
|
|
163 |
5b237745
|
Scott Ullrich
|
/* enable routing */
|
164 |
|
|
system_routing_enable();
|
165 |
e5cd29a0
|
Scott Ullrich
|
|
166 |
5b237745
|
Scott Ullrich
|
/* start syslogd */
|
167 |
|
|
system_syslogd_start();
|
168 |
e5cd29a0
|
Scott Ullrich
|
|
169 |
5b237745
|
Scott Ullrich
|
/* start web server */
|
170 |
|
|
system_webgui_start();
|
171 |
fb453a4a
|
Scott Ullrich
|
|
172 |
|
|
/* ensure passwords are sync'd */
|
173 |
|
|
system_password_configure();
|
174 |
e5cd29a0
|
Scott Ullrich
|
|
175 |
5b237745
|
Scott Ullrich
|
/* configure console menu */
|
176 |
|
|
system_console_configure();
|
177 |
e5cd29a0
|
Scott Ullrich
|
|
178 |
5b237745
|
Scott Ullrich
|
/* start dnsmasq service */
|
179 |
|
|
services_dnsmasq_configure();
|
180 |
e5cd29a0
|
Scott Ullrich
|
|
181 |
5b237745
|
Scott Ullrich
|
/* start dyndns service */
|
182 |
|
|
services_dyndns_configure();
|
183 |
e5cd29a0
|
Scott Ullrich
|
|
184 |
5b237745
|
Scott Ullrich
|
/* start DHCP service */
|
185 |
|
|
services_dhcpd_configure();
|
186 |
e5cd29a0
|
Scott Ullrich
|
|
187 |
5b237745
|
Scott Ullrich
|
/* start SNMP service */
|
188 |
|
|
services_snmpd_configure();
|
189 |
e5cd29a0
|
Scott Ullrich
|
|
190 |
5b237745
|
Scott Ullrich
|
/* start proxy ARP service */
|
191 |
|
|
services_proxyarp_configure();
|
192 |
|
|
|
193 |
|
|
/* start the NTP client */
|
194 |
|
|
system_ntp_configure();
|
195 |
e5cd29a0
|
Scott Ullrich
|
|
196 |
5b237745
|
Scott Ullrich
|
/* start pptpd */
|
197 |
|
|
vpn_pptpd_configure();
|
198 |
e5cd29a0
|
Scott Ullrich
|
|
199 |
3d941d72
|
Scott Ullrich
|
/* start pppoe server */
|
200 |
|
|
vpn_pppoe_configure();
|
201 |
|
|
|
202 |
5b237745
|
Scott Ullrich
|
/* start the captive portal */
|
203 |
|
|
captiveportal_configure();
|
204 |
e5cd29a0
|
Scott Ullrich
|
|
205 |
5b237745
|
Scott Ullrich
|
/* execute the rc scripts of extensions */
|
206 |
|
|
system_do_extensions();
|
207 |
e5cd29a0
|
Scott Ullrich
|
|
208 |
5b237745
|
Scott Ullrich
|
/* run any shell commands specified in config.xml */
|
209 |
|
|
system_do_shell_commands();
|
210 |
e5cd29a0
|
Scott Ullrich
|
|
211 |
dd78523c
|
Scott Ullrich
|
/* start ftp proxy helpers if they are enabled */
|
212 |
74dbce1f
|
Scott Ullrich
|
echo "Starting FTP helpers... ";
|
213 |
61c25e53
|
Scott Ullrich
|
system_start_ftp_helpers();
|
214 |
74dbce1f
|
Scott Ullrich
|
echo "done.\n";
|
215 |
dd78523c
|
Scott Ullrich
|
|
216 |
28d38aa4
|
Scott Ullrich
|
/* setup interface microcode which improves tcp/ip speed */
|
217 |
bd99c318
|
Scott Ullrich
|
mute_kernel_msgs();
|
218 |
9f6b1429
|
Scott Ullrich
|
setup_microcode();
|
219 |
bd99c318
|
Scott Ullrich
|
unmute_kernel_msgs();
|
220 |
9f6b1429
|
Scott Ullrich
|
|
221 |
c6e604d8
|
Scott Ullrich
|
/* setup carp interfaces */
|
222 |
|
|
interfaces_carp_configure();
|
223 |
|
|
|
224 |
|
|
mwexec("/sbin/pfctl -f /tmp/rules.debug");
|
225 |
11c32d4a
|
Scott Ullrich
|
|
226 |
|
|
/* start IPsec tunnels */
|
227 |
|
|
vpn_ipsec_configure();
|
228 |
c6e604d8
|
Scott Ullrich
|
|
229 |
02e7ac12
|
Bill Marquette
|
/* start load balancer daemon */
|
230 |
|
|
slbd_configure();
|
231 |
|
|
|
232 |
5b237745
|
Scott Ullrich
|
/* done */
|
233 |
|
|
unlink("{$g['varrun_path']}/booting");
|
234 |
5c60c947
|
Scott Ullrich
|
$g['booting'] = FALSE;
|
235 |
|
|
|
236 |
22d0b8e5
|
Bill Marquette
|
?>
|