aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2015-10-07 09:15:47 -0400
committerjim-p <jimp@pfsense.org>2015-10-07 09:15:47 -0400
commit7d613d5c35a0effaadfe409cc80e07068fdcc39b (patch)
tree6e239643b8140aa854252662cc56c5c2ec0b692a /config
parent7425d1a64fcc168818cb9c1bf37d8a7181925e20 (diff)
downloadpfsense-packages-7d613d5c35a0effaadfe409cc80e07068fdcc39b.tar.gz
pfsense-packages-7d613d5c35a0effaadfe409cc80e07068fdcc39b.tar.bz2
pfsense-packages-7d613d5c35a0effaadfe409cc80e07068fdcc39b.zip
Restore previous legacy code for squid cron job handling as the updated method completely breaks saving the package on 2.1.x. Fixes #5205
Diffstat (limited to 'config')
-rw-r--r--config/squid/squid.inc81
1 files changed, 66 insertions, 15 deletions
diff --git a/config/squid/squid.inc b/config/squid/squid.inc
index 4cfb9af8..fc62a587 100644
--- a/config/squid/squid.inc
+++ b/config/squid/squid.inc
@@ -552,24 +552,75 @@ function squid_install_cron($should_install) {
return;
}
- parse_config(true);
+ $rotate_is_installed = false;
+ $swapstate_is_installed = false;
+ if(!$config['cron']['item'])
+ return;
+ $settings = $config['installedpackages']['squidcache']['config'][0];
- if (is_array($config['installedpackages']['squidcache'])) {
- $settings = $config['installedpackages']['squidcache']['config'][0];
- } else {
- $settings = array();
- }
- $cachedir = ($settings['harddisk_cache_location'] ? $settings['harddisk_cache_location'] : '/var/squid/cache');
- $cron_cmd = "/bin/rm {$cachedir}/swap.state; " . SQUID_LOCALBASE . "/sbin/squid -k rotate";
- $swapstate_cmd = "/usr/local/pkg/swapstate_check.php";
+ $x=0;
+ $rotate_job_id=-1;
+ $swapstate_job_id=-1;
- if ($should_install) {
- install_cron_job("{$cron_cmd}", true, "0", "0", "*", "*", "*", "root");
- install_cron_job("{$swapstate_cmd}", true, "*/15");
- } else {
- install_cron_job("{$cron_cmd}", false);
- install_cron_job("{$swapstate_cmd}", false);
+ foreach($config['cron']['item'] as $item) {
+ if(strstr($item['task_name'], "squid_rotate_logs")) {
+ $rotate_job_id = $x;
+ } elseif(strstr($item['task_name'], "squid_check_swapstate")) {
+ $swapstate_job_id = $x;
+ }
+ $x++;
+ }
+ $need_write = false;
+ switch($should_install) {
+ case true:
+ $cachedir =($settings['harddisk_cache_location'] ? $settings['harddisk_cache_location'] : '/var/squid/cache');
+ if($rotate_job_id < 0) {
+ $cron_item = array();
+ $cron_item['task_name'] = "squid_rotate_logs";
+ $cron_item['minute'] = "0";
+ $cron_item['hour'] = "0";
+ $cron_item['mday'] = "*";
+ $cron_item['month'] = "*";
+ $cron_item['wday'] = "*";
+ $cron_item['who'] = "root";
+ $cron_item['command'] = "/bin/rm {$cachedir}/swap.state; " . SQUID_LOCALBASE . "/sbin/squid -k rotate";
+ $config['cron']['item'][] = $cron_item;
+ $need_write = true;
+ }
+ if($swapstate_job_id < 0) {
+ $cron_item = array();
+ $cron_item['task_name'] = "squid_check_swapstate";
+ $cron_item['minute'] = "*/15";
+ $cron_item['hour'] = "*";
+ $cron_item['mday'] = "*";
+ $cron_item['month'] = "*";
+ $cron_item['wday'] = "*";
+ $cron_item['who'] = "root";
+ $cron_item['command'] = "/usr/local/pkg/swapstate_check.php";
+ $config['cron']['item'][] = $cron_item;
+ $need_write = true;
+ }
+ if ($need_write) {
+ parse_config(true);
+ write_config("Adding Squid Cron Jobs");
+ }
+ break;
+ case false:
+ if($rotate_job_id >= 0) {
+ unset($config['cron']['item'][$rotate_job_id]);
+ $need_write = true;
+ }
+ if($swapstate_job_id >= 0) {
+ unset($config['cron']['item'][$swapstate_job_id]);
+ $need_write = true;
+ }
+ if ($need_write) {
+ parse_config(true);
+ write_config("Removing Squid Cron Jobs");
+ }
+ break;
}
+ configure_cron();
}
function squid_resync_general() {