core/src/etc/rc.bootup
Franco Fichtner 09f45fbdbf system: rewrite the default route handling
With this, there is consistency in setting the default route
and associated marker file.  Nothing is done before the decision
is final, so we may not end up with a missing route after an
attempt to reconfigure for something that doesn't work anyway.

DHCPv4 and PPP still do this manually, but we will have to route
them through the same logic instead of them manually handling their
routes.  6rd and 6to4 may have a similar issue as well.

While here, swap the system_routing_configure() arguments to
align with the way other configure functions present their
arguments (verbose print flag first).

Gateway monitoring and default switching improvement since 2016.
Push $keep into default handling, it may be useful in general to
avoid spurious switches.  It could also be a default probably.
2018-03-16 07:41:17 +00:00

134 lines
3.9 KiB
PHP
Executable File

#!/usr/local/bin/php
<?php
/*
* Copyright (C) 2014-2018 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2004-2009 Scott Ullrich <sullrich@gmail.com>
* Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
* Copyright (C) 2009 Erik Kristensen <erik@erikkristensen.com>
* 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.
*/
/* looks weird, but means we started PHP successfully */
echo "done.\n";
echo "Initializing...";
flush();
$inc_files = array(
'config.inc',
'console.inc',
'auth.inc',
'util.inc',
'interfaces.inc',
'services.inc',
'system.inc',
'filter.inc',
'rrd.inc',
);
foreach ($inc_files as $inc_file) {
require_once $inc_file;
echo '.';
flush();
}
echo "done.\n";
/*
* If this was an import or restore or reset, once run
* the migration, but do not display the status here as
* otherwise this prints all the models that keep their
* current version level.
*/
convert_config();
/*
* Now mute console messages from kernel for this script, it
* has consequences for printing bootup info and can clobber
* stty probing during interface auto-detection.
*/
system_console_mute();
system_devd_configure(true);
system_login_configure(true);
/*
* Determine if we need to throw an interface exception
* and ask the user to reassign interfaces. This will
* avoid a reboot and thats a good thing.
*/
if (is_interface_mismatch()) {
echo "\nDefault interfaces not found -- Running interface assignment option.\n";
while (!set_networking_interfaces_ports(true));
}
/* loopback device is required early for syslog */
interfaces_loopback_configure(true);
system_kernel_configure(true);
system_sysctl_configure(true);
system_timezone_configure(true);
system_firmware_configure(true);
system_hostname_configure(true);
system_hosts_generate(true);
system_syslogd_start(true);
openvpn_prepare_all(true);
interfaces_configure(true);
system_resolvconf_generate(true);
filter_configure_sync(true);
filter_pflog_start(true);
setup_gateways_monitor(true);
plugins_configure('earlybootup', true);
system_cron_configure(true, true);
system_routing_configure(true);
plugins_configure('dns', true);
services_dhcpd_configure('all', array(), true);
system_hosts_generate(true);
services_dhcrelay_configure(true);
services_dhcrelay6_configure(true);
prefer_ipv4_or_ipv6();
plugins_configure('vpn', true);
filter_configure_sync(true);
plugins_configure('bootup', true);
rrd_configure(true);
/* XXX this seems misplaced */
system_powerd_configure(true);
/*
* Give syslogd a kick after everything else has been
* initialized, otherwise it can occasionally fail to
* route syslog messages properly on both IPv4 and IPv6.
*/
system_syslogd_start(true);
system_console_unmute();
exit(0);