From 0ae12ec9be5a9fc96cb1fbb1d2c68aab9740c48c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 18:40:27 +0200 Subject: haproxy1_5 - use install_cron_job() instead of reimplementing it --- config/haproxy1_5/pkg/haproxy.inc | 103 +++----------------------------------- 1 file changed, 8 insertions(+), 95 deletions(-) diff --git a/config/haproxy1_5/pkg/haproxy.inc b/config/haproxy1_5/pkg/haproxy.inc index 8ba7e437..5e554ffc 100644 --- a/config/haproxy1_5/pkg/haproxy.inc +++ b/config/haproxy1_5/pkg/haproxy.inc @@ -347,10 +347,10 @@ function haproxy_custom_php_deinstall_command() { update_output_window($static_output); unlink_if_exists("/usr/local/etc/rc.d/haproxy.sh"); unlink_if_exists("/etc/rc.haproxy_ocsp.sh"); - $static_output .= "HAProxy, installing cron job if needed\n"; + $static_output .= "HAProxy, uninstalling cron job if needed\n"; update_output_window($static_output); - haproxy_install_cron(false); - haproxy_install_cronjob(false, '/etc/rc.haproxy_ocsp.sh'); + install_cron_job("/usr/local/etc/rc.d/haproxy.sh onecheck", false); + install_cron_job("/etc/rc.haproxy_ocsp.sh", false); $static_output .= "HAProxy, running haproxy_custom_php_deinstall_command() DONE\n"; update_output_window($static_output); } @@ -472,95 +472,6 @@ EOD; update_output_window($static_output); } -function haproxy_install_cronjob($should_install, $script, $interval = 60, $parameters = "") { - global $config, $g; - if($g['booting']==true) - return; - $is_installed = false; - if(!$config['cron']['item']) - return; - $x=0; - foreach($config['cron']['item'] as $item) { - if(strstr($item['command'], $script)) { - $is_installed = true; - break; - } - $x++; - } - switch($should_install) { - case true: - if(!$is_installed) { - $cron_item = array(); - $cron_item['minute'] = "*/{$interval}"; - $cron_item['hour'] = "*"; - $cron_item['mday'] = "*"; - $cron_item['month'] = "*"; - $cron_item['wday'] = "*"; - $cron_item['who'] = "root"; - $cron_item['command'] = "$script $parameters"; - $config['cron']['item'][] = $cron_item; - parse_config(true); - write_config("haproxy, install cron job"); - configure_cron(); - } - break; - case false: - if($is_installed == true) { - if($x > 0) { - unset($config['cron']['item'][$x]); - parse_config(true); - write_config("haproxy, remove cron job"); - } - configure_cron(); - } - break; - } -} - -function haproxy_install_cron($should_install) { - global $config, $g; - if($g['booting']==true) - return; - $is_installed = false; - if(!$config['cron']['item']) - return; - $x=0; - foreach($config['cron']['item'] as $item) { - if(strstr($item['command'], "/usr/local/etc/rc.d/haproxy.sh")) { - $is_installed = true; - break; - } - $x++; - } - switch($should_install) { - case true: - if(!$is_installed) { - $cron_item = array(); - $cron_item['minute'] = "*/2"; - $cron_item['hour'] = "*"; - $cron_item['mday'] = "*"; - $cron_item['month'] = "*"; - $cron_item['wday'] = "*"; - $cron_item['who'] = "root"; - $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"); - configure_cron(); - } - break; - case false: - if($is_installed == true) { - if($x > 0) { - unset($config['cron']['item'][$x]); - parse_config(true); - write_config("haproxy, remove cron CARP job"); - } - configure_cron(); - } - break; - } -} function haproxy_find_backend($backendname) { global $config; @@ -1729,12 +1640,14 @@ function haproxy_check_run($reload) { haproxy_updateocsp(false); if (isset($a_global['carpdev'])) - haproxy_install_cron(true); + install_cron_job("/usr/local/etc/rc.d/haproxy.sh onecheck", true, "*/2"); else - haproxy_install_cron(false); + install_cron_job("/usr/local/etc/rc.d/haproxy.sh onecheck", false); $useocsp = haproxy_uses_ocsp(); - haproxy_install_cronjob($useocsp, '/etc/rc.haproxy_ocsp.sh', 120); + if ($useocsp == "true") { + install_cron_job("/etc/rc.haproxy_ocsp.sh", true, "*/120"); + } } if(isset($a_global['enable'])) { -- cgit v1.2.3 From 2f008f3427dbc4e081a7b551e416c92cac05f7f1 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 18:41:21 +0200 Subject: Bump haproxy-1_5 package version --- pkg_config.10.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 8e7c95ba..29dd545d 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -143,7 +143,7 @@ http://haproxy.1wt.eu/ Services - 0.29 + 0.30 Release 2.2 https://packages.pfsense.org/packages/config/haproxy1_5/haproxy.xml -- cgit v1.2.3 From f6fdeb258e3ef2b6fe7fafa211074e457fec6c71 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 18:43:50 +0200 Subject: haproxy1_5 - use install_cron_job() instead of reimplementing it - Remove the OSCP cronjob when disabled. --- config/haproxy1_5/pkg/haproxy.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/haproxy1_5/pkg/haproxy.inc b/config/haproxy1_5/pkg/haproxy.inc index 5e554ffc..f539cff5 100644 --- a/config/haproxy1_5/pkg/haproxy.inc +++ b/config/haproxy1_5/pkg/haproxy.inc @@ -1647,6 +1647,8 @@ function haproxy_check_run($reload) { $useocsp = haproxy_uses_ocsp(); if ($useocsp == "true") { install_cron_job("/etc/rc.haproxy_ocsp.sh", true, "*/120"); + } else { + install_cron_job("/etc/rc.haproxy_ocsp.sh", false); } } -- cgit v1.2.3