summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-08-08 23:58:58 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-08-08 23:58:58 +0000
commitdb9db2a86ec7486fbbaf4d0f41c4baffe70b3822 (patch)
tree9c71fd1ef225621edc86047df1db7e2d97b90342 /etc
parent9d1143bdffcd66abf0242a867d0d0866fcfedab8 (diff)
downloadpfsense-db9db2a86ec7486fbbaf4d0f41c4baffe70b3822.zip
pfsense-db9db2a86ec7486fbbaf4d0f41c4baffe70b3822.tar.gz
If no config.xml is found, attempt restore from the latest backup.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/config.inc10
1 files changed, 9 insertions, 1 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc
index 5386abe..f1225ab 100644
--- a/etc/inc/config.inc
+++ b/etc/inc/config.inc
@@ -207,6 +207,14 @@ function parse_config($parse = false) {
}
} else {
config_unlock();
+ if(!file_exists($g['conf_path'] . "/config.xml")) {
+ log_error(gettext("No config.xml found, attempting last known config restore."));
+ $last_backup = discover_last_backup();
+ if ($last_backup)
+ restore_backup("/cf/conf/backup/{$last_backup}");
+ else
+ log_error(gettext("Could not restore config.xml."));
+ }
$config = parse_config(true);
}
} else {
@@ -252,7 +260,7 @@ function generate_config_cache($config) {
}
function discover_last_backup() {
- $backups = split("\n", `cd /cf/conf/backup && ls -lat | awk '{print \$9}' | grep -v "\\.\\."`);
+ $backups = split("\n", `cd /cf/conf/backup && ls -lat *.xml | awk '{print \$9}' | grep -v "\\.\\."`);
$last_backup = "";
foreach($backups as $backup)
if($backup)
OpenPOWER on IntegriCloud