Project

General

Profile

Download (7.05 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
	require_once("globals.inc");
35
	require_once("pfsense-utils.inc");
36

    
37
	/* let the other functions know we're booting */
38
	$pkg_interface = 'console';
39
	$g['booting'] = TRUE;
40
	touch("{$g['varrun_path']}/booting");
41

    
42
	if($g['platform'] == "cdrom") {
43
		$motd = trim(file_get_contents("/etc/motd"));
44
		if(strlen($motd) > 2) echo "\n{$motd}\n\n";
45
	}
46

    
47
	/* parse the configuration and include all functions used below */
48
	require_once("config.inc");
49
	
50
	require_once("functions.inc");
51

    
52
	/* start devd (dhclient now uses it */
53
	echo "Starting device manager (devd)... ";
54
	mute_kernel_msgs();
55
	start_devd();
56
	unmute_kernel_msgs();
57
	echo "done.\n";
58

    
59
	echo "Loading configuration... ";
60
	parse_config_bootup();
61
	echo "done.\n";
62

    
63
	$lan_if = $config['interfaces']['lan']['if'];
64
	$wan_if = get_real_wan_interface();
65

    
66
	/*
67
	 *  Determine if we need to throw a interface exception
68
         *  and ask the user to reassign interfaces.  This will
69
         *  avoid a reboot and thats a good thing.
70
	 */
71
	$do_assign = 0;
72
	/* we need to ignore the vlan interface checks) */
73
	if(stristr($lan_if,"vlan") == false and stristr($wan_if,"vlan") == false) {
74
		if(does_interface_exist($lan_if) == false) {
75
			echo "\n\n\nLAN {$lan_if} interface mismatch.";
76
			$do_assign = 1;
77
		}
78
		if($config['interfaces']['wan']['ipaddr'] <> "pppoe" && $config['interfaces']['wan']['ipaddr'] <> "pptp" && $do_assign == 0) {
79
			if(does_interface_exist($wan_if) == false) {
80
				echo "\n\n\nWAN {$wan_if} interface mismatch.";
81
				$do_assign = 1;
82
			}
83
		}
84
		if($do_assign == 1 and !file_exists("{$g['tmp_path']}/assign_complete")) {
85
			$noreboot = true;
86
			echo " -- Running interface assignment option.\n";
87
			set_networking_interfaces_ports();
88
		}
89
	}
90
	unmute_kernel_msgs();
91

    
92
	/* convert config and clean backups */
93
	echo "Updating configuration... ";
94
	convert_config();
95
	echo "done.\n";
96

    
97
	echo "Cleaning backup cache... ";
98
	cleanup_backupcache(true);
99
	echo "done.\n";
100
	
101
	/* read in /etc/sysctl.conf and set values if needed */
102
	echo "Setting up extended sysctls... ";
103
	system_setup_sysctl();
104
	echo "done.\n";
105

    
106
	/* sync user passwords */
107
	echo "Syncing user passwords... ";
108
	sync_webgui_passwords();
109
	echo "done.\n";
110

    
111
	echo "Starting Secure Shell Services... ";
112
	mwexec_bg("/etc/sshd");
113
	echo "done.\n";
114

    
115
	/* run any early shell commands specified in config.xml */
116
	system_do_shell_commands(1);
117

    
118
	/* save dmesg output to file */
119
	system_dmesg_save();
120

    
121
	/* set up our timezone */
122
	system_timezone_configure();
123

    
124
	/* set up our hostname */
125
	system_hostname_configure();
126

    
127
	/* make hosts file */
128
	system_hosts_generate();
129

    
130
	/* generate resolv.conf */
131
	system_resolvconf_generate();
132

    
133
	/* configure loopback interface */
134
	interfaces_loopback_configure();
135

    
136
	/* start syslogd */
137
	system_syslogd_start();
138

    
139
	/* set up VLAN virtual interfaces */
140
	interfaces_vlan_configure();
141

    
142
	/* set up LAN interface */
143
	echo "Configuring LAN interface... ";
144
	mute_kernel_msgs();
145
	interfaces_lan_configure();
146
	unmute_kernel_msgs();
147
	echo "done.\n";
148

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

    
156
	/* set up Optional interfaces */
157
	echo "Configuring OPT interfaces... ";
158
	if(!$debugging)
159
		mute_kernel_msgs();
160
	interfaces_optional_configure();
161
	if(!$debugging) 
162
		unmute_kernel_msgs();
163
	echo "done.\n";
164

    
165
	/* bring up carp interfaces */
166
	interfaces_carp_configure();
167

    
168
	/* generate resolv.conf */
169
	system_resolvconf_generate();
170

    
171
	/* start pflog */
172
	filter_pflog_start();
173

    
174
	setup_filter_bridge();
175
	
176
	/* setup altq + pf */
177
	echo "Configuring firewall... ";
178
	//mute_kernel_msgs();
179
	filter_configure_sync();
180
	//unmute_kernel_msgs();
181
	echo "done.\n";
182

    
183
	/* start web server */
184
	system_webgui_start();
185

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

    
189
	/* set up static routes */
190
	system_routing_configure();
191

    
192
	/* enable routing */
193
	system_routing_enable();
194
	
195
	/* ensure passwords are sync'd */
196
	system_password_configure();
197

    
198
	/* configure console menu */
199
	system_console_configure();
200

    
201
	/* start dnsmasq service */
202
	services_dnsmasq_configure();
203

    
204
	/* start dyndns service */
205
	services_dyndns_configure();
206
	
207
	/* static IP address? -> attempt DNS update */
208
	if (is_ipaddr($config['interfaces']['wan']['ipaddr']))
209
		services_dnsupdate_process();
210

    
211
	/* start DHCP service */
212
	services_dhcpd_configure();
213

    
214
	/* start DHCP relay */
215
	services_dhcrelay_configure();
216

    
217
	/* start proxy ARP service */
218
	services_proxyarp_configure();
219

    
220
	/* start the NTP client */
221
	system_ntp_configure();
222

    
223
	/* start pptpd */
224
	vpn_pptpd_configure();
225

    
226
	/* start pppoe server */
227
	vpn_pppoe_configure();
228

    
229
	/* start the captive portal */
230
	captiveportal_configure();
231

    
232
	/* run any shell commands specified in config.xml */
233
	system_do_shell_commands();
234

    
235
	/* setup polling */
236
	setup_polling();
237

    
238
	/* setup interface microcode which improves tcp/ip speed */
239
	echo "Setting up microcode and tx/rx offloading... ";
240
	setup_microcode();
241
	echo "done.\n";
242
		
243
	mwexec("/sbin/pfctl -f /tmp/rules.debug");
244
	
245
	/* start IPsec tunnels */
246
	vpn_ipsec_configure();
247

    
248
	/* start load balancer daemon */
249
	slbd_configure();
250

    
251
	/* start ftp proxy helpers if they are enabled */
252
	echo "Starting FTP helpers... ";
253
	system_start_ftp_helpers();
254
	echo "done.\n";
255

    
256
	interfaces_carp_bring_up_final();
257

    
258
	/* start SNMP service */
259
	services_snmpd_configure();
260

    
261
	/* power down hard drive if needed/set */
262
	system_set_harddisk_standby();
263

    
264
	/* lock down console if necessary */
265
	if(isset($config['system']['disableconsolemenu']))
266
		touch("/var/etc/console_lockdown");
267

    
268
	filter_configure();
269

    
270
	/*   start DHCP service again now that CARP has settled
271
	 *   incase user is using primary/backup failover dhcp mode
272
         */
273
	services_dhcpd_configure();
274
	
275
	/* done */
276
	unlink("{$g['varrun_path']}/booting");
277
	$g['booting'] = FALSE;
278

    
279
?>
(26-26/71)