aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoktornotor <notordoktor@gmail.com>2015-09-04 22:17:03 +0200
committerdoktornotor <notordoktor@gmail.com>2015-09-04 22:17:03 +0200
commita928e6df410383d00c19318b5c20459c50249a5a (patch)
treecb2f748a693045ed1a57d8832219b3d238fab8d1
parent46d4da44f8da4cca4eee0e91382c8d2157d8afb1 (diff)
downloadpfsense-packages-a928e6df410383d00c19318b5c20459c50249a5a.tar.gz
pfsense-packages-a928e6df410383d00c19318b5c20459c50249a5a.tar.bz2
pfsense-packages-a928e6df410383d00c19318b5c20459c50249a5a.zip
squid3 - use install_cron_job() instead of reimplementing it
Also, use platform_booting() for boot check.
-rwxr-xr-xconfig/squid3/34/squid.inc90
1 files changed, 17 insertions, 73 deletions
diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc
index 2705ceb6..481b010b 100755
--- a/config/squid3/34/squid.inc
+++ b/config/squid3/34/squid.inc
@@ -772,89 +772,33 @@ function squid_validate_auth($post, &$input_errors) {
}
function squid_install_cron($should_install) {
- global $config, $g;
-
- if ($g['booting']==true)
- return;
- $rotate_is_installed = false;
- $swapstate_is_installed = false;
+ global $config;
- if (!$config['cron']['item'])
+ if (platform_booting()) {
return;
+ }
- if (is_array($config['installedpackages']['squidcache']))
+ parse_config(true);
+ if (is_array($config['installedpackages']['squidcache'])) {
$settings = $config['installedpackages']['squidcache']['config'][0];
- else
+ } else {
$settings = array();
-
- $x=0;
- $rotate_job_id=-1;
- $swapstate_job_id=-1;
- $cron_cmd=($settings['clear_cache']=='on' ? "/usr/local/pkg/swapstate_check.php clean; " : "");
- $cron_cmd .= SQUID_BASE."/sbin/squid -k rotate -f " . SQUID_CONFFILE;
- $need_write = false;
- foreach ($config['cron']['item'] as $item) {
- if (strstr($item['task_name'], "squid_rotate_logs")) {
- $rotate_job_id = $x;
- if ($item['command'] != $cron_cmd) {
- $config['cron']['item'][$x]['command']=$cron_cmd;
- $need_write = true;
- }
- } elseif (strstr($item['task_name'], "squid_check_swapstate")) {
- $swapstate_job_id = $x;
- }
- $x++;
}
+
+ $cron_cmd = ($settings['clear_cache'] == 'on' ? "/usr/local/pkg/swapstate_check.php clean; " : "");
+ $cron_cmd .= SQUID_BASE . "/sbin/squid -k rotate -f " . SQUID_CONFFILE;
+ install_cron_job("{$cron_cmd}", $should_install, "0", "0", "*", "*", "*", "root");
+
+ $swapstate_cmd = "/usr/local/pkg/swapstate_check.php clean; ";
if ($should_install) {
- $cachedir =($settings['harddisk_cache_location'] ? $settings['harddisk_cache_location'] : '/var/squid/cache');
- if ($rotate_job_id < 0) {
- $cron_item['command']=($settings['clear_cache']=='on' ? "/usr/local/pkg/swapstate_check.php clean; " : "");
- $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'] .= $cron_cmd;
- /* Add this cron_item as a new entry at the end of the item array. */
- $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";
- /* Add this cron_item as a new entry at the end of the item array. */
- $config['cron']['item'][] = $cron_item;
- $need_write = true;
- }
- if ($need_write) {
- parse_config(true);
- write_config("Adding Squid Cron Jobs");
+ if ($settings['clear_cache'] == 'on' ) {
+ install_cron_job("{$swapstate_cmd}", true, "*/15");
+ } else {
+ install_cron_job("{$swapstate_cmd}", false);
}
} else {
- 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");
- }
+ install_cron_job("{$swapstate_cmd}", false);
}
- configure_cron();
}
function squid_check_ca_hashes() {