Commit 88aab655 authored by Franco Fichtner's avatar Franco Fichtner

rc: further boot rework

parent b234d36f
......@@ -382,19 +382,28 @@ function system_hosts_generate()
unbound_hosts_generate();
}
function system_hostname_configure()
function system_hostname_configure($verbose = false)
{
global $config;
if ($verbose) {
echo 'Setting hostname: ';
flush();
}
$syscfg = $config['system'];
$hostname = "{$syscfg['hostname']}.{$syscfg['domain']}";
/* set hostname */
$status = mwexecf('/bin/hostname %s', "{$syscfg['hostname']}.{$syscfg['domain']}");
mwexecf('/bin/hostname %s', $hostname);
/* Setup host GUID ID. This is used by ZFS. */
mwexec("/etc/rc.d/hostid start");
return $status;
if ($verbose) {
echo "{$hostname}\n";
}
}
function system_routing_configure($interface = '')
......@@ -698,17 +707,17 @@ function system_syslogd_start($verbose = false)
{
global $config, $g;
if ($verbose) {
echo 'Starting syslog...';
flush();
}
configd_run('template reload OPNsense/Syslog');
mwexec('/etc/rc.d/hostid start');
$syslogcfg = $config['syslog'];
if ($verbose) {
echo 'Starting syslog...';
flush();
}
$log_directive = '%';
$syslogd_extra = '';
......@@ -1273,10 +1282,15 @@ EOD;
return 0;
}
function system_firmware_configure()
function system_firmware_configure($verbose = false)
{
global $config;
if ($verbose) {
echo 'Writing firmware setting...';
flush();
}
/* rewrite the config via the defaults */
$origin_conf = '/usr/local/etc/pkg/repos/origin.conf';
copy("${origin_conf}.sample", $origin_conf);
......@@ -1306,6 +1320,10 @@ function system_firmware_configure()
array('-sn', str_replace('/', '\/', $osabi . $config['system']['firmware']['flavour']))
);
}
if ($verbose) {
echo "done.\n";
}
}
function system_timezone_configure($verbose = false)
......@@ -1359,10 +1377,19 @@ function system_reboot($sync = false)
}
}
function system_setup_sysctl()
function system_sysctl_configure($verbose = false)
{
if ($verbose) {
echo 'Setting up extended sysctls...';
flush();
}
activate_sysctls();
system_arp_wrong_if();
if ($verbose) {
echo "done.\n";
}
}
function system_arp_wrong_if()
......
......@@ -30,31 +30,32 @@
*/
/* looks weird, but means we started PHP successfully */
echo " done.\n";
echo "done.\n";
echo "Initializing...";
require_once("config.inc");
echo ".";
require_once("config.console.inc");
echo ".";
require_once("auth.inc");
echo ".";
require_once("util.inc");
echo ".";
require_once("interfaces.inc");
echo ".";
require_once("services.inc");
echo ".";
require_once("system.inc");
echo ".";
require_once("filter.inc");
echo ".";
require_once("ipsec.inc");
echo ".";
require_once("openvpn.inc");
echo ".";
require_once("rrd.inc");
echo " done.\n";
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";
system_devd_configure(true);
system_login_configure(true);
......@@ -95,20 +96,10 @@ if (is_interface_mismatch()) {
}
system_kernel_configure(true);
/* read in /etc/sysctl.conf and set values if needed */
echo "Setting up extended sysctls...";
system_setup_sysctl();
echo "done.\n";
/* set up our timezone */
system_sysctl_configure(true);
system_timezone_configure(true);
/* set up firmware configuration */
system_firmware_configure();
/* set up our hostname */
system_hostname_configure();
system_firmware_configure(true);
system_hostname_configure(true);
/* make hosts file */
system_hosts_generate();
......
......@@ -74,7 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
header(url_safe('Location: /system_advanced_sysctl.php'));
exit;
} else if (!empty($pconfig['apply'])) {
system_setup_sysctl();
system_sysctl_configure();
clear_subsystem_dirty('sysctl');
header(url_safe('Location: /system_advanced_sysctl.php'));
exit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment