Project

General

Profile

Download (6.79 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) {
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 altq + pf */
175
	echo "Configuring firewall... ";
176
	//mute_kernel_msgs();
177
	filter_configure_sync();
178
	//unmute_kernel_msgs();
179
	echo "done.\n";
180

    
181
	/* start web server */
182
	system_webgui_start();
183

    
184
	/* start OpenVPN server & clients */
185
        ovpn_configure(false);
186

    
187
	/* set up static routes */
188
	system_routing_configure();
189

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

    
196
	/* configure console menu */
197
	system_console_configure();
198

    
199
	/* start dnsmasq service */
200
	services_dnsmasq_configure();
201

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

    
209
	/* start DHCP service */
210
	services_dhcpd_configure();
211

    
212
	/* start DHCP relay */
213
	services_dhcrelay_configure();
214

    
215
	/* start SNMP service */
216
	services_snmpd_configure();
217

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

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

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

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

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

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

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

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

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

    
252
	interfaces_carp_bring_up_final();
253

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

    
259
	/* power down hard drive if needed/set */
260
	system_set_harddisk_standby();
261

    
262
	/* lock down console if necessary */
263
	if(isset($config['system']['disableconsolemenu']))
264
		touch("/var/etc/console_lockdown");
265
	
266
	/* done */
267
	unlink("{$g['varrun_path']}/booting");
268
	$g['booting'] = FALSE;
269

    
270
?>
(26-26/65)