mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
206 lines
5.8 KiB
PHP
Executable File
206 lines
5.8 KiB
PHP
Executable File
#!/usr/local/bin/php
|
|
<?php
|
|
|
|
/*
|
|
Copyright (C) 2014-2016 Franco Fichtner <franco@opnsense.org>
|
|
Copyright (C) 2004-2009 Scott Ullrich <sullrich@pfsense.org>.
|
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
|
Copyright (C) 2009 Erik Kristensen
|
|
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',
|
|
'config.console.inc',
|
|
'auth.inc',
|
|
'util.inc',
|
|
'interfaces.inc',
|
|
'services.inc',
|
|
'system.inc',
|
|
'filter.inc',
|
|
'ipsec.inc',
|
|
'openvpn.inc',
|
|
'rrd.inc',
|
|
);
|
|
|
|
foreach ($inc_files as $inc_file) {
|
|
require_once $inc_file;
|
|
echo '.';
|
|
flush();
|
|
}
|
|
|
|
echo "done.\n";
|
|
|
|
/*
|
|
* 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();
|
|
|
|
/* loopback device is required early for syslog and the installer */
|
|
interfaces_loopback_configure(true);
|
|
|
|
$setup_installer = is_install_media();
|
|
if ($setup_installer) {
|
|
echo 'Press any key to start the early installer: ';
|
|
|
|
$key = timeout();
|
|
if ($key != "\n") {
|
|
echo "\n";
|
|
}
|
|
|
|
if (isset($key)) {
|
|
passthru('/usr/local/etc/rc.installer');
|
|
if (file_exists('/tmp/install_complete')) {
|
|
passthru('/usr/local/etc/rc.reboot');
|
|
exit;
|
|
}
|
|
}
|
|
|
|
/* config may have changed via installer import */
|
|
OPNsense\Core\Config::getInstance()->forceReload();
|
|
}
|
|
|
|
global $config;
|
|
$config = parse_config(true);
|
|
convert_config();
|
|
|
|
system_devd_configure(true);
|
|
system_login_configure(true);
|
|
|
|
/*
|
|
* 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.
|
|
*/
|
|
if (is_interface_mismatch()) {
|
|
echo "\nDefault interfaces not found -- Running interface assignment option.\n";
|
|
while (!set_networking_interfaces_ports(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);
|
|
openvpn_resync_all(null, true);
|
|
|
|
system_resolvconf_generate(true);
|
|
filter_configure_sync(true);
|
|
filter_pflog_start(true);
|
|
setup_gateways_monitor(true);
|
|
local_sync_accounts(true);
|
|
system_webgui_configure(true);
|
|
system_cron_configure(true);
|
|
system_routing_configure('', true);
|
|
|
|
dnsmasq_configure_do(true);
|
|
unbound_configure_do(true);
|
|
services_dhcpd_configure('all', array(), true);
|
|
system_hosts_generate(true);
|
|
services_dhcrelay_configure(true);
|
|
services_dhcrelay6_configure(true);
|
|
|
|
mwexec("/usr/local/etc/rc.sshd"); /* XXX convert to plugin */
|
|
mwexec("/usr/local/etc/rc.dyndns.update"); /* XXX convert to plugin */
|
|
|
|
prefer_ipv4_or_ipv6();
|
|
filter_configure_sync(true);
|
|
|
|
if (function_exists('plugins_configure')) {
|
|
plugins_configure('bootup', true);
|
|
}
|
|
|
|
/* start IPsec tunnels */
|
|
$ipsec_dynamic_hosts = ipsec_configure(true);
|
|
|
|
enable_rrd_graphing(true);
|
|
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);
|
|
|
|
/* If there are ipsec dynamic hosts try again to reload the tunnels as rc.newipsecdns does */
|
|
if ($ipsec_dynamic_hosts) {
|
|
ipsec_configure(true);
|
|
}
|
|
|
|
// generate configuration data for all installed templates
|
|
configd_run('template reload *');
|
|
|
|
if ($setup_installer) {
|
|
/*
|
|
* Installer mode requires setting up an extra user and
|
|
* we will protect it with root's password. We can only
|
|
* do this if user does not exist, though.
|
|
*/
|
|
|
|
$root = null;
|
|
|
|
if (isset($config['system']['user'])) {
|
|
foreach ($config['system']['user'] as $user) {
|
|
if ($user['name'] == 'installer') {
|
|
$root = null;
|
|
break;
|
|
}
|
|
if ($user['uid'] == 0) {
|
|
$root = $user;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($root) {
|
|
$root['shell'] = '/usr/local/etc/rc.installer';
|
|
$root['name'] = 'installer';
|
|
local_user_set($root, true);
|
|
|
|
mwexec("/usr/local/etc/rc.sshd installer");
|
|
|
|
echo "\n";
|
|
echo "Welcome! Both `root' and `installer' users are availabe for system\n";
|
|
echo "setup or invoking the installer, respectively. The predefined root\n";
|
|
echo "password works for both accounts. Remote login via SSH is possible.\n\n";
|
|
}
|
|
}
|
|
|
|
system_console_unmute();
|
|
|
|
exit(0);
|