$be) { $a_backends[$id]['status'] = 'active'; } $id = 0; foreach ($a_oldservers as $oldserver) { $pool=$oldserver; /* make server sub array */ $server=array(); $server['name'] = $oldserver['name']; $server['address'] = $oldserver['address']; $server['port'] = $oldserver['port']; $server['weight'] = $oldserver['weight']; $a_servers=array(); $a_servers[]=$server; /* set new pool */ $pool['name'] = "pool$id"; $id++; $pool['ha_servers']['item']=$a_servers; /* link to frontend */ foreach ($a_backends as $id => $be) { if ($a_backends[$id]['name'] == $oldserver['backend']) { $a_backends[$id]['backend_serverpool'] = $pool['name']; $pool['monitor_uri'] = $be['monitor_uri']; unset($a_backends[$id]['monitor_uri']); break; } } unset($pool['backend']); unset($pool['address']); unset($pool['port']); unset($pool['weight']); $a_pools[] = $pool; } unset($config['installedpackages']['haproxy']['ha_servers']); $writeconfigupdate = true; } /* XML update to: pkg v1.3 and 'pool' changed to 'backend_serverpool' because 'pool' was added to listtags() in xmlparse.inc */ if (is_arrayset($config,'installedpackages','haproxy','ha_backends','item',0,'pool')) { $static_output .= "HAProxy, Do XML upgrade, change to backend_serverpool from pool array\n"; update_output_window($static_output); foreach($config['installedpackages']['haproxy']['ha_backends']['item'] as &$frontend) { $backend_serverpool = $frontend['pool'][0]; $frontend['backend_serverpool'] = $backend_serverpool; unset($frontend['pool']); } $writeconfigupdate = true; } //also move setting for existing 2.0 installations as only the new variable is used if (is_arrayset($config,'installedpackages','haproxy','ha_backends','item',0) && isset($config['installedpackages']['haproxy']['ha_backends']['item'][0]['pool'])) { $static_output .= "HAProxy, Do XML upgrade, change to backend_serverpool from pool\n"; update_output_window($static_output); foreach($config['installedpackages']['haproxy']['ha_backends']['item'] as &$frontend) { $backend_serverpool = $frontend['pool']; $frontend['backend_serverpool'] = $backend_serverpool; unset($frontend['pool']); } $writeconfigupdate = true; } // update config to "haproxy-devel 1.5-dev19 pkg v0.5" if(is_arrayset($config,'installedpackages','haproxy','ha_backends','item')) { $static_output .= "HAProxy, Do XML upgrade, update frontend options\n"; update_output_window($static_output); foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$bind) { if($bind['httpclose'] && $bind['httpclose'] == "yes" ) { $bind['httpclose'] = "httpclose"; $writeconfigupdate = true; } if (!$bind['extaddr']){ $bind['extaddr'] = "wan_ipv4"; $writeconfigupdate = true; } if ($bind['extaddr'] == "localhost"){ $bind['extaddr'] = "localhost_ipv4"; $writeconfigupdate = true; } if ($bind['extaddr'] == "any"){ $bind['extaddr'] = "any_ipv4"; $writeconfigupdate = true; } } } } if ($configversion < "00.13") { // update config to "haproxy-devel 1.5-dev19 pkg v0.13" foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$bind) { if (isset($bind['extaddr'])) { $new['extaddr'] = $bind['extaddr']; $new['extaddr_port'] = $bind['port']; $new['extaddr_ssl'] = $bind['ssloffload']; $bind['a_extaddr']['item'][] = $new; } unset($bind['extaddr']); unset($bind['port']); //unset($bind['ssloffload']); } $configversion = "00.13"; } if ($configversion < "00.16") { $static_output .= "HAProxy, 00.16\n"; $static_output .= "HAProxy, NOTICE: Changes to certificate acl's might need adjusting current config accordingly.\n"; $static_output .= "HAProxy, NOTICE: Certificate acls are now combined with user acls.\n"; update_output_window($static_output); $configversion = "00.16"; } if ($configversion < "00.17") { $static_output .= "HAProxy, 00.17\n"; update_output_window($static_output); // remove 'none' ca-cert, and set checkbox to allow for no certificate instead. foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$bind) { $list = array(); foreach ($bind['clientcert_ca']['item'] as $ca){ if (empty($ca['cert_ca'])) $bind['sslclientcert-none'] = 'yes'; else $list[] = $ca; } $bind['clientcert_ca']['item'] = $list; } $configversion = "00.17"; } if ($configversion < "00.19") { update_output_window($static_output); $carpint = $config['installedpackages']['haproxy']['carpdev']; if (is_arrayset($config, 'virtualip', 'vip') && is_arrayset($config, 'installedpackages', 'haproxy')) { foreach($config['virtualip']['vip'] as $carp) { $carp_int = "{$carp['interface']}_vip{$carp['vhid']}"; if ($carp_int == $carpint) { $config['installedpackages']['haproxy']['carpdev'] = $carp['subnet']; break; } } } $configversion = "00.19"; } $writeconfigupdate = $config['installedpackages']['haproxy']['configversion'] <> $configversion; if ($writeconfigupdate) { $config['installedpackages']['haproxy']['configversion'] = $configversion; $static_output .= "HAProxy, write updated config to version: $configversion\n"; update_output_window($static_output); write_config("HAProxy, update xml config version"); } }