Project

General

Profile

Download (8.26 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("/etc/inc/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("/etc/inc/config.inc");
51
	echo ".";
52
	require_once("/etc/inc/functions.inc");
53
	/* get system memory amount */
54
	$memory = get_memory();
55
	$avail = $memory[0];
56
	echo " done.\n";
57

    
58
	conf_mount_rw();
59

    
60
	/* remove previous firmware upgrade if present */
61
	if(file_exists("/root/firmware.tgz")) 
62
		unlink("/root/firmware.tgz");
63

    
64
	/* start devd (dhclient now uses it */
65
	echo "Starting device manager (devd)...";
66
	mute_kernel_msgs();
67
	start_devd();
68
	set_device_perms();
69
	unmute_kernel_msgs();
70
	echo "done.\n";
71

    
72
	echo "Loading configuration...";
73
	parse_config_bootup();
74
	echo "done.\n";
75

    
76
	/* setup php.ini */
77
	opcode_cache_configuration();
78

    
79
	$lan_if = $config['interfaces']['lan']['if'];
80
	$wan_if = get_real_wan_interface();
81

    
82
	/*
83
	 *  Determine if we need to throw a interface exception
84
     *  and ask the user to reassign interfaces.  This will
85
     *  avoid a reboot and thats a good thing.
86
	 */
87
	unmute_kernel_msgs();
88
	/*
89
	 *   Determine if we need to throw a interface exception
90
	 *   and ask the user to reassign interfaces.  This will
91
	 *   avoid a reboot and thats a good thing.
92
	 */
93
	while(is_interface_mismatch() == true) {
94
		echo "\nNetwork interface mismatch -- Running interface assignment option.\n";
95
		set_networking_interfaces_ports();
96
	}
97
	
98
	/* convert config and clean backups */
99
	echo "Updating configuration...";
100
	convert_config();
101
	echo "done.\n";
102

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
177
	/* check if the wan interface is up, this might delay upto 10 seconds */
178
	is_wan_interface_up("wan");
179

    
180
	/* Sync the system time at boot before service startup */
181
	sync_system_time();
182

    
183
	/* start pflog */
184
	filter_pflog_start();
185

    
186
	setup_filter_bridge();
187

    
188
	/* start load balancer daemon */
189
	load_balancer_use_sticky();
190
	slbd_configure();
191

    
192
	/* start OpenVPN server & clients */
193
    openvpn_resync_all();
194

    
195
	/* setup altq + pf */
196
	echo "Configuring firewall...";
197
	//mute_kernel_msgs();
198
	filter_configure_sync();
199
	//unmute_kernel_msgs();
200
	echo "done.\n";
201

    
202
	if($avail > 0 and $avail < 65) {
203
		echo "System has less than 65 megabytes of ram {$avail}.  Delaying webConfigurator startup.\n";
204
		/* start webConfigurator up on final pass */
205
		touch("/tmp/restart_webgui");
206
	} else {
207
		/* start web server */
208
		system_webgui_start();
209
	}
210

    
211
	/* configure cron service */
212
	configure_cron();
213

    
214
	/* set up static routes */
215
	system_routing_configure();
216

    
217
	/* enable routing */
218
	system_routing_enable();
219

    
220
	/* ensure passwords are sync'd */
221
	system_password_configure();
222

    
223
	/* configure console menu */
224
	system_console_configure();
225

    
226
	/* start dnsmasq service */
227
	services_dnsmasq_configure();
228

    
229
	/* start dyndns service */
230
	services_dyndns_configure();
231

    
232
	/* static IP address? -> attempt DNS update */
233
	if (is_ipaddr($config['interfaces']['wan']['ipaddr']))
234
		services_dnsupdate_process();
235

    
236
	/* start DHCP service */
237
	services_dhcpd_configure();
238

    
239
	/* start DHCP relay */
240
	services_dhcrelay_configure();
241

    
242
	/* start proxy ARP service */
243
	services_proxyarp_configure();
244

    
245
	/* setup pppoe and pptp */
246
	vpn_setup();
247

    
248
	/* start the captive portal */
249
	captiveportal_configure();
250

    
251
	/* run any shell commands specified in config.xml */
252
	system_do_shell_commands();
253

    
254
	/* setup polling */
255
	setup_polling();
256

    
257
	/* setup interface microcode which improves tcp/ip speed */
258
	echo "Setting up microcode and tx/rx offloading...";
259
	setup_microcode();
260
	echo "done.\n";
261

    
262
	mwexec("/sbin/pfctl -f /tmp/rules.debug");
263

    
264
	/* start IPsec tunnels */
265
	vpn_ipsec_configure();
266

    
267
	/* start ftp proxy helpers if they are enabled */
268
	echo "Starting FTP helpers...";
269
	system_start_ftp_helpers();
270
	echo "done.\n";
271

    
272
	interfaces_carp_bring_up_final();
273

    
274
	/* start SNMP service */
275
	services_snmpd_configure();
276

    
277
	/* power down hard drive if needed/set */
278
	system_set_harddisk_standby();
279

    
280
	/* lock down console if necessary */
281
	if(isset($config['system']['disableconsolemenu']))
282
		touch("/var/etc/console_lockdown");
283

    
284
	filter_configure();
285

    
286
	/* load graphing functions */
287
	enable_rrd_graphing();
288

    
289
	/*   start DHCP service again now that CARP has settled
290
	 *   incase user is using primary/backup failover dhcp mode
291
         */
292
	services_dhcpd_configure();
293

    
294
	/* startup OLSR if needed */
295
	setup_wireless_olsr();
296

    
297
	/* startup routed if needed */
298
	include_once("/usr/local/pkg/routed/routed.inc");
299
	setup_routed();
300

    
301
	/* enable watchdog if supported */
302
	enable_watchdog();
303

    
304
	/* start the NTP client */
305
	echo "Starting OpenNTP time client...";
306
	system_ntp_configure();
307
	echo "done.\n";
308

    
309
	/* if <system><afterbootupshellcmd> exists, execute the command */
310
	if($config['system']['afterbootupshellcmd'] <> "")
311
		mwexec($config['system']['afterbootupshellcmd']);
312

    
313
	if($avail < 126) {
314
		require_once("/etc/inc/notices.inc");
315
		file_notice("pfSenseMemoryRequirements", "pfSense requires atleast 128 megabytes of RAM.  Expect unusual performance.  This platform is not supported.", "Memory", "", 1);
316
		mwexec("sysctl net.inet.tcp.recvspace=4096");
317
		mwexec("sysctl net.inet.tcp.sendspace=4096");
318
	}
319

    
320
	upnp_start();
321

    
322
	/* done */
323
	unlink("{$g['varrun_path']}/booting");
324
	$g['booting'] = FALSE;
325

    
326
?>
(26-26/76)