diff options
author | Colin Smith <colin@pfsense.org> | 2005-05-08 03:48:46 +0000 |
---|---|---|
committer | Colin Smith <colin@pfsense.org> | 2005-05-08 03:48:46 +0000 |
commit | 84884519beff6bcaea79d24633075737832045aa (patch) | |
tree | 7a28f6ac704b0b4135029ea22089e0de7ff6c6c2 /etc/inc | |
parent | 5f5e5b71a6d529405261a5d47f85fac89799ba31 (diff) | |
download | pfsense-84884519beff6bcaea79d24633075737832045aa.zip pfsense-84884519beff6bcaea79d24633075737832045aa.tar.gz |
More work on config versioning.
* Archive the current config, instead of the new one.
* Don't read the new config over.
* Create new backup directory.
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/config.inc | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc index a3be4b8..05fdacb 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -508,10 +508,17 @@ function convert_config() { /* save the system configuration */ function write_config($desc="Unknown") { global $config, $g; - $lastchange = $config['revision']['lastchange']; + if(!is_dir($g['cf_conf_path'] . '/backup')) mkdir($g['cf_conf_path'] . '/backup'); + if (time() > mktime(0, 0, 0, 9, 1, 2004)) + $config['revision']['time'] = time(); + $config['revision']['description'] = $desc; - config_lock(); + /* archive config */ + if (isset($config['system']['version_control'])) { + copy($g['cf_conf_path'] . '/config.xml', $g['cf_conf_path'] . '/backup/config-' . $config['revision']['time'] . '.xml'); + } + config_lock(); conf_mount_rw(); if (time() > mktime(0, 0, 0, 9, 1, 2004)) /* make sure the clock settings are plausible */ @@ -522,29 +529,15 @@ function write_config($desc="Unknown") { /* generate configuration XML */ $xmlconfig = dump_xml_config($config, $g['xml_rootobj']); - /* archive config */ - if (isset($config['system']['version_control'])) { - $fd = fopen("{$g['cf_conf_path']}/backup/config-{$lastchange}.xml", "w"); - if (!$fd) - die("Unable to open {$g['cf_conf_path']}/bak/config-{$config['lastchange']}.xml for writing in write_config()\n"); - fwrite($fd, $xmlconfig); - fclose($fd); - } - - /* write configuration */ + /* write new configuration */ $fd = fopen("{$g['cf_conf_path']}/config.xml", "w"); - if (!$fd) die("Unable to open {$g['cf_conf_path']}/config.xml for writing in write_config()\n"); - fwrite($fd, $xmlconfig); fclose($fd); conf_mount_ro(); - /* re-read configuration */ - $config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']); - /* write config cache */ $fd = @fopen("{$g['tmp_path']}/config.cache", "wb"); if ($fd) { |