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

rc: further boot rework

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