From 557300a7eb66a82d951d5696c80209593cccfd6f Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 6 Apr 2011 12:54:18 -0400 Subject: Actually re-parse the config if a valid config was not written. (Should help stop installs from blowing up on failed config upgrades). Save the bad config for inspection, and print a message to the console about what was done. --- etc/inc/config.lib.inc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'etc') diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc index 1b7766a..8b25a3a 100644 --- a/etc/inc/config.lib.inc +++ b/etc/inc/config.lib.inc @@ -534,10 +534,17 @@ function write_config($desc="Unknown", $backup = true) { /* NOTE: We assume that the file can be parsed since we wrote it. */ $config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']); if ($config == -1) { + copy("{$g['conf_path']}/config.xml", "{$g['conf_path']}/config.xml.bad"); $last_backup = discover_last_backup(); - if ($last_backup) + if ($last_backup) { restore_backup("/cf/conf/backup/{$last_backup}"); - else + $config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']); + if ($g['booting']) { + echo "\n\n ************** WARNING **************"; + echo "\n\n New configuration could not be validated. Restored previous configuration. \n"; + echo "\n Failed configuration has been saved as {{$g['conf_path']}/config.xml.bad} \n\n"; + } + } else log_error(gettext("Could not restore config.xml.")); } else generate_config_cache($config); -- cgit v1.1