Project

General

Profile

Download (6.64 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
	/* run any early shell commands specified in config.xml */
112
	system_do_shell_commands(1);
113

    
114
	/* save dmesg output to file */
115
	system_dmesg_save();
116

    
117
	/* set up our timezone */
118
	system_timezone_configure();
119

    
120
	/* set up our hostname */
121
	system_hostname_configure();
122

    
123
	/* make hosts file */
124
	system_hosts_generate();
125

    
126
	/* generate resolv.conf */
127
	system_resolvconf_generate();
128

    
129
	/* configure loopback interface */
130
	interfaces_loopback_configure();
131

    
132
	/* start syslogd */
133
	system_syslogd_start();
134

    
135
	/* set up VLAN virtual interfaces */
136
	interfaces_vlan_configure();
137

    
138
	/* set up LAN interface */
139
	echo "Configuring LAN interface... ";
140
	mute_kernel_msgs();
141
	interfaces_lan_configure();
142
	unmute_kernel_msgs();
143
	echo "done.\n";
144

    
145
	/* set up WAN interface */
146
	echo "Configuring WAN interface... ";
147
	mute_kernel_msgs();
148
	interfaces_wan_configure();
149
	unmute_kernel_msgs();
150
	echo "done.\n";
151

    
152
	/* set up Optional interfaces */
153
	echo "Configuring OPT interfaces... ";
154
	if(!$debugging)
155
		mute_kernel_msgs();
156
	interfaces_optional_configure();
157
	if(!$debugging) 
158
		unmute_kernel_msgs();
159
	echo "done.\n";
160

    
161
	/* generate resolv.conf */
162
	system_resolvconf_generate();
163

    
164
	/* start pflog */
165
	filter_pflog_start();
166
	
167
	/* bring up carp interfaces */
168
	interfaces_carp_configure();
169
	
170
	/* setup altq + pf */
171
	echo "Configuring firewall... ";
172
	//mute_kernel_msgs();
173
	filter_configure_sync();
174
	//unmute_kernel_msgs();
175
	echo "done.\n";
176

    
177
	/* start web server */
178
	system_webgui_start();
179

    
180
	/* start OpenVPN server & clients */
181
        ovpn_configure(false);
182

    
183
	/* set up static routes */
184
	system_routing_configure();
185

    
186
	/* enable routing */
187
	system_routing_enable();
188
	
189
	/* ensure passwords are sync'd */
190
	system_password_configure();
191

    
192
	/* configure console menu */
193
	system_console_configure();
194

    
195
	/* start dnsmasq service */
196
	services_dnsmasq_configure();
197

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

    
205
	/* start DHCP service */
206
	services_dhcpd_configure();
207

    
208
	/* start DHCP relay */
209
	services_dhcrelay_configure();
210

    
211
	/* start SNMP service */
212
	services_snmpd_configure();
213

    
214
	/* start proxy ARP service */
215
	services_proxyarp_configure();
216

    
217
	/* start the NTP client */
218
	system_ntp_configure();
219

    
220
	/* start pptpd */
221
	vpn_pptpd_configure();
222

    
223
	/* start pppoe server */
224
	vpn_pppoe_configure();
225

    
226
	/* start the captive portal */
227
	captiveportal_configure();
228

    
229
	/* run any shell commands specified in config.xml */
230
	system_do_shell_commands();
231

    
232
	/* start ftp proxy helpers if they are enabled */
233
	echo "Starting FTP helpers... ";
234
	system_start_ftp_helpers();
235
	echo "done.\n";
236

    
237
	/* setup interface microcode which improves tcp/ip speed */
238
	mute_kernel_msgs();
239
	setup_microcode();
240
	unmute_kernel_msgs();
241
	
242
	mwexec("/sbin/pfctl -f /tmp/rules.debug");
243
	
244
	/* start IPsec tunnels */
245
	vpn_ipsec_configure();
246

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

    
250
	interfaces_carp_bring_up_final();
251

    
252
	/* power down hard drive if needed/set */
253
	system_set_harddisk_standby();
254

    
255
	/* lock down console if necessary */
256
	if(isset($config['system']['disableconsolemenu']))
257
		touch("/var/etc/console_lockdown");
258
	
259
	/* done */
260
	unlink("{$g['varrun_path']}/booting");
261
	$g['booting'] = FALSE;
262

    
263
?>
(25-25/63)