aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-09-08 08:32:37 -0300
committerRenato Botelho <renato@netgate.com>2015-09-08 08:32:37 -0300
commit2641e2a9bc44ae928aed7bc4bae277c4e64d3b7b (patch)
tree152ef6512c22a537cdd8ab8e103923b8d967790a /config
parentf17d566b02921bb4348d9b045a99b88c7ceb4594 (diff)
parentcc7fe261ae7209fa5a1a4c7840219137bf87327f (diff)
downloadpfsense-packages-2641e2a9bc44ae928aed7bc4bae277c4e64d3b7b.tar.gz
pfsense-packages-2641e2a9bc44ae928aed7bc4bae277c4e64d3b7b.tar.bz2
pfsense-packages-2641e2a9bc44ae928aed7bc4bae277c4e64d3b7b.zip
Merge pull request #1042 from doktornotor/patch-15
Diffstat (limited to 'config')
-rw-r--r--config/haproxy-devel/pkg/haproxy.inc106
1 files changed, 10 insertions, 96 deletions
diff --git a/config/haproxy-devel/pkg/haproxy.inc b/config/haproxy-devel/pkg/haproxy.inc
index e9bdbf47..13477677 100644
--- a/config/haproxy-devel/pkg/haproxy.inc
+++ b/config/haproxy-devel/pkg/haproxy.inc
@@ -367,10 +367,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);
}
@@ -492,96 +492,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;
$a_backends = &$config['installedpackages']['haproxy']['ha_pools']['item'];
@@ -1794,12 +1704,16 @@ 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");
+ } else {
+ install_cron_job("/etc/rc.haproxy_ocsp.sh", false);
+ }
}
if(isset($a_global['enable'])) {