Project

General

Profile

Download (7.5 KB) Statistics
| Branch: | Tag: | Revision:
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 d0e94aaf Scott Ullrich
	echo " done.\n";
35
36
	echo "Initializing...";
37
	echo ".";
38 5b237745 Scott Ullrich
	require_once("globals.inc");
39 d0e94aaf Scott Ullrich
	echo ".";
40 5b237745 Scott Ullrich
	/* let the other functions know we're booting */
41 7f347359 Colin Smith
	$pkg_interface = 'console';
42 5b237745 Scott Ullrich
	$g['booting'] = TRUE;
43
	touch("{$g['varrun_path']}/booting");
44 2c35ed91 Scott Ullrich
	if($g['platform'] == "cdrom") {
45 7822d966 Colin Smith
		$motd = trim(file_get_contents("/etc/motd"));
46 2c35ed91 Scott Ullrich
		if(strlen($motd) > 2) echo "\n{$motd}\n\n";
47
	}
48 5f89728d Scott Ullrich
49 5b237745 Scott Ullrich
	/* parse the configuration and include all functions used below */
50
	require_once("config.inc");
51 d0e94aaf Scott Ullrich
	echo ".";
52 5b237745 Scott Ullrich
	require_once("functions.inc");
53 a6abbd66 Scott Ullrich
	/* get system memory amount */
54
	$memory = get_memory();
55
	$avail = $memory[0];
56 d0e94aaf Scott Ullrich
	echo " done.\n";
57 e5cd29a0 Scott Ullrich
58 86ddbb71 Scott Ullrich
	/* start devd (dhclient now uses it */
59 f05740c1 Scott Ullrich
	echo "Starting device manager (devd)...";
60 70b89814 Scott Ullrich
	mute_kernel_msgs();
61 86ddbb71 Scott Ullrich
	start_devd();
62 09b949e1 Scott Ullrich
	set_device_perms();
63 70b89814 Scott Ullrich
	unmute_kernel_msgs();
64 86ddbb71 Scott Ullrich
	echo "done.\n";
65
66 f05740c1 Scott Ullrich
	echo "Loading configuration...";
67 b6f3f5c6 Colin Smith
	parse_config_bootup();
68 74dbce1f Scott Ullrich
	echo "done.\n";
69 b6f3f5c6 Colin Smith
70 afde8c22 Scott Ullrich
	$lan_if = $config['interfaces']['lan']['if'];
71 aa01f2f2 Scott Ullrich
	$wan_if = get_real_wan_interface();
72
73 28d38aa4 Scott Ullrich
	/*
74 22d0b8e5 Bill Marquette
	 *  Determine if we need to throw a interface exception
75 d0e94aaf Scott Ullrich
     *  and ask the user to reassign interfaces.  This will
76
     *  avoid a reboot and thats a good thing.
77 28d38aa4 Scott Ullrich
	 */
78 aa01f2f2 Scott Ullrich
	$do_assign = 0;
79 61c25e53 Scott Ullrich
	/* we need to ignore the vlan interface checks) */
80 12a6188d Scott Ullrich
	if(stristr($lan_if,"vlan") == false and stristr($wan_if,"vlan") == false) {
81 61c25e53 Scott Ullrich
		if(does_interface_exist($lan_if) == false) {
82
			echo "\n\n\nLAN {$lan_if} interface mismatch.";
83 6395d5fa Scott Ullrich
			$do_assign = 1;
84 61c25e53 Scott Ullrich
		}
85
		if($config['interfaces']['wan']['ipaddr'] <> "pppoe" && $config['interfaces']['wan']['ipaddr'] <> "pptp" && $do_assign == 0) {
86
			if(does_interface_exist($wan_if) == false) {
87
				echo "\n\n\nWAN {$wan_if} interface mismatch.";
88
				$do_assign = 1;
89
			}
90
		}
91 76612f46 Scott Ullrich
		if($do_assign == 1 and !file_exists("{$g['tmp_path']}/assign_complete")) {
92 61c25e53 Scott Ullrich
			$noreboot = true;
93
			echo " -- Running interface assignment option.\n";
94
			set_networking_interfaces_ports();
95
		}
96 6ee4c02f Scott Ullrich
	}
