Project

General

Profile

Download (5.95 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
	echo "Loading configuration... ";
53
	parse_config_bootup();
54
	echo "done.\n";
55

    
56
	$lan_if = $config['interfaces']['lan']['if'];
57
	$wan_if = get_real_wan_interface();
58

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

    
84
	/* convert config and clean backups */
85
	echo "Updating configuration... ";
86
	convert_config();
87
	echo "done.\n";
88

    
89
	echo "Cleaning backup cache... ";
90
	cleanup_backupcache(true);
91
	echo "done.\n";
92
	
93
	/* read in /etc/sysctl.conf and set values if needed */
94
	system_setup_sysctl();
95

    
96
	/* run any early shell commands specified in config.xml */
97
	system_do_shell_commands(1);
98

    
99
	/* save dmesg output to file */
100
	system_dmesg_save();
101

    
102
	/* set up our timezone */
103
	system_timezone_configure();
104

    
105
	/* set up our hostname */
106
	system_hostname_configure();
107

    
108
	/* make hosts file */
109
	system_hosts_generate();
110

    
111
	/* generate resolv.conf */
112
	system_resolvconf_generate();
113

    
114
	/* configure loopback interface */
115
	interfaces_loopback_configure();
116

    
117
	/* start devd (dhclient now uses it */
118
	start_devd();
119

    
120
	/* set up VLAN virtual interfaces */
121
	interfaces_vlan_configure();
122

    
123
	/* set up LAN interface */
124
	echo "Configuring LAN interface... ";
125
	mute_kernel_msgs();
126
	interfaces_lan_configure();
127
	unmute_kernel_msgs();
128
	echo "done.\n";
129

    
130
	/* set up WAN interface */
131
	echo "Configuring WAN interface... ";
132
	mute_kernel_msgs();
133
	interfaces_wan_configure();
134
	unmute_kernel_msgs();
135
	echo "done.\n";
136

    
137
	/* set up Optional interfaces */
138
	echo "Configuring OPT interfaces... ";
139
	mute_kernel_msgs();
140
	interfaces_optional_configure();
141
	unmute_kernel_msgs();
142
	echo "done.\n";
143

    
144
	/* start pflog */
145
	filter_pflog_start();
146
	
147
	/* bring up carp interfaces */
148
	interfaces_carp_bringup();
149
	
150
	/* setup altq + pf */
151
	echo "Configuring firewall... ";
152
	//mute_kernel_msgs();
153
	filter_configure_sync();
154
	//unmute_kernel_msgs();
155
	echo "done.\n";
156

    
157
	/* start OpenVPN server & clients */
158
	ovpn_configure();
159

    
160
	/* set up static routes */
161
	system_routing_configure();
162

    
163
	/* enable routing */
164
	system_routing_enable();
165

    
166
	/* start syslogd */
167
	system_syslogd_start();
168

    
169
	/* start web server */
170
	system_webgui_start();
171
	
172
	/* ensure passwords are sync'd */
173
	system_password_configure();
174

    
175
	/* configure console menu */
176
	system_console_configure();
177

    
178
	/* start dnsmasq service */
179
	services_dnsmasq_configure();
180

    
181
	/* start dyndns service */
182
	services_dyndns_configure();
183

    
184
	/* start DHCP service */
185
	services_dhcpd_configure();
186

    
187
	/* start SNMP service */
188
	services_snmpd_configure();
189

    
190
	/* start proxy ARP service */
191
	services_proxyarp_configure();
192

    
193
	/* start the NTP client */
194
	system_ntp_configure();
195

    
196
	/* start pptpd */
197
	vpn_pptpd_configure();
198

    
199
	/* start pppoe server */
200
	vpn_pppoe_configure();
201

    
202
	/* start the captive portal */
203
	captiveportal_configure();
204

    
205
	/* execute the rc scripts of extensions */
206
	system_do_extensions();
207

    
208
	/* run any shell commands specified in config.xml */
209
	system_do_shell_commands();
210

    
211
	/* start ftp proxy helpers if they are enabled */
212
	echo "Starting FTP helpers... ";
213
	system_start_ftp_helpers();
214
	echo "done.\n";
215

    
216
	/* setup interface microcode which improves tcp/ip speed */
217
	mute_kernel_msgs();
218
	setup_microcode();
219
	unmute_kernel_msgs();
220

    
221
	/* setup carp interfaces */
222
	interfaces_carp_configure();
223
	
224
	mwexec("/sbin/pfctl -f /tmp/rules.debug");
225
	
226
	/* start IPsec tunnels */
227
	vpn_ipsec_configure();
228

    
229
	/* start load balancer daemon */
230
	slbd_configure();
231

    
232
	/* done */
233
	unlink("{$g['varrun_path']}/booting");
234
	$g['booting'] = FALSE;
235

    
236
?>
(24-24/59)