From c3ce2eced406efb771f0dc796633c7489cc944ba Mon Sep 17 00:00:00 2001 From: smos Date: Wed, 18 Apr 2012 17:31:36 +0200 Subject: [PATCH] Add upgrade code that updates the dynamic gateway names to their new format new $if_$type. Redmine Ticket #2332. I've tested a simple upgrade with 3 dynamic Wans with varying names and that appears to have succeeded. Needs more testing. --- etc/inc/globals.inc | 2 +- etc/inc/upgrade_config.inc | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index dda1935d69..6544b89abb 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -77,7 +77,7 @@ $g = array( "disablecrashreporter" => false, "crashreporterurl" => "http://crashreporter.pfsense.org/crash_reporter.php", "debug" => false, - "latest_config" => "8.4", + "latest_config" => "8.5", "nopkg_platforms" => array("cdrom"), "minimum_ram_warning" => "101", "minimum_ram_warning_text" => "128 MB", diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index 42396f52ba..251de2970a 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -2767,4 +2767,40 @@ function upgrade_083_to_084() { } } +function upgrade_084_to_085() { + global $config; + + $gateway_group_arr = array(); + $gateways = return_gateways_array(); + $oldnames = array(); + /* setup translation array */ + foreach($gateways as $name => $gw) { + if(isset($gw['dynamic'])){ + $oldname = strtoupper($config['interfaces'][$gw['friendlyiface']]['descr']); + $oldnames[$oldname] = $name; + } else { + $oldnames[$name] = $name; + } + } + + /* process the old array */ + if(is_array($config['gateways']['gateway_group'])) { + $group_array_new = array(); + foreach($config['gateways']['gateway_group'] as $name => $group) { + if(is_array($group['item'])) { + $newlist = array(); + foreach($group['item'] as $entry) { + $elements = explode("|", $entry); + if($oldnames[$elements[0]] <> "") { + $newlist[] = "{$oldnames[$elements[0]]}|{$elements[1]}"; + } + } + $group['item'] = $newlist; + $group_array_new[$name] = $group; + } + } + $config['gateways']['gateway_group'] = $group_array_new; + } +} + ?>