97 de16ed63 Scott Ullrich
	unmute_kernel_msgs();
98 aa01f2f2 Scott Ullrich
99 d6f1dbe3 Colin Smith
	/* convert config and clean backups */
100 f05740c1 Scott Ullrich
	echo "Updating configuration...";
101 5b237745 Scott Ullrich
	convert_config();
102 74dbce1f Scott Ullrich
	echo "done.\n";
103 bad59dd6 Colin Smith
104 f05740c1 Scott Ullrich
	echo "Cleaning backup cache...";
105 d6f1dbe3 Colin Smith
	cleanup_backupcache(true);
106 74dbce1f Scott Ullrich
	echo "done.\n";
107 d0e94aaf Scott Ullrich
108 3ff9d424 Scott Ullrich
	/* read in /etc/sysctl.conf and set values if needed */
109 f05740c1 Scott Ullrich
	echo "Setting up extended sysctls...";
110 3ff9d424 Scott Ullrich
	system_setup_sysctl();
111 92e2deb7 Scott Ullrich
	echo "done.\n";
112 3ff9d424 Scott Ullrich
113 88b63d7c Scott Ullrich
	/* sync user passwords */
114 f05740c1 Scott Ullrich
	echo "Syncing user passwords...";
115 88b63d7c Scott Ullrich
	sync_webgui_passwords();
116 92e2deb7 Scott Ullrich
	echo "done.\n";
117 88b63d7c Scott Ullrich
118 f05740c1 Scott Ullrich
	echo "Starting Secure Shell Services...";
119 beaff8b0 Scott Ullrich
	mwexec_bg("/etc/sshd");
120
	echo "done.\n";
121
122 5b237745 Scott Ullrich
	/* run any early shell commands specified in config.xml */
123
	system_do_shell_commands(1);
124 e5cd29a0 Scott Ullrich
125 5b237745 Scott Ullrich
	/* save dmesg output to file */
126
	system_dmesg_save();
127 e5cd29a0 Scott Ullrich
128 5b237745 Scott Ullrich
	/* set up our timezone */
129
	system_timezone_configure();
130 e5cd29a0 Scott Ullrich
131 5b237745 Scott Ullrich
	/* set up our hostname */
132
	system_hostname_configure();
133 e5cd29a0 Scott Ullrich
134 5b237745 Scott Ullrich
	/* make hosts file */
135
	system_hosts_generate();
136 e5cd29a0 Scott Ullrich
137 5b237745 Scott Ullrich
	/* generate resolv.conf */
138
	system_resolvconf_generate();
139 e5cd29a0 Scott Ullrich
140 5b237745 Scott Ullrich
	/* configure loopback interface */
141
	interfaces_loopback_configure();
142 e5cd29a0 Scott Ullrich
143 93629767 Scott Ullrich
	/* start syslogd */
144
	system_syslogd_start();
145
146 5b237745 Scott Ullrich
	/* set up VLAN virtual interfaces */
147
	interfaces_vlan_configure();
148 e5cd29a0 Scott Ullrich
149 5b237745 Scott Ullrich
	/* set up LAN interface */
150 f05740c1 Scott Ullrich
	echo "Configuring LAN interface...";
151 dd2ab8f8 Scott Ullrich
	mute_kernel_msgs();
152 5b237745 Scott Ullrich
	interfaces_lan_configure();
153 dd2ab8f8 Scott Ullrich
	unmute_kernel_msgs();
154 74dbce1f Scott Ullrich
	echo "done.\n";
155 e5cd29a0 Scott Ullrich
156 5b237745 Scott Ullrich
	/* set up WAN interface */
