diff options
author | Renato Botelho <garga@FreeBSD.org> | 2014-09-23 08:57:50 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2014-09-23 08:57:50 -0300 |
commit | 3f257101f44f5a3d1547d1d442761d7fdcf597fd (patch) | |
tree | 310cd73e26daed1e162fcf967136d25eb1605e59 /etc/inc | |
parent | 8d5b31a26d9800fd1a636ca709e5825a6d65cad0 (diff) | |
download | pfsense-3f257101f44f5a3d1547d1d442761d7fdcf597fd.zip pfsense-3f257101f44f5a3d1547d1d442761d7fdcf597fd.tar.gz |
Provide upgrade config code to migrate unbound settings from 2.1 package to 2.2 base. Bump config version to 11.1. It fixes #3880
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/globals.inc | 2 | ||||
-rw-r--r-- | etc/inc/upgrade_config.inc | 92 |
2 files changed, 93 insertions, 1 deletions
diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index d70de57..4bb1410 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -73,7 +73,7 @@ $g = array( "disablecrashreporter" => false, "crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php", "debug" => false, - "latest_config" => "11.0", + "latest_config" => "11.1", "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 fc0a5ad..6261b49 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -3374,4 +3374,96 @@ function upgrade_109_to_110() { } } +function upgrade_110_to_111() { + global $config; + + if (!isset($config['installedpackages']['unbound']['config'][0])) + return; + + $pkg = $config['installedpackages']['unbound']['config'][0]; + + if (isset($config['installedpackages']['unboundadvanced']['config'][0])) + $pkg = array_merge($pkg, $config['installedpackages']['unboundadvanced']['config'][0]); + + $new = array(); + + /* deal first with boolean fields */ + $fields = array( + "enable" => "enable", + "dnssec_status" => "dnssec", + "forwarding_mode" => "forwarding", + "regdhcp" => "regdhcp", + "regdhcpstatic" => "regdhcpstatic", + "txtsupport" => "txtsupport", + "hide_id" => "hideidentity", + "hide_version" => "hideversion", + "prefetch" => "prefetch", + "prefetch_key" => "prefetchkey", + "harden_glue" => "hardenglue", + "harden_dnssec_stripped" => "dnssec_stripped"); + + foreach ($fields as $oldk => $newk) { + if (isset($pkg[$oldk])) { + if ($pkg[$oldk] == 'on') + $new[$newk] = true; + unset($pkg[$oldk]); + } + } + + $fields = array( + "active_interface" => "network_interface", + "query_interface" => "outgoing_interface", + "unbound_verbosity" => "log_verbosity", + "unbound_verbosity" => "log_verbosity", + "msg_cache_size" => "msgcachesize", + "outgoing_num_tcp" => "outgoing_num_tcp", + "incoming_num_tcp" => "incoming_num_tcp", + "edns_buffer_size" => "edns_buffer_size", + "num_queries_per_thread" => "num_queries_per_thread", + "jostle_timeout" => "jostle_timeout", + "cache_max_ttl" => "cache_max_ttl", + "cache_min_ttl" => "cache_min_ttl", + "infra_host_ttl" => "infra_host_ttl", + "infra_cache_numhosts" => "infra_cache_numhosts", + "unwanted_reply_threshold" => "unwanted_reply_threshold", + "custom_options" => "custom_options"); + + foreach ($fields as $oldk => $newk) { + if (isset($pkg[$oldk])) { + $new[$newk] = $pkg[$oldk]; + unset($pkg[$oldk]); + } + } + + /* Following options were removed, bring them as custom_options */ + if (isset($pkg['stats']) && $pkg['stats'] == "on") { + if (isset($pkg['stats_interval'])) + $new['custom_options'] .= (empty($new['custom_options']) ? "" : ";") . "statistics-interval: {$pkg['stats_interval']}"; + if (isset($pkg['cumulative_stats'])) + $new['custom_options'] .= (empty($new['custom_options']) ? "" : ";") . "statistics-cumulative: {$pkg['cumulative_stats']}"; + if (isset($pkg['extended_stats']) && $pkg['extended_stats'] == "on") + $new['custom_options'] .= (empty($new['custom_options']) ? "" : ";") . "extended-statistics: yes"; + else + $new['custom_options'] .= (empty($new['custom_options']) ? "" : ";") . "extended-statistics: no"; + } + + $new['acls'] = array(); + if (isset($config['installedpackages']['unboundacls']['config']) && + is_array($config['installedpackages']['unboundacls']['config'])) { + foreach ($config['installedpackages']['unboundacls']['config'] as $acl) + $new['acls'][] = $acl; + } + + $config['unbound'] = $new; + + if(isset($config['installedpackages']['unbound'])) + unset($config['installedpackages']['unbound']); + if(isset($config['installedpackages']['unboundadvanced'])) + unset($config['installedpackages']['unboundadvanced']); + if(isset($config['installedpackages']['unboundacls'])) + unset($config['installedpackages']['unboundacls']); + + unset($pkg, $new); +} + ?> |