mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
271 lines
6.8 KiB
PHP
Executable File
271 lines
6.8 KiB
PHP
Executable File
#!/usr/local/bin/php -f
|
|
<?php
|
|
/* $Id$ */
|
|
/*
|
|
rc.bootup
|
|
part of pfSense by Scott Ullrich
|
|
originally based on m0n0wall (http://m0n0.ch/wall)
|
|
|
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
|
All rights reserved.
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright notice,
|
|
this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
notice, this list of conditions and the following disclaimer in the
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
require_once("globals.inc");
|
|
require_once("pfsense-utils.inc");
|
|
|
|
/* let the other functions know we're booting */
|
|
$pkg_interface = 'console';
|
|
$g['booting'] = TRUE;
|
|
touch("{$g['varrun_path']}/booting");
|
|
|
|
if($g['platform'] == "cdrom") {
|
|
$motd = trim(file_get_contents("/etc/motd"));
|
|
if(strlen($motd) > 2) echo "\n{$motd}\n\n";
|
|
}
|
|
|
|
/* parse the configuration and include all functions used below */
|
|
require_once("config.inc");
|
|
|
|
require_once("functions.inc");
|
|
|
|
/* start devd (dhclient now uses it */
|
|
echo "Starting device manager (devd)... ";
|
|
mute_kernel_msgs();
|
|
start_devd();
|
|
unmute_kernel_msgs();
|
|
echo "done.\n";
|
|
|
|
echo "Loading configuration... ";
|
|
parse_config_bootup();
|
|
echo "done.\n";
|
|
|
|
$lan_if = $config['interfaces']['lan']['if'];
|
|
$wan_if = get_real_wan_interface();
|
|
|
|
/*
|
|
* Determine if we need to throw a interface exception
|
|
* and ask the user to reassign interfaces. This will
|
|
* avoid a reboot and thats a good thing.
|
|
*/
|
|
$do_assign = 0;
|
|
/* we need to ignore the vlan interface checks) */
|
|
if(stristr($lan_if,"vlan") == false and stristr($wan_if,"vlan") == false) {
|
|
if(does_interface_exist($lan_if) == false) {
|
|
echo "\n\n\nLAN {$lan_if} interface mismatch.";
|
|
$do_assign = 1;
|
|
}
|
|
if($config['interfaces']['wan']['ipaddr'] <> "pppoe" && $config['interfaces']['wan']['ipaddr'] <> "pptp" && $do_assign == 0) {
|
|
if(does_interface_exist($wan_if) == false) {
|
|
echo "\n\n\nWAN {$wan_if} interface mismatch.";
|
|
$do_assign = 1;
|
|
}
|
|
}
|
|
if($do_assign == 1) {
|
|
$noreboot = true;
|
|
echo " -- Running interface assignment option.\n";
|
|
set_networking_interfaces_ports();
|
|
}
|
|
}
|
|
unmute_kernel_msgs();
|
|
|
|
/* convert config and clean backups */
|
|
echo "Updating configuration... ";
|
|
convert_config();
|
|
echo "done.\n";
|
|
|
|
echo "Cleaning backup cache... ";
|
|
cleanup_backupcache(true);
|
|
echo "done.\n";
|
|
|
|
/* read in /etc/sysctl.conf and set values if needed */
|
|
echo "Setting up extended sysctls... ";
|
|
system_setup_sysctl();
|
|
echo "done.\n";
|
|
|
|
/* sync user passwords */
|
|
echo "Syncing user passwords... ";
|
|
sync_webgui_passwords();
|
|
echo "done.\n";
|
|
|
|
echo "Starting Secure Shell Services... ";
|
|
mwexec_bg("/etc/sshd");
|
|
echo "done.\n";
|
|
|
|
/* run any early shell commands specified in config.xml */
|
|
system_do_shell_commands(1);
|
|
|
|
/* save dmesg output to file */
|
|
system_dmesg_save();
|
|
|
|
/* set up our timezone */
|
|
system_timezone_configure();
|
|
|
|
/* set up our hostname */
|
|
system_hostname_configure();
|
|
|
|
/* make hosts file */
|
|
system_hosts_generate();
|
|
|
|
/* generate resolv.conf */
|
|
system_resolvconf_generate();
|
|
|
|
/* configure loopback interface */
|
|
interfaces_loopback_configure();
|
|
|
|
/* start syslogd */
|
|
system_syslogd_start();
|
|
|
|
/* set up VLAN virtual interfaces */
|
|
interfaces_vlan_configure();
|
|
|
|
/* set up LAN interface */
|
|
echo "Configuring LAN interface... ";
|
|
mute_kernel_msgs();
|
|
interfaces_lan_configure();
|
|
unmute_kernel_msgs();
|
|
echo "done.\n";
|
|
|
|
/* set up WAN interface */
|
|
echo "Configuring WAN interface... ";
|
|
mute_kernel_msgs();
|
|
interfaces_wan_configure();
|
|
unmute_kernel_msgs();
|
|
echo "done.\n";
|
|
|
|
/* set up Optional interfaces */
|
|
echo "Configuring OPT interfaces... ";
|
|
if(!$debugging)
|
|
mute_kernel_msgs();
|
|
interfaces_optional_configure();
|
|
if(!$debugging)
|
|
unmute_kernel_msgs();
|
|
echo "done.\n";
|
|
|
|
/* generate resolv.conf */
|
|
system_resolvconf_generate();
|
|
|
|
/* start pflog */
|
|
filter_pflog_start();
|
|
|
|
/* bring up carp interfaces */
|
|
interfaces_carp_configure();
|
|
|
|
/* setup altq + pf */
|
|
echo "Configuring firewall... ";
|
|
//mute_kernel_msgs();
|
|
filter_configure_sync();
|
|
//unmute_kernel_msgs();
|
|
echo "done.\n";
|
|
|
|
/* start web server */
|
|
system_webgui_start();
|
|
|
|
/* start OpenVPN server & clients */
|
|
ovpn_configure(false);
|
|
|
|
/* set up static routes */
|
|
system_routing_configure();
|
|
|
|
/* enable routing */
|
|
system_routing_enable();
|
|
|
|
/* ensure passwords are sync'd */
|
|
system_password_configure();
|
|
|
|
/* configure console menu */
|
|
system_console_configure();
|
|
|
|
/* start dnsmasq service */
|
|
services_dnsmasq_configure();
|
|
|
|
/* start dyndns service */
|
|
services_dyndns_configure();
|
|
|
|
/* static IP address? -> attempt DNS update */
|
|
if (is_ipaddr($config['interfaces']['wan']['ipaddr']))
|
|
services_dnsupdate_process();
|
|
|
|
/* start DHCP service */
|
|
services_dhcpd_configure();
|
|
|
|
/* start DHCP relay */
|
|
services_dhcrelay_configure();
|
|
|
|
/* start SNMP service */
|
|
services_snmpd_configure();
|
|
|
|
/* start proxy ARP service */
|
|
services_proxyarp_configure();
|
|
|
|
/* start the NTP client */
|
|
system_ntp_configure();
|
|
|
|
/* start pptpd */
|
|
vpn_pptpd_configure();
|
|
|
|
/* start pppoe server */
|
|
vpn_pppoe_configure();
|
|
|
|
/* start the captive portal */
|
|
captiveportal_configure();
|
|
|
|
/* run any shell commands specified in config.xml */
|
|
system_do_shell_commands();
|
|
|
|
/* setup polling */
|
|
setup_polling();
|
|
|
|
/* start ftp proxy helpers if they are enabled */
|
|
echo "Starting FTP helpers... ";
|
|
system_start_ftp_helpers();
|
|
echo "done.\n";
|
|
|
|
/* setup interface microcode which improves tcp/ip speed */
|
|
mute_kernel_msgs();
|
|
setup_microcode();
|
|
unmute_kernel_msgs();
|
|
|
|
mwexec("/sbin/pfctl -f /tmp/rules.debug");
|
|
|
|
/* start IPsec tunnels */
|
|
vpn_ipsec_configure();
|
|
|
|
/* start load balancer daemon */
|
|
slbd_configure();
|
|
|
|
interfaces_carp_bring_up_final();
|
|
|
|
/* power down hard drive if needed/set */
|
|
system_set_harddisk_standby();
|
|
|
|
/* lock down console if necessary */
|
|
if(isset($config['system']['disableconsolemenu']))
|
|
touch("/var/etc/console_lockdown");
|
|
|
|
/* done */
|
|
unlink("{$g['varrun_path']}/booting");
|
|
$g['booting'] = FALSE;
|
|
|
|
?>
|