Commit f763c7cd authored by Franco Fichtner's avatar Franco Fichtner

config: reformat config.xml sample, some additions

parent 06723bcf
This diff is collapsed.
...@@ -37,7 +37,6 @@ require_once("legacy_bindings.inc"); ...@@ -37,7 +37,6 @@ require_once("legacy_bindings.inc");
require_once('upgrade_config.inc'); require_once('upgrade_config.inc');
require_once("certs.inc"); require_once("certs.inc");
/* make a global alias table (for faster lookups) */ /* make a global alias table (for faster lookups) */
function alias_make_table($config) function alias_make_table($config)
{ {
...@@ -98,11 +97,19 @@ function parse_config() ...@@ -98,11 +97,19 @@ function parse_config()
* null * null
******/ ******/
/* convert configuration, if necessary */ /* convert configuration, if necessary */
function convert_config() { function convert_config()
{
global $config, $g; global $config, $g;
$now = date("H:i:s");
log_error(sprintf(gettext("Start Configuration upgrade at %s, set execution timeout to 15 minutes"), $now)); if (!isset($config['revision'])) {
//ini_set("max_execution_time", "900"); /* force a revision tag for proper handling in config history */
write_config('Factory configuration', false);
}
if ($config['version'] == $g['latest_config']) {
/* already at latest version */
return;
}
/* special case upgrades */ /* special case upgrades */
/* fix every minute crontab bogons entry */ /* fix every minute crontab bogons entry */
...@@ -118,8 +125,6 @@ function convert_config() { ...@@ -118,8 +125,6 @@ function convert_config() {
} }
} }
} }
if ($config['version'] == $g['latest_config'])
return; /* already at latest version */
// Save off config version // Save off config version
$prev_version = $config['version']; $prev_version = $config['version'];
...@@ -134,11 +139,9 @@ function convert_config() { ...@@ -134,11 +139,9 @@ function convert_config() {
$config['version'] = sprintf('%.1f', $next / 10); $config['version'] = sprintf('%.1f', $next / 10);
} }
$now = date("H:i:s"); if ($prev_version != $config['version']) {
log_error(sprintf(gettext("Ended Configuration upgrade at %s"), $now));
if ($prev_version != $config['version'])
write_config(sprintf(gettext('Upgraded config version level from %1$s to %2$s'), $prev_version, $config['version'])); write_config(sprintf(gettext('Upgraded config version level from %1$s to %2$s'), $prev_version, $config['version']));
}
} }
...@@ -318,7 +321,10 @@ function set_device_perms() { ...@@ -318,7 +321,10 @@ function set_device_perms() {
} }
function make_config_revision_entry($desc = null, $override_user = null) { function make_config_revision_entry($desc = null, $override_user = null)
{
global $config;
if (empty($override_user)) { if (empty($override_user)) {
if (empty($_SESSION["Username"])) { if (empty($_SESSION["Username"])) {
$username = getenv("USER"); $username = getenv("USER");
...@@ -330,22 +336,26 @@ function make_config_revision_entry($desc = null, $override_user = null) { ...@@ -330,22 +336,26 @@ function make_config_revision_entry($desc = null, $override_user = null) {
if (!empty($_SERVER['REMOTE_ADDR'])) { if (!empty($_SERVER['REMOTE_ADDR'])) {
$username .= '@' . $_SERVER['REMOTE_ADDR']; $username .= '@' . $_SERVER['REMOTE_ADDR'];
} }
} } else {
else {
$username = $override_user; $username = $override_user;
} }
$revision = array(); $revision = array();
if (time() > mktime(0, 0, 0, 9, 1, 2004)) /* make sure the clock settings are plausible */
$revision['time'] = time();
/* Log the running script so it's not entirely unlogged what changed */
if ($desc == "Unknown")
$desc = sprintf(gettext("%s made unknown change"), $_SERVER['SCRIPT_NAME']);
if (!empty($desc))
$revision['description'] = "{$username}: " . $desc;
$revision['username'] = $username; $revision['username'] = $username;
$revision['time'] = time();
if ($revision['time'] == $config['revision']['time']) {
/* avoid conflicting timestamps (a second is long) */
$revision['time'] = intval($revision['time']) + 1;
}
if ($desc == null || $desc == 'Unknown') {
$revision['description'] = sprintf(gettext("%s made unknown change"), $_SERVER['SCRIPT_NAME']);
} else {
$revision['description'] = $desc;
}
return $revision; return $revision;
} }
......
...@@ -162,6 +162,7 @@ if (is_install_media()) { ...@@ -162,6 +162,7 @@ if (is_install_media()) {
echo "Loading configuration..."; echo "Loading configuration...";
global $config; global $config;
$config = parse_config(); $config = parse_config();
convert_config();
echo "done.\n"; echo "done.\n";
/* /*
...@@ -177,11 +178,6 @@ if (is_interface_mismatch()) { ...@@ -177,11 +178,6 @@ if (is_interface_mismatch()) {
led_kitt(); led_kitt();
} }
/* convert config and clean backups */
echo "Updating configuration...";
convert_config();
echo "done.\n";
/* read in /etc/sysctl.conf and set values if needed */ /* read in /etc/sysctl.conf and set values if needed */
echo "Setting up extended sysctls..."; echo "Setting up extended sysctls...";
system_setup_sysctl(); system_setup_sysctl();
......
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