summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-08-16 08:54:12 -0300
committerRenato Botelho <renato@netgate.com>2017-08-16 11:03:20 -0300
commitacaafa7f5095ad27afde85cd0622912c8221a1e5 (patch)
treeb9e01856588a0ba350851ba80ee601ae632f32e1
parent4ed2e462ffd4cde5826b4f3e2455ad390e1e2a91 (diff)
downloadpfsense-acaafa7f5095ad27afde85cd0622912c8221a1e5.zip
pfsense-acaafa7f5095ad27afde85cd0622912c8221a1e5.tar.gz
Check if specific config upgrade code already ran and skip it
-rw-r--r--src/etc/inc/config.lib.inc27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc
index 5d0216e..6c3fa8f 100644
--- a/src/etc/inc/config.lib.inc
+++ b/src/etc/inc/config.lib.inc
@@ -349,17 +349,30 @@ function convert_config() {
if (file_exists("/etc/inc/upgrade_config_custom.inc")) {
include_once("upgrade_config_custom.inc");
}
+
+ if (!is_array($config['system']['already_run_config_upgrade'])) {
+ $config['system']['already_run_config_upgrade'] = array();
+ }
+ $already_run =& $config['system']['already_run_config_upgrade'];
+
/* Loop and run upgrade_VER_to_VER() until we're at current version */
while ($config['version'] < $g['latest_config']) {
$cur = $config['version'] * 10;
$next = $cur + 1;
- $migration_function = sprintf('upgrade_%03d_to_%03d', $cur, $next);
- if (function_exists($migration_function)) {
- $migration_function();
- }
- $migration_function = "{$migration_function}_custom";
- if (function_exists($migration_function)) {
- $migration_function();
+ $migration_function = sprintf('upgrade_%03d_to_%03d', $cur,
+ $next);
+
+ foreach (array("", "_custom") as $suffix) {
+ $migration_function .= $suffix;
+ if (!function_exists($migration_function)) {
+ continue;
+ }
+ if (isset($already_run[$migration_function])) {
+ /* Already executed, skip now */
+ unset($already_run[$migration_function]);
+ } else {
+ $migration_function();
+ }
}
$config['version'] = sprintf('%.1f', $next / 10);
if (platform_booting()) {
OpenPOWER on IntegriCloud