aboutsummaryrefslogtreecommitdiffstats
path: root/config/haproxy-devel
diff options
context:
space:
mode:
Diffstat (limited to 'config/haproxy-devel')
-rw-r--r--config/haproxy-devel/haproxy.inc22
-rwxr-xr-xconfig/haproxy-devel/haproxy_global.php26
-rw-r--r--config/haproxy-devel/pkg/haproxy_upgrade_config.inc14
3 files changed, 39 insertions, 23 deletions
diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc
index cebe2a51..803d857e 100644
--- a/config/haproxy-devel/haproxy.inc
+++ b/config/haproxy-devel/haproxy.inc
@@ -472,7 +472,7 @@ function haproxy_install_cron($should_install) {
$cron_item['month'] = "*";
$cron_item['wday'] = "*";
$cron_item['who'] = "root";
- $cron_item['command'] = "/usr/local/etc/rc.d/haproxy.sh check";
+ $cron_item['command'] = "/usr/local/etc/rc.d/haproxy.sh onecheck";
$config['cron']['item'][] = $cron_item;
parse_config(true);
write_config("haproxy, install cron CARP job");
@@ -1537,6 +1537,22 @@ function haproxy_plugin_certificates($pluginparams) {
return $result;
}
+function haproxy_carpipismaster($ip) {
+ global $config;
+ foreach($config['virtualip']['vip'] as $carp) {
+ if ($carp['mode'] != "carp")
+ continue;
+ $ipaddress = $carp['subnet'];
+ if ($ipaddress != $ip)
+ continue;
+
+ $carp_int = "{$carp['interface']}_vip{$carp['vhid']}";
+ $status = get_carp_interface_status($carp_int);
+ return ($status == "MASTER");
+ }
+ return null;
+}
+
function haproxy_check_run($reload) {
global $config, $g, $haproxy_run_message;
@@ -1549,8 +1565,8 @@ function haproxy_check_run($reload) {
if(isset($a_global['enable'])) {
if (isset($a_global['carpdev'])) {
- $status = get_carp_interface_status($a_global['carpdev']);
- if ($status != "MASTER") {
+ $status = haproxy_carpipismaster($a_global['carpdev']);
+ if (!$status) {
if (haproxy_is_running()) {
log_error("Stopping haproxy on CARP backup.");
//exec("/bin/pkill -F /var/run/haproxy.pid haproxy");//doesnt work for multiple pid's in a pidfile
diff --git a/config/haproxy-devel/haproxy_global.php b/config/haproxy-devel/haproxy_global.php
index 60c2fd9d..978d778d 100755
--- a/config/haproxy-devel/haproxy_global.php
+++ b/config/haproxy-devel/haproxy_global.php
@@ -271,26 +271,12 @@ function enable_change(enable_change) {
Carp monitor
</td>
<td class="vtable">
- <select name="carpdev" class="formfld">
- <option value="disabled" <?php if (!isset($pconfig['carpdev'])) echo "selected"; ?>>
- disabled
- </option>
- <?php
- if(is_array($config['virtualip']['vip'])) {
- foreach($config['virtualip']['vip'] as $carp):
- if ($carp['mode'] != "carp") continue;
- $ipaddress = $carp['subnet'];
- $carp_int = trim(find_carp_interface($ipaddress));
- ?>
- <option value="<?=$carp_int;?>"
- <?php if (isset($pconfig['carpdev']) && $carp_int == $pconfig['carpdev']) echo "selected"; ?>>
- <?=$carp_int;?> (<?=$ipaddress;?>)
- </option>
- <?php
- endforeach;
- }
- ?>
- </select>
+ <?php
+ $vipinterfaces = array();
+ $vipinterfaces[] = array('ip' => '', 'name' => 'Disabled');
+ $vipinterfaces += haproxy_get_bindable_interfaces($ipv="ipv4,ipv6", $interfacetype="carp");
+ echo_html_select('carpdev',$vipinterfaces, $pconfig['carpdev'],"No carp interfaces pressent");
+ ?>
<br/>
Monitor carp interface and only run haproxy on the firewall which is MASTER.
</td>
diff --git a/config/haproxy-devel/pkg/haproxy_upgrade_config.inc b/config/haproxy-devel/pkg/haproxy_upgrade_config.inc
index 9c602457..c1c951df 100644
--- a/config/haproxy-devel/pkg/haproxy_upgrade_config.inc
+++ b/config/haproxy-devel/pkg/haproxy_upgrade_config.inc
@@ -179,6 +179,20 @@ function haproxy_upgrade_config() {
}
$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) {