157 f05740c1 Scott Ullrich
	echo "Configuring WAN interface...";
158 dd2ab8f8 Scott Ullrich
	mute_kernel_msgs();
159 5b237745 Scott Ullrich
	interfaces_wan_configure();
160 dd2ab8f8 Scott Ullrich
	unmute_kernel_msgs();
161 74dbce1f Scott Ullrich
	echo "done.\n";
162 e5cd29a0 Scott Ullrich
163 5b237745 Scott Ullrich
	/* set up Optional interfaces */
164 f05740c1 Scott Ullrich
	echo "Configuring OPT interfaces...";
165 e556dea7 Scott Ullrich
	if(!$debugging)
166
		mute_kernel_msgs();
167 5b237745 Scott Ullrich
	interfaces_optional_configure();
168 d0e94aaf Scott Ullrich
	if(!$debugging)
169 e556dea7 Scott Ullrich
		unmute_kernel_msgs();
170 74dbce1f Scott Ullrich
	echo "done.\n";
171 dd2ab8f8 Scott Ullrich
172 ae723ece Scott Ullrich
	/* bring up carp interfaces */
173
	interfaces_carp_configure();
174
175 3a89b8d9 Scott Ullrich
	/* generate resolv.conf */
176
	system_resolvconf_generate();
177
178 24d15c0c Scott Ullrich
	/* start pflog */
179
	filter_pflog_start();
180 3962b070 Scott Ullrich
181
	setup_filter_bridge();
182 ab34f4ec Scott Ullrich
183
	/* start load balancer daemon */
184
	slbd_configure();
185 12c09555 Scott Ullrich
186
	/* start OpenVPN server & clients */
187
    openvpn_resync_all();
188 d0e94aaf Scott Ullrich
189 24d15c0c Scott Ullrich
	/* setup altq + pf */
190 cb74ffd5 Scott Ullrich
	echo "Configuring firewall...";
191 1c872736 Scott Ullrich
	//mute_kernel_msgs();
192 4e6f9d37 Scott Ullrich
	filter_configure_sync();
193 1c872736 Scott Ullrich
	//unmute_kernel_msgs();
194 74dbce1f Scott Ullrich
	echo "done.\n";
195 e5cd29a0 Scott Ullrich
196 a6abbd66 Scott Ullrich
	if($avail > 0 and $avail < 65) {
197 bd042586 Scott Ullrich
		echo "System has less than 65 megabytes of ram {$avail}.  Delaying webConfigurator startup.\n";
198 a6abbd66 Scott Ullrich
		/* start webConfigurator up on final pass */
199
		touch("/tmp/restart_webgui");
200
	} else {
201
		/* start web server */
202
		system_webgui_start();
203
	}
204 d0e94aaf Scott Ullrich
205 5b237745 Scott Ullrich
	/* set up static routes */
206
	system_routing_configure();
207 e5cd29a0 Scott Ullrich
208 5b237745 Scott Ullrich
	/* enable routing */
209
	system_routing_enable();
210 d0e94aaf Scott Ullrich
211 fb453a4a Scott Ullrich
	/* ensure passwords are sync'd */
212
	system_password_configure();
213 e5cd29a0 Scott Ullrich
214 5b237745 Scott Ullrich
	/* configure console menu */
215
	system_console_configure();
216 e5cd29a0 Scott Ullrich
217 5b237745 Scott Ullrich
	/* start dnsmasq service */
218
	services_dnsmasq_configure();
219 e5cd29a0 Scott Ullrich
220 5b237745 Scott Ullrich
	/* start dyndns service */
221
	services_dyndns_configure();
222 d0e94aaf Scott Ullrich
223 5ffb18e0 Scott Ullrich
	/* static IP address? -> attempt DNS update */
224
	if (is_ipaddr($config['interfaces']['wan']['ipaddr']))
225
		services_dnsupdate_process();
226 e5cd29a0 Scott Ullrich
227 5b237745 Scott Ullrich
	/* start DHCP service */
228
	services_dhcpd_configure();
229 e5cd29a0 Scott Ullrich
230 5ffb18e0 Scott Ullrich
	/* start DHCP relay */
231
	services_dhcrelay_configure();
232
233 5b237745 Scott Ullrich
	/* start proxy ARP service */
234
	services_proxyarp_configure();
235
236
	/* start the NTP client */
237
	system_ntp_configure();
238 e5cd29a0 Scott Ullrich
239 88964924 Scott Ullrich
	/* setup pppoe and pptp */
240
	vpn_setup();
241 3d941d72 Scott Ullrich
242 5b237745 Scott Ullrich
	/* start the captive portal */
243
	captiveportal_configure();
244 e5cd29a0 Scott Ullrich
245 5b237745 Scott Ullrich
	/* run any shell commands specified in config.xml */
246
	system_do_shell_commands();
247 e5cd29a0 Scott Ullrich
248 562fca6d Scott Ullrich
	/* setup polling */
249
	setup_polling();
250
251 28d38aa4 Scott Ullrich
	/* setup interface microcode which improves tcp/ip speed */
252 f05740c1 Scott Ullrich
	echo "Setting up microcode and tx/rx offloading...";
253 11e2c67c Scott Ullrich
	setup_microcode();
254 0192adaf Scott Ullrich
	echo "done.\n";
255 d0e94aaf Scott Ullrich
256 11e2c67c Scott Ullrich
	mwexec("/sbin/pfctl -f /tmp/rules.debug");
257 d0e94aaf Scott Ullrich
258 11c32d4a Scott Ullrich
	/* start IPsec tunnels */
259 11e2c67c Scott Ullrich
	vpn_ipsec_configure();
260 c6e604d8 Scott Ullrich
261 154349f9 Scott Ullrich
	/* start ftp proxy helpers if they are enabled */
262 f05740c1 Scott Ullrich
	echo "Starting FTP helpers...";
263 154349f9 Scott Ullrich
	system_start_ftp_helpers();
264
	echo "done.\n";
265
266 11e2c67c Scott Ullrich
	interfaces_carp_bring_up_final();
267 04c5bd17 Scott Ullrich
268 f4959a69 Scott Ullrich
	/* start SNMP service */
269
	services_snmpd_configure();
270
271 9f966bc9 Scott Ullrich
	/* power down hard drive if needed/set */
272 11e2c67c Scott Ullrich
	system_set_harddisk_standby();
273 9f966bc9 Scott Ullrich
274 ce9e67ce Scott Ullrich
	/* lock down console if necessary */
275
	if(isset($config['system']['disableconsolemenu']))
276
		touch("/var/etc/console_lockdown");
277 f4959a69 Scott Ullrich
278 b826526d Scott Ullrich
	filter_configure();
279 d0e94aaf Scott Ullrich
280 f0842feb Scott Ullrich
	/* load graphing functions */
281 d0e94aaf Scott Ullrich
	enable_rrd_graphing();
282 1e19b3b4 Scott Ullrich
283
	/*   start DHCP service again now that CARP has settled
284
	 *   incase user is using primary/backup failover dhcp mode
285
         */
286
	services_dhcpd_configure();
287 a199b93e Scott Ullrich
288 11cbd478 Scott Ullrich
	/* startup OLSR if needed */
289
	setup_wireless_olsr();
290
291 a199b93e Scott Ullrich
	/* enable watchdog if supported */
292
	enable_watchdog();
293 d0e94aaf Scott Ullrich
294 5b237745 Scott Ullrich
	/* done */
295
	unlink("{$g['varrun_path']}/booting");
296 5c60c947 Scott Ullrich
	$g['booting'] = FALSE;
297
298 d0e94aaf Scott Ullrich
?>