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)
* RESULT
* $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();
// 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()
/* make alias table (for faster lookups) */
alias_make_table($config);
if ($verbose) {
echo "done.\n";
}
return $config;
}
......@@ -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 = '')
{
global $config;
......
......@@ -376,19 +376,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 = '')
......@@ -692,17 +701,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 = '';
......@@ -1267,10 +1276,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);
......@@ -1300,6 +1314,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)
......@@ -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();
system_arp_wrong_if();
if ($verbose) {
echo "done.\n";
}
}
function system_arp_wrong_if()
......@@ -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)
{
global $config;
......@@ -1605,10 +1648,15 @@ function system_console_types()
);
}
function system_login_configure()
function system_login_configure($verbose = false)
{
global $config;
if ($verbose) {
echo 'Configuring login behaviour...';
flush();
}
configd_run('template reload OPNsense/Auth');
$serialspeed = (!empty($config['system']['serialspeed']) && is_numeric($config['system']['serialspeed'])) ? $config['system']['serialspeed'] : '115200';
......@@ -1701,6 +1749,11 @@ function system_login_configure()
}
fclose($fd);
if ($verbose) {
echo "done\n";
flush();
}
/* force init(8) to reload /etc/ttys */
exec('/bin/kill -HUP 1');
}
......
......@@ -30,43 +30,35 @@
*/
/* 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";
/* 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();
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";
/* configure login behaviour */
system_login_configure();
system_devd_configure(true);
system_login_configure(true);
$setup_installer = is_install_media();
if ($setup_installer) {
......@@ -89,11 +81,9 @@ if ($setup_installer) {
OPNsense\Core\Config::getInstance()->forceReload();
}
echo "Loading configuration...";
global $config;
$config = parse_config();
$config = parse_config(true);
convert_config();
echo "done.\n";
/*
* Determine if we need to throw a interface exception
......@@ -106,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