mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Fix #8911: Keep configured pkg repository when restoring config
This commit is contained in:
parent
d43485a9bc
commit
635ea24ece
@ -934,10 +934,29 @@ function restore_config_section($section_name, $new_contents) {
|
||||
if ($section_xml === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Save current pkg repo to re-add on new config */
|
||||
unset($pkg_repo_conf_path);
|
||||
if ($section_name == "system" &&
|
||||
isset($config['system']['pkg_repo_conf_path'])) {
|
||||
$pkg_repo_conf_path = $config['system']['pkg_repo_conf_path'];
|
||||
}
|
||||
|
||||
$config[$section_name] = &$section_xml;
|
||||
if (file_exists("{$g['tmp_path']}/config.cache")) {
|
||||
unlink("{$g['tmp_path']}/config.cache");
|
||||
}
|
||||
|
||||
/* Restore previously pkg repo configured */
|
||||
if ($section_name == "system") {
|
||||
if (isset($pkg_repo_conf_path)) {
|
||||
$config['system']['pkg_repo_conf_path'] =
|
||||
$pkg_repo_conf_path;
|
||||
} elseif (isset($config['system']['pkg_repo_conf_path'])) {
|
||||
unset($config['system']['pkg_repo_conf_path']);
|
||||
}
|
||||
}
|
||||
|
||||
write_config(sprintf(gettext("Restored %s of config file (maybe from CARP partner)"), $section_name));
|
||||
disable_security_checks();
|
||||
return true;
|
||||
|
||||
@ -287,6 +287,12 @@ if ($_POST) {
|
||||
/* restore the entire configuration */
|
||||
file_put_contents($_FILES['conffile']['tmp_name'], $data);
|
||||
if (config_install($_FILES['conffile']['tmp_name']) == 0) {
|
||||
/* Save current pkg repo to re-add on new config */
|
||||
unset($pkg_repo_conf_path);
|
||||
if (isset($config['system']['pkg_repo_conf_path'])) {
|
||||
$pkg_repo_conf_path = $config['system']['pkg_repo_conf_path'];
|
||||
}
|
||||
|
||||
/* this will be picked up by /index.php */
|
||||
mark_subsystem_dirty("restore");
|
||||
touch("/conf/needs_package_sync");
|
||||
@ -295,6 +301,22 @@ if ($_POST) {
|
||||
unlink("{$g['tmp_path']}/config.cache");
|
||||
}
|
||||
$config = parse_config(true);
|
||||
|
||||
/* Restore previously pkg repo configured */
|
||||
$pkg_repo_restored = false;
|
||||
if (isset($pkg_repo_conf_path)) {
|
||||
$config['system']['pkg_repo_conf_path'] =
|
||||
$pkg_repo_conf_path;
|
||||
$pkg_repo_restored = true;
|
||||
} elseif (isset($config['system']['pkg_repo_conf_path'])) {
|
||||
unset($config['system']['pkg_repo_conf_path']);
|
||||
$pkg_repo_restored = true;
|
||||
}
|
||||
|
||||
if ($pkg_repo_restored) {
|
||||
write_config(gettext("Removing pkg repository set after restoring full configuration"));
|
||||
}
|
||||
|
||||
if (file_exists("/boot/loader.conf")) {
|
||||
$loaderconf = file_get_contents("/boot/loader.conf");
|
||||
if (strpos($loaderconf, "console=\"comconsole")) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user