Commit 8060cea0 authored by Franco Fichtner's avatar Franco Fichtner

rc: more $verbose conversion

(cherry picked from commit 7c65a076)
(cherry picked from commit 88aab655)
(cherry picked from commit d4fe7fbc)
parent 94f8a0bb
...@@ -92,8 +92,13 @@ function load_config_from_file($filename) ...@@ -92,8 +92,13 @@ function load_config_from_file($filename)
* RESULT * RESULT
* $config - array containing all configuration variables * $config - array containing all configuration variables
******/ ******/
function parse_config() function parse_config($verbose = false)
{ {
if ($verbose) {
echo 'Loading configuration...';
flush();
}
$cnf = OPNsense\Core\Config::getInstance(); $cnf = OPNsense\Core\Config::getInstance();
// return config data as array, use old "listags" construction to mark certain elements as array (even if they're not recurring) // return config data as array, use old "listags" construction to mark certain elements as array (even if they're not recurring)
...@@ -102,6 +107,10 @@ function parse_config() ...@@ -102,6 +107,10 @@ function parse_config()
/* make alias table (for faster lookups) */ /* make alias table (for faster lookups) */
alias_make_table($config); alias_make_table($config);
if ($verbose) {
echo "done.\n";
}
return $config; return $config;
} }
...@@ -290,24 +299,6 @@ function cleanup_backups() ...@@ -290,24 +299,6 @@ function cleanup_backups()
} }
} }
function set_device_perms() {
$devices = array(
'pf' => array( 'user' => 'root',
'group' => 'proxy',
'mode' => 0660),
);
foreach ($devices as $name => $attr) {
$path = "/dev/$name";
if (file_exists($path)) {
chown($path, $attr['user']);
chgrp($path, $attr['group']);
chmod($path, $attr['mode']);
}
}
}
function make_config_revision_entry($desc = '') function make_config_revision_entry($desc = '')
{ {
global $config; global $config;
......
...@@ -376,19 +376,28 @@ function system_hosts_generate() ...@@ -376,19 +376,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 = '')
...@@ -692,17 +701,17 @@ function system_syslogd_start($verbose = false) ...@@ -692,17 +701,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 = '';
...@@ -1267,10 +1276,15 @@ EOD; ...@@ -1267,10 +1276,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);
...@@ -1300,6 +1314,10 @@ function system_firmware_configure() ...@@ -1300,6 +1314,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)
...@@ -1353,10 +1371,19 @@ function system_reboot($sync = false) ...@@ -1353,10 +1371,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()
...@@ -1470,6 +1497,22 @@ function system_kernel_configure($verbose = false) ...@@ -1470,6 +1497,22 @@ function system_kernel_configure($verbose = false)
} }
} }
function system_devd_configure($verbose = false)
{
if ($verbose) {
echo 'Starting device manager...';
flush();
}
exec('/sbin/devd');
/* historic sleep */
sleep(1);
if ($verbose) {
echo "done.\n";
}
}
function system_cron_configure($verbose = false) function system_cron_configure($verbose = false)
{ {
global $config; global $config;
...@@ -1605,10 +1648,15 @@ function system_console_types() ...@@ -1605,10 +1648,15 @@ function system_console_types()
); );
} }
function system_login_configure() function system_login_configure($verbose = false)
{ {
global $config; global $config;
if ($verbose) {
echo 'Configuring login behaviour...';
flush();
}
configd_run('template reload OPNsense/Auth'); configd_run('template reload OPNsense/Auth');
$serialspeed = (!empty($config['system']['serialspeed']) && is_numeric($config['system']['serialspeed'])) ? $config['system']['serialspeed'] : '115200'; $serialspeed = (!empty($config['system']['serialspeed']) && is_numeric($config['system']['serialspeed'])) ? $config['system']['serialspeed'] : '115200';
...@@ -1701,6 +1749,11 @@ function system_login_configure() ...@@ -1701,6 +1749,11 @@ function system_login_configure()
} }
fclose($fd); fclose($fd);
if ($verbose) {
echo "done\n";
flush();
}
/* force init(8) to reload /etc/ttys */ /* force init(8) to reload /etc/ttys */
exec('/bin/kill -HUP 1'); exec('/bin/kill -HUP 1');
} }
......
...@@ -30,43 +30,35 @@ ...@@ -30,43 +30,35 @@
*/ */
/* 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";
/* start devd (dhclient now uses it) */
echo "Starting device manager (devd)...";
system_console_mute();
exec('/sbin/devd');
sleep(1);
set_device_perms();
system_console_unmute();
echo "done.\n"; echo "done.\n";
/* configure login behaviour */ system_devd_configure(true);
system_login_configure(); system_login_configure(true);
$setup_installer = is_install_media(); $setup_installer = is_install_media();
if ($setup_installer) { if ($setup_installer) {
...@@ -89,11 +81,9 @@ if ($setup_installer) { ...@@ -89,11 +81,9 @@ if ($setup_installer) {
OPNsense\Core\Config::getInstance()->forceReload(); OPNsense\Core\Config::getInstance()->forceReload();
} }
echo "Loading configuration...";
global $config; global $config;
$config = parse_config(); $config = parse_config(true);
convert_config(); convert_config();
echo "done.\n";
/* /*
* Determine if we need to throw a interface exception * Determine if we need to throw a interface exception
...@@ -106,20 +96,10 @@ if (is_interface_mismatch()) { ...@@ -106,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