Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
f8193d6a
Commit
f8193d6a
authored
Mar 12, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restore backup / defaults on config load
parent
67c7bd63
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
61 deletions
+11
-61
config.lib.inc
src/etc/inc/config.lib.inc
+11
-61
No files found.
src/etc/inc/config.lib.inc
View file @
f8193d6a
...
...
@@ -89,72 +89,22 @@ function encrypted_configxml()
function
parse_config
(
$parse
=
false
)
{
$cnf
=
OPNsense\Core\Config
::
getInstance
();
$config
=
$cnf
->
toArray
();
return
$config
;
global
$g
,
$config_parsed
;
$config_xml
=
'/conf/config.xml'
;
$lockkey
=
lock
(
'config'
);
$config_parsed
=
false
;
if
(
!
file_exists
(
$config_xml
)
||
filesize
(
$config_xml
)
==
0
)
{
$last_backup
=
discover_last_backup
();
if
(
$last_backup
)
{
log_error
(
gettext
(
"No config.xml found, attempting last known config restore."
));
file_notice
(
"config.xml"
,
gettext
(
"No config.xml found, attempting last known config restore."
),
"pfSenseConfigurator"
,
""
);
restore_backup
(
"/conf/backup/
{
$last_backup
}
"
);
if
(
!
$cnf
->
isValid
())
{
// there was an issue with loading the config, try to restore the last backup
$backups
=
$cnf
->
getBackups
();
if
(
count
(
$backups
)
>
0
)
{
// load last backup
log_error
(
gettext
(
"No (valid) config.xml found, attempting last known config restore."
));
file_notice
(
"config.xml"
,
gettext
(
"No (valid) config.xml found, attempting last known config restore."
),
"pfSenseConfigurator"
,
""
);
$cnf
->
restoreBackup
(
$backups
[
0
]);
}
else
{
// we don't have backups, try to load the default
log_error
(
gettext
(
'No config.xml found, attempting to restore factory config.'
));
restore_b
ackup
(
'/usr/local/etc/config.xml'
);
$cnf
->
restoreB
ackup
(
'/usr/local/etc/config.xml'
);
}
}
// Check for encrypted config.xml
encrypted_configxml
();
if
(
!
$parse
)
{
if
(
file_exists
(
'/tmp/config.cache'
))
{
$config
=
unserialize
(
file_get_contents
(
'/tmp/config.cache'
));
if
(
is_null
(
$config
))
$parse
=
true
;
}
else
$parse
=
true
;
}
if
(
$parse
==
true
)
{
if
(
!
file_exists
(
$config_xml
))
{
log_error
(
"No config.xml found, attempting last known config restore."
);
file_notice
(
"config.xml"
,
"No config.xml found, attempting last known config restore."
,
"pfSenseConfigurator"
,
""
);
$last_backup
=
discover_last_backup
();
if
(
$last_backup
)
{
restore_backup
(
"/conf/backup/
{
$last_backup
}
"
);
}
else
{
log_error
(
gettext
(
'No config.xml found, attempting to restore factory config.'
));
restore_backup
(
'/usr/local/etc/config.xml'
);
}
}
$config
=
parse_xml_config
(
$config_xml
,
array
(
$g
[
'xml_rootobj'
],
'pfsense'
));
if
(
$config
==
-
1
)
{
$last_backup
=
discover_last_backup
();
if
(
$last_backup
)
restore_backup
(
"/conf/backup/
{
$last_backup
}
"
);
else
{
log_error
(
gettext
(
'No config.xml found, attempting to restore factory config.'
));
restore_backup
(
'/usr/local/etc/config.xml'
);
}
}
generate_config_cache
(
$config
);
}
$config_parsed
=
true
;
unlock
(
$lockkey
);
alias_make_table
(
$config
);
return
$config
;
return
$cnf
->
toArray
();
}
function
generate_config_cache
(
$config
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment