Project

General

Profile

Download (7.5 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php -f
2
<?php
3
/* $Id$ */
4
/*
5
	rc.bootup
6
	part of pfSense by Scott Ullrich
7
	originally based on m0n0wall (http://m0n0.ch/wall)
8

    
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	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

    
22
	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
	echo " done.\n";
35

    
36
	echo "Initializing...";
37
	echo ".";
38
	require_once("globals.inc");
39
	echo ".";
40
	/* let the other functions know we're booting */
41
	$pkg_interface = 'console';
42
	$g['booting'] = TRUE;
43
	touch("{$g['varrun_path']}/booting");
44
	if($g['platform'] == "cdrom") {
45
		$motd = trim(file_get_contents("/etc/motd"));
46
		if(strlen($motd) > 2) echo "\n{$motd}\n\n";
47
	}
48

    
49
	/* parse the configuration and include all functions used below */
50
	require_once("config.inc");
51
	echo ".";
52
	require_once("functions.inc");
53
	/* get system memory amount */
54
	$memory = get_memory();
55
	$avail = $memory[0];
56
	echo " done.\n";
57

    
58
	/* start devd (dhclient now uses it */
59
	echo "Starting device manager (devd)...";
60
	mute_kernel_msgs();
61
	start_devd();
62
	set_device_perms();
63
	unmute_kernel_msgs();
64
	echo "done.\n";
65

    
66
	echo "Loading configuration...";
67
	parse_config_bootup();
68
	echo "done.\n";
69

    
70
	$lan_if = $config['interfaces']['lan']['if'];
71
	$wan_if = get_real_wan_interface();
72

    
73
	/*
74
	 *  Determine if we need to throw a interface exception
75
     *  and ask the user to reassign interfaces.  This will
76
     *  avoid a reboot and thats a good thing.
77
	 */
78
	$do_assign = 0;
79
	/* we need to ignore the vlan interface checks) */
80
	if(stristr($lan_if,"vlan") == false and stristr($wan_if,"vlan") == false) {
81
		if(does_interface_exist($lan_if) == false) {
82
			echo "\n\n\nLAN {$lan_if} interface mismatch.";
83
			$do_assign = 1;
84
		}
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
		if($do_assign == 1 and !file_exists("{$g['tmp_path']}/assign_complete")) {
92
			$noreboot = true;
93
			echo " -- Running interface assignment option.\n";
94
			set_networking_interfaces_ports();
95
		}
96
	}
97
	unmute_kernel_msgs();
98

    
99
	/* convert config and clean backups */
100
	echo "Updating configuration...";
101
	convert_config();
102
	echo "done.\n";
103

    
104
	echo "Cleaning backup cache...";
105
	cleanup_backupcache(true);
106
	echo "done.\n";
107

    
108
	/* read in /etc/sysctl.conf and set values if needed */
109
	echo "Setting up extended sysctls...";
110
	system_setup_sysctl();
111
	echo "done.\n";
112

    
113
	/* sync user passwords */
114
	echo "Syncing user passwords...";
115
	sync_webgui_passwords();
116
	echo "done.\n";
117

    
118
	echo "Starting Secure Shell Services...";
119
	mwexec_bg("/etc/sshd");
120
	echo "done.\n";
121

    
122
	/* run any early shell commands specified in config.xml */
123
	system_do_shell_commands(1);
124

    
125
	/* save dmesg output to file */
126
	system_dmesg_save();
127

    
128
	/* set up our timezone */
129
	system_timezone_configure();
130

    
131
	/* set up our hostname */
132
	system_hostname_configure();
133

    
134
	/* make hosts file */
135
	system_hosts_generate();
136

    
137
	/* generate resolv.conf */
138
	system_resolvconf_generate();
139

    
140
	/* configure loopback interface */
141
	interfaces_loopback_configure();
142

    
143
	/* start syslogd */
144
	system_syslogd_start();
145

    
146
	/* set up VLAN virtual interfaces */
147
	interfaces_vlan_configure();
148

    
149
	/* set up LAN interface */
150
	echo "Configuring LAN interface...";
151
	mute_kernel_msgs();
152
	interfaces_lan_configure();
153
	unmute_kernel_msgs();
154
	echo "done.\n";
155

    
156
	/* set up WAN interface */
157
	echo "Configuring WAN interface...";
158
	mute_kernel_msgs();
159
	interfaces_wan_configure();
160
	unmute_kernel_msgs();
161
	echo "done.\n";
162

    
163
	/* set up Optional interfaces */
164
	echo "Configuring OPT interfaces...";
165
	if(!$debugging)
166
		mute_kernel_msgs();
167
	interfaces_optional_configure();
168
	if(!$debugging)
169
		unmute_kernel_msgs();
170
	echo "done.\n";
171

    
172
	/* bring up carp interfaces */
173
	interfaces_carp_configure();
174

    
175
	/* generate resolv.conf */
176
	system_resolvconf_generate();
177

    
178
	/* start pflog */
179
	filter_pflog_start();
180

    
181
	setup_filter_bridge();
182

    
183
	/* start load balancer daemon */
184
	slbd_configure();
185

    
186
	/* start OpenVPN server & clients */
187
    openvpn_resync_all();
188

    
189
	/* setup altq + pf */
190
	echo "Configuring firewall...";
191
	//mute_kernel_msgs();
192
	filter_configure_sync();
193
	//unmute_kernel_msgs();
194
	echo "done.\n";
195

    
196
	if($avail > 0 and $avail < 65) {
197
		echo "System has less than 65 megabytes of ram {$avail}.  Delaying webConfigurator startup.\n";
198
		/* start webConfigurator up on final pass */
199
		touch("/tmp/restart_webgui");
200
	} else {
201
		/* start web server */
202
		system_webgui_start();
203
	}
204

    
205
	/* set up static routes */
206
	system_routing_configure();
207

    
208
	/* enable routing */
209
	system_routing_enable();
210

    
211
	/* ensure passwords are sync'd */
212
	system_password_configure();
213

    
214
	/* configure console menu */
215
	system_console_configure();
216

    
217
	/* start dnsmasq service */
218
	services_dnsmasq_configure();
219

    
220
	/* start dyndns service */
221
	services_dyndns_configure();
222

    
223
	/* static IP address? -> attempt DNS update */
224
	if (is_ipaddr($config['interfaces']['wan']['ipaddr']))
225
		services_dnsupdate_process();
226

    
227
	/* start DHCP service */
228
	services_dhcpd_configure();
229

    
230
	/* start DHCP relay */
231
	services_dhcrelay_configure();
232

    
233
	/* start proxy ARP service */
234
	services_proxyarp_configure();
235

    
236
	/* start the NTP client */
237
	system_ntp_configure();
238

    
239
	/* setup pppoe and pptp */
240
	vpn_setup();
241

    
242
	/* start the captive portal */
243
	captiveportal_configure();
244

    
245
	/* run any shell commands specified in config.xml */
246
	system_do_shell_commands();
247

    
248
	/* setup polling */
249
	setup_polling();
250

    
251
	/* setup interface microcode which improves tcp/ip speed */
252
	echo "Setting up microcode and tx/rx offloading...";
253
	setup_microcode();
254
	echo "done.\n";
255

    
256
	mwexec("/sbin/pfctl -f /tmp/rules.debug");
257

    
258
	/* start IPsec tunnels */
259
	vpn_ipsec_configure();
260

    
261
	/* start ftp proxy helpers if they are enabled */
262
	echo "Starting FTP helpers...";
263
	system_start_ftp_helpers();
264
	echo "done.\n";
265

    
266
	interfaces_carp_bring_up_final();
267

    
268
	/* start SNMP service */
269
	services_snmpd_configure();
270

    
271
	/* power down hard drive if needed/set */
272
	system_set_harddisk_standby();
273

    
274
	/* lock down console if necessary */
275
	if(isset($config['system']['disableconsolemenu']))
276
		touch("/var/etc/console_lockdown");
277

    
278
	filter_configure();
279

    
280
	/* load graphing functions */
281
	enable_rrd_graphing();
282

    
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

    
288
	/* startup OLSR if needed */
289
	setup_wireless_olsr();
290

    
291
	/* enable watchdog if supported */
292
	enable_watchdog();
293

    
294
	/* done */
295
	unlink("{$g['varrun_path']}/booting");
296
	$g['booting'] = FALSE;
297

    
298
?>
(26-26/71)