aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/squid/squid.inc81
-rw-r--r--pkg_config.8.xml2
2 files changed, 67 insertions, 16 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() {
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index a0dcec6a..51148f48 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -1110,7 +1110,7 @@
<descr>High performance web proxy cache.</descr>
<website>http://www.squid-cache.org/</website>
<category>Network</category>
- <version>2.7.9 pkg v.4.3.10</version>
+ <version>2.7.9 pkg v.4.3.11</version>
<status>Stable</status>
<required_version>2</required_version>
<maintainer>fernando@netfilter.com.br seth.mos@dds.nl mfuchs77@googlemail.com jimp@pfsense.org</maintainer>