From a14c663f8579cb097aa2d40a5a556703173b183b Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 00:37:44 +0200 Subject: Stop creating log_dir here to avoid stupid recursive chown on / bug It's been already done squid_resync_general() in the first place, not needed at all. Leaving the squid_chown_recursive() safety checks in place, certainly good this to have here regardless. --- config/squid3/34/squid.inc | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index a7cb0490..d017852f 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -959,6 +959,7 @@ function squid_resync_general() { $logdir = ($settings['log_dir'] ? $settings['log_dir'] : '/var/squid/logs'); if (!is_dir($logdir)) { + log_error("Creating Squid log dir $logdir"); safe_mkdir($logdir, 0755); squid_chown_recursive($logdir, SQUID_UID, SQUID_GID); } @@ -1951,7 +1952,6 @@ function squid_resync($via_rpc = "no") { chgrp(SQUID_LOCALBASE . "/libexec/squid/pinger", SQUID_GID); } - $log_dir = ""; $squid_enabled = false; if (is_array($config['installedpackages']['squid']['config'])) { // check if Squid is enabled @@ -1964,19 +1964,6 @@ function squid_resync($via_rpc = "no") { $squid_enabled = true; } } - // create log dir if required - if (is_array($config['installedpackages']['squid']['config'])) { - if ($config['installedpackages']['squid']['config'][0]['log_dir'] != "") { - $log_dir = $config['installedpackages']['squid']['config'][0]['log_dir'] . '/'; - } - } else { - $log_dir = "/var/squid/logs/"; - } - if (!is_dir($log_dir)) { - log_error("Creating Squid log dir $log_dir"); - safe_mkdir($log_dir, 0755); - squid_chown_recursive($log_dir, SQUID_UID, SQUID_GID); - } // check cache dir and create if necessary squid_dash_z(); -- cgit v1.2.3 From ced23a5782a29ded3358f331c24fbd81e7ebb422 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 00:40:13 +0200 Subject: squid_traffic.xml - fix field tags --- config/squid3/34/squid_traffic.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/squid3/34/squid_traffic.xml b/config/squid3/34/squid_traffic.xml index 135ef9ad..ac86770f 100755 --- a/config/squid3/34/squid_traffic.xml +++ b/config/squid3/34/squid_traffic.xml @@ -191,7 +191,6 @@ Squid Transfer Quick Abort Settings listtopic - info @@ -205,6 +204,7 @@ ]]> + Finish transfer if less than x KB remaining quick_abort_min If the transfer has less than x KB remaining, it will finish the retrieval. -- cgit v1.2.3 From 349b9f6021d87128c88d4d186fc0f5b63d1dc1cd Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 00:43:39 +0200 Subject: Only try to stop Squid if running to prevent useless logspam --- config/squid3/34/squid.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index d017852f..a5b11204 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -1996,8 +1996,10 @@ function squid_resync($via_rpc = "no") { log_error("Stopping any running proxy monitors"); mwexec("/usr/local/etc/rc.d/sqp_monitor.sh stop"); sleep(1); - log_error("Stopping Squid"); - stop_service("squid"); + if (is_service_running('squid')) { + log_error("Stopping Squid"); + stop_service("squid"); + } } filter_configure(); -- cgit v1.2.3 From 305923a980f69fb4c826d3c6799b7b3abe6474cc Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 00:46:27 +0200 Subject: Remove the advanced advancedfield tags because pkg_edit.php is buggy. Also, adjust cols to prevent line wrapping and fix indentation. --- config/squid3/34/squid_antivirus.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid_antivirus.xml b/config/squid3/34/squid_antivirus.xml index 8d74eb2a..2e85ab19 100755 --- a/config/squid3/34/squid_antivirus.xml +++ b/config/squid3/34/squid_antivirus.xml @@ -87,8 +87,7 @@ Sync /pkg_edit.php?xml=squid_sync.xml - - enabled + ClamAV Anti-Virus Integration Using C-ICAP @@ -117,15 +116,18 @@ + + Advanced Options + listtopic + squidclamav.conf squidclamav squidclamav.conf file. Leave empty to load sample file. Edit only if you know what are you doing. textarea base64 - 75 + 85 15 - c-icap.conf @@ -133,9 +135,8 @@ c-icap.conf file. Leave empty to load sample file. Edit only if you know what are you doing. textarea base64 - 75 + 85 15 - c-icap.magic @@ -143,9 +144,8 @@ c-icap.conf file. Leave empty to load sample file. Edit only if you know what are you doing. textarea base64 - 75 + 85 15 - -- cgit v1.2.3 From d9534321ac68a2d0c61f7c230530af11584312bc Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 00:47:14 +0200 Subject: squid_cache.xml - add missing line break --- config/squid3/34/squid_cache.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/squid3/34/squid_cache.xml b/config/squid3/34/squid_cache.xml index ff861897..9c166a59 100755 --- a/config/squid3/34/squid_cache.xml +++ b/config/squid3/34/squid_cache.xml @@ -175,7 +175,7 @@ ext_cachemanager Cache Managers to be granted access to this proxy. + Enter the IPs for the external Cache Managers to be granted access to this proxy.
Note: Separate entries by semi-colons (;) ]]>
-- cgit v1.2.3 From 55c137525bfb94b631b09591cd29d3b404027102 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 00:48:11 +0200 Subject: squid_monitor.php - improve English --- config/squid3/34/squid_monitor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid_monitor.php b/config/squid3/34/squid_monitor.php index ba87f998..80e15a64 100755 --- a/config/squid3/34/squid_monitor.php +++ b/config/squid3/34/squid_monitor.php @@ -120,9 +120,9 @@ include("head.inc");
-
-
- ! to invert the sense of matching, to select non-matching lines.");?> +
+
+ ! to invert the sense of matching (to select non-matching lines).");?>
-- cgit v1.2.3 From b3c786134303ec09c28d05acd474c66bc2eb1396 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 00:49:01 +0200 Subject: squid_nac.xml - add missing line break --- config/squid3/34/squid_nac.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/squid3/34/squid_nac.xml b/config/squid3/34/squid_nac.xml index fb7accc3..4a81ac91 100755 --- a/config/squid3/34/squid_nac.xml +++ b/config/squid3/34/squid_nac.xml @@ -171,7 +171,7 @@ block_user_agent Note: Put each entry on a separate line. You also can use regular expressions. ]]> -- cgit v1.2.3 From e9a93bf65dc37e31af37a886eec1ea1894c5fca6 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 01:42:10 +0200 Subject: squid3 - clean up after itself on uninstall --- config/squid3/34/squid.inc | 75 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 14 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index a5b11204..ae311e56 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -353,26 +353,73 @@ function squid_install_command() { function squid_deinstall_command() { global $config, $g; - $plswait_txt = "This operation may take quite some time, please be patient. Do not press stop or attempt to navigate away from this page during this process."; + /* remove cronjob */ squid_install_cron(false); + + update_status("Stopping services..."); + /* kill all running services */ + mwexec('/usr/local/etc/rc.d/sqp_monitor.sh stop'); + if (is_process_running("c-icap")) { + mwexec('/usr/local/etc/rc.d/c-icap stop'); + } + if (is_process_running("clamd")) { + mwexec('/usr/local/etc/rc.d/clamav-clamd stop'); + } + if (is_process_running("freshclam")) { + mwexec('/usr/local/etc/rc.d/clamav-freshclam stop'); + } + mwexec("/bin/ps awux | /usr/bin/grep \"squid\" | /usr/bin/grep -v \"grep\" | /usr/bin/awk '{ print $2 }' | /usr/bin/xargs kill"); + mwexec("/bin/ps awux | /usr/bin/grep \"dnsserver\" | /usr/bin/grep -v \"grep\" | /usr/bin/awk '{ print $2 }' | /usr/bin/xargs kill"); + mwexec("/bin/ps awux | /usr/bin/grep \"unlinkd\" | /usr/bin/grep -v \"grep\" | /usr/bin/awk '{ print $2 }' | /usr/bin/xargs kill"); + /* delete rc scripts */ + unlink_if_exists('/usr/local/etc/rc.d/sqp_monitor.sh'); + unlink_if_exists('/usr/local/etc/rc.d/c-icap'); + unlink_if_exists('/usr/local/etc/rc.d/clamav-clamd'); + unlink_if_exists('/usr/local/etc/rc.d/clamav-freshclam'); + + /* clean up created directories */ + update_status("Removing cache and logs ... One moment please..."); + update_output_window("This operation may take quite some time, please be patient. Do not press stop or attempt to navigate away from this page during this process."); if (is_array($config['installedpackages']['squidcache'])) { - $settings = $config['installedpackages']['squidcache']['config'][0]; + $cachesettings = $config['installedpackages']['squidcache']['config'][0]; } else { - $settings = array(); + $cachesettings = array(); } - $cachedir =($settings['harddisk_cache_location'] ? $settings['harddisk_cache_location'] : '/var/squid/cache'); - $logdir = ($settings['log_dir'] ? $settings['log_dir'] : '/var/squid/logs'); - update_status("Removing cache ... One moment please..."); - update_output_window("$plswait_txt"); + $cachedir =($cachesettings['harddisk_cache_location'] ? $cachesettings['harddisk_cache_location'] : '/var/squid/cache'); + if (is_array($config['installedpackages']['squid'])) { + $squidsettings = $config['installedpackages']['squid']['config'][0]; + } else { + $squidsettings = array(); + } + $logdir = ($squidsettings['log_dir'] ? $squidsettings['log_dir'] : '/var/squid/logs'); // XXX: Is it ok to remove cache and logs? It's going to happen every time package is updated - mwexec_bg("/bin/rm -rf {$cachedir}"); - mwexec("/bin/rm -rf {$logdir}"); + if (is_dir("{$cachedir}")) { + mwexec_bg("/bin/rm -rf {$cachedir}"); + } + if (is_dir("{$logdir}")) { + mwexec("/bin/rm -rf {$logdir}"); + } + $dirs = array("/var/run/c-icap", "/var/log/c-icap", "/var/log/clamav", "/var/run/clamav", "/var/db/clamav"); + foreach ($dirs as $dir) { + if (is_dir("{$dir}")) { + mwexec("/bin/rm -rf {$dir}"); + } + } + /* clean up created PBI symlinks */ update_status("Finishing package cleanup."); - mwexec("/usr/local/etc/rc.d/sqp_monitor.sh stop"); - unlink_if_exists('/usr/local/etc/rc.d/sqp_monitor.sh'); - mwexec("/bin/ps awux | /usr/bin/grep \"squid\" | /usr/bin/grep -v \"grep\" | /usr/bin/awk '{ print $2 }' | /usr/bin/xargs kill"); - mwexec("/bin/ps awux | /usr/bin/grep \"dnsserver\" | /usr/bin/grep -v \"grep\" | /usr/bin/awk '{ print $2 }' | /usr/bin/xargs kill"); - mwexec("/bin/ps awux | /usr/bin/grep \"unlinkd\" | /usr/bin/grep -v \"grep\" | /usr/bin/awk '{ print $2 }' | /usr/bin/xargs kill"); + if (SQUID_LOCALBASE != '/usr/local') { + $ln_icap = array('bin/c-icap', 'bin/c-icap-client', 'c-icap-config', 'c-icap-libicapapi-config', 'c-icap-stretch', 'lib/c_icap', 'share/c_icap', 'etc/c-icap'); + foreach ($ln_icap as $ln) { + if (is_link("/usr/local/{$ln}")) { + unlink("/usr/local/{$ln}"); + } + } + if (is_link("/usr/local/lib/libicapapi.so.3")) { + unlink("/usr/local/lib/libicapapi.so.3"); + } + } + + update_status("Reloading filter..."); filter_configure(); } -- cgit v1.2.3 From a6d6098556a197190ad08b1328f4ad5541749644 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 02:41:44 +0200 Subject: remove the squid_dash_z() nonsense from here squid_dash_z() is already run as part of squid_resync(), plus the whole logic is broken here (like, leaving old cache dir in place if location changes, or cleaning the cache if the configured size gets increased). But that's for another round of fixes. --- config/squid3/34/squid_cache.xml | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid_cache.xml b/config/squid3/34/squid_cache.xml index 9c166a59..a5e73f80 100755 --- a/config/squid3/34/squid_cache.xml +++ b/config/squid3/34/squid_cache.xml @@ -403,22 +403,10 @@ base64
- - - squid_validate_cache($_POST, $input_errors); - -- cgit v1.2.3 From cfcec18e460d0927a276b0c7ac8968cdbf3d1c5e Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 03:19:17 +0200 Subject: squid3 - fix squid_dash_z() so that cache dir gets created on package install Also, don't try to kill Squid needlessly if not running. --- config/squid3/34/squid.inc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index ae311e56..a11a29ac 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -123,21 +123,20 @@ function squid_check_clamav_user($user) { function squid_dash_z($cache_action = 'none') { global $config; - //Do nothing if there is no cache config - if (!is_array($config['installedpackages']['squidcache']['config'])) { - return; + // We need cache created on package install + if (is_array($config['installedpackages']['squidcache'])) { + $cachesettings = $config['installedpackages']['squidcache']['config'][0]; + } else { + $cachesettings = array(); } - - $settings = $config['installedpackages']['squidcache']['config'][0]; + $cachedir = ($cachesettings['harddisk_cache_location'] ? $cachesettings['harddisk_cache_location'] : '/var/squid/cache'); // If the cache system is null, there is no need to initialize the (irrelevant) cache dir. - if ($settings['harddisk_cache_system'] == "null") { + if ($cachesettings['harddisk_cache_system'] == "null") { return; } - $cachedir = ($settings['harddisk_cache_location'] ? $settings['harddisk_cache_location'] : '/var/squid/cache'); - - if ($cache_action == "clean" && file_exists($cachedir)) { + if ($cache_action == "clean" && is_dir($cachedir)) { rename($cachedir, "{$cachedir}.old"); mwexec_bg("/bin/rm -rf {$cachedir}.old"); } @@ -151,11 +150,13 @@ function squid_dash_z($cache_action = 'none') { if (!is_dir($cachedir . '/00')) { log_error("Creating Squid cache subdirs in $cachedir"); - mwexec(SQUID_BASE. "/sbin/squid -k shutdown -f " . SQUID_CONFFILE); - sleep(5); - mwexec(SQUID_BASE. "/sbin/squid -k kill -f " . SQUID_CONFFILE); + if (is_process_running('squid')) { + mwexec(SQUID_BASE. "/sbin/squid -k shutdown -f " . SQUID_CONFFILE); + sleep(5); + mwexec(SQUID_BASE. "/sbin/squid -k kill -f " . SQUID_CONFFILE); + } // Double check permissions here, should be safe to recurse cache dir if it's small here. - mwexec("/usr/sbin/chown -R " . SQUID_UID . ":" . SQUID_GID . " $cachedir"); + squid_chown_recursive($cachedir, SQUID_UID, SQUID_GID); mwexec(SQUID_BASE. "/sbin/squid -z -f " . SQUID_CONFFILE); } @@ -385,7 +386,7 @@ function squid_deinstall_command() { } else { $cachesettings = array(); } - $cachedir =($cachesettings['harddisk_cache_location'] ? $cachesettings['harddisk_cache_location'] : '/var/squid/cache'); + $cachedir = ($cachesettings['harddisk_cache_location'] ? $cachesettings['harddisk_cache_location'] : '/var/squid/cache'); if (is_array($config['installedpackages']['squid'])) { $squidsettings = $config['installedpackages']['squid']['config'][0]; } else { -- cgit v1.2.3 From 94a0c4dc98133ae78a58928c311cb1848f46869b Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 09:25:43 +0200 Subject: split Squid services monitoring/handling to separate functions --- config/squid3/34/squid.inc | 57 +++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 18 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index a11a29ac..40abd166 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -2000,6 +2000,38 @@ function squid_resync($via_rpc = "no") { chgrp(SQUID_LOCALBASE . "/libexec/squid/pinger", SQUID_GID); } + // check cache dir and create if necessary + squid_dash_z(); + + // restart Squid if enabled and reconfigure filter + squid_restart_services(); + filter_configure(); + conf_mount_ro(); +} + +function squid_stop_monitor() { + /* kill any running proxy alarm scripts */ + log_error("Stopping any running proxy monitors"); + if (exec("/bin/ps auxw | /usr/bin/grep '[s]qpmon'")) { + mwexec("/usr/local/etc/rc.d/sqp_monitor.sh stop"); + } + sleep(1); +} + +function squid_start_monitor() { + if (exec("/bin/ps auxw | /usr/bin/grep '[s]qpmon'")) { + log_error("Starting a proxy monitor script"); + mwexec_bg("/usr/local/etc/rc.d/sqp_monitor.sh start"); + } + sleep(1); +} + +function squid_restart_services() { + // reconfigure and (re)start service as needed if enabled, otherwise stop them + // do not (re)start squid services on boot + if (platform_booting()) { + return; + } $squid_enabled = false; if (is_array($config['installedpackages']['squid']['config'])) { // check if Squid is enabled @@ -2013,16 +2045,10 @@ function squid_resync($via_rpc = "no") { } } - // check cache dir and create if necessary - squid_dash_z(); - - // reconfigure and (re)start service as needed if enabled, otherwise stop them - // do not (re)start squid services on boot - if ((!isset($boot_process)) && ($squid_enabled)) { + if ($squid_enabled) { /* kill any running proxy alarm scripts */ - log_error("Stopping any running proxy monitors"); - mwexec("/usr/local/etc/rc.d/sqp_monitor.sh stop"); - sleep(1); + squid_stop_monitor(); + if (!is_service_running('squid')) { log_error("Starting Squid"); mwexec(SQUID_BASE . "/sbin/squid -f " . SQUID_CONFFILE); @@ -2037,21 +2063,16 @@ function squid_resync($via_rpc = "no") { } } /* restart proxy alarm scripts */ - log_error("Starting a proxy monitor script"); - mwexec_bg("/usr/local/etc/rc.d/sqp_monitor.sh start"); - } elseif (!$squid_enabled) { + squid_start_monitor(); + + } else { /* Squid is disabled - kill any running proxy alarm scripts and stop Squid services */ - log_error("Stopping any running proxy monitors"); - mwexec("/usr/local/etc/rc.d/sqp_monitor.sh stop"); - sleep(1); + squid_stop_monitor(); if (is_service_running('squid')) { log_error("Stopping Squid"); stop_service("squid"); } } - - filter_configure(); - conf_mount_ro(); } function squid_print_javascript_auth() { -- cgit v1.2.3 From de6a7095933768eeb524b09b70fadcae85961661 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 09:29:00 +0200 Subject: Fix inverted squid_start_monitor() check --- config/squid3/34/squid.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index 40abd166..7c6799ee 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -2019,7 +2019,7 @@ function squid_stop_monitor() { } function squid_start_monitor() { - if (exec("/bin/ps auxw | /usr/bin/grep '[s]qpmon'")) { + if (!exec("/bin/ps auxw | /usr/bin/grep '[s]qpmon'")) { log_error("Starting a proxy monitor script"); mwexec_bg("/usr/local/etc/rc.d/sqp_monitor.sh start"); } -- cgit v1.2.3 From f387471a2fe21348cd2f34c8b75f113142ded18b Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 09:51:23 +0200 Subject: Split disk cache creation to a separate function as well --- config/squid3/34/squid.inc | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index 7c6799ee..6fb6140f 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -137,9 +137,28 @@ function squid_dash_z($cache_action = 'none') { } if ($cache_action == "clean" && is_dir($cachedir)) { + // cannot nuke disk cache while Squid is running + squid_stop_monitor(); + if (is_service_running('squid')) { + stop_service("squid"); + } rename($cachedir, "{$cachedir}.old"); mwexec_bg("/bin/rm -rf {$cachedir}.old"); + squid_create_cachedir(); + squid_restart_services(); + } else { + squid_create_cachedir(); + } +} + +function squid_create_cachedir() { + global $config; + if (is_array($config['installedpackages']['squidcache'])) { + $cachesettings = $config['installedpackages']['squidcache']['config'][0]; + } else { + $cachesettings = array(); } + $cachedir = ($cachesettings['harddisk_cache_location'] ? $cachesettings['harddisk_cache_location'] : '/var/squid/cache'); if (!is_dir($cachedir)) { log_error("Creating Squid cache dir {$cachedir}"); @@ -150,11 +169,6 @@ function squid_dash_z($cache_action = 'none') { if (!is_dir($cachedir . '/00')) { log_error("Creating Squid cache subdirs in $cachedir"); - if (is_process_running('squid')) { - mwexec(SQUID_BASE. "/sbin/squid -k shutdown -f " . SQUID_CONFFILE); - sleep(5); - mwexec(SQUID_BASE. "/sbin/squid -k kill -f " . SQUID_CONFFILE); - } // Double check permissions here, should be safe to recurse cache dir if it's small here. squid_chown_recursive($cachedir, SQUID_UID, SQUID_GID); mwexec(SQUID_BASE. "/sbin/squid -z -f " . SQUID_CONFFILE); @@ -2027,6 +2041,7 @@ function squid_start_monitor() { } function squid_restart_services() { + global $config; // reconfigure and (re)start service as needed if enabled, otherwise stop them // do not (re)start squid services on boot if (platform_booting()) { -- cgit v1.2.3 From 1e10ea594897ba3cd6c72ae5f5a83e8bbc2880dc Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 09:58:26 +0200 Subject: Force Squid shutdown on stopping service --- config/squid3/34/squid.inc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index 6fb6140f..d75c813b 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -2442,6 +2442,9 @@ EOD; {$squid_base}/sbin/squid -k shutdown -f {$squid_conffile_var} # Just to be sure... sleep 5 +if [ -n "`/bin/ps auxw | /usr/bin/grep "[s]quid " | /usr/bin/awk '{print $2}'`" ]; then + {$squid_base}/sbin/squid -k kill -f {$squid_conffile_var} +fi if [ -x /usr/bin/ipcs ]; then # http://man.chinaunix.net/newsoft/squid/Squid_FAQ/FAQ-22.html#ss22.8 -- cgit v1.2.3 From b5dcb3027c95ed5133693630934c0d7da704324a Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 10:24:20 +0200 Subject: Force delete the PBI initscript that keeps creeping back --- config/squid3/34/squid.inc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index d75c813b..519c7c54 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -2465,6 +2465,8 @@ if [ -z "`ps auxw | /usr/bin/grep "[s]quid " | /usr/bin/awk '{print $2}'`" ]; th EOD; conf_mount_rw(); write_rcfile($rc); + // force delete the PBI initscript that keeps creeping back + unlink_if_exists("/usr/local/etc/rc.d/squid"); conf_mount_ro(); } -- cgit v1.2.3 From 8454383e2a4bb1fba0050b4d8f66ab7cb79c9898 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 11:01:09 +0200 Subject: Remove yet another duplicate squid_dash_z() invocation, also don't log unless needed --- config/squid3/34/squid.inc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index 519c7c54..e44dbe62 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -608,8 +608,6 @@ function squid_validate_cache($post, &$input_errors) { } } } - - squid_dash_z(); } function squid_validate_nac($post, &$input_errors) { @@ -2025,8 +2023,8 @@ function squid_resync($via_rpc = "no") { function squid_stop_monitor() { /* kill any running proxy alarm scripts */ - log_error("Stopping any running proxy monitors"); if (exec("/bin/ps auxw | /usr/bin/grep '[s]qpmon'")) { + log_error("Stopping any running proxy monitors"); mwexec("/usr/local/etc/rc.d/sqp_monitor.sh stop"); } sleep(1); -- cgit v1.2.3 From d73dc9987b4d75f77246d4821c3704031b8fbc5a Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 11:31:47 +0200 Subject: Fix squid_dash_z() logic so that it creates cache dir properly when it has changed --- config/squid3/34/squid.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index e44dbe62..0faba446 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -136,18 +136,18 @@ function squid_dash_z($cache_action = 'none') { return; } - if ($cache_action == "clean" && is_dir($cachedir)) { + if ($cache_action == "clean" || (!is_dir($cachedir))) { // cannot nuke disk cache while Squid is running squid_stop_monitor(); if (is_service_running('squid')) { stop_service("squid"); } - rename($cachedir, "{$cachedir}.old"); - mwexec_bg("/bin/rm -rf {$cachedir}.old"); + if (is_dir($cachedir)) { + rename($cachedir, "{$cachedir}.old"); + mwexec_bg("/bin/rm -rf {$cachedir}.old"); + } squid_create_cachedir(); squid_restart_services(); - } else { - squid_create_cachedir(); } } -- cgit v1.2.3 From f7dbbd45e8f68d52cd46b1ae0d552d0bac66e3d5 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Wed, 30 Sep 2015 12:11:10 +0200 Subject: Also check for level 1 subdirs in cachedir for proper cache creation --- config/squid3/34/squid.inc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index 0faba446..7d2b08b7 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -130,13 +130,20 @@ function squid_dash_z($cache_action = 'none') { $cachesettings = array(); } $cachedir = ($cachesettings['harddisk_cache_location'] ? $cachesettings['harddisk_cache_location'] : '/var/squid/cache'); + $numdirs = ($cachesettings['level1_subdirs'] ? $cachesettings['level1_subdirs'] : 16); + if (is_dir($cachedir)) { + $currentdirs = count(glob("{$cachedir}/*", GLOB_ONLYDIR)); + } else { + $currentdirs = 0; + } // If the cache system is null, there is no need to initialize the (irrelevant) cache dir. if ($cachesettings['harddisk_cache_system'] == "null") { return; } - - if ($cache_action == "clean" || (!is_dir($cachedir))) { + // Re-create the cachedir if clean is forced by cronjob/manually, or + // or if the cachedir changed, or level1_subdirs don't exist or the number of level1_subdirs changed + if ($cache_action == "clean" || ((!is_dir($cachedir)) || (!is_dir($cachedir . '/00'))) || ($numdirs !== $currentdirs)) { // cannot nuke disk cache while Squid is running squid_stop_monitor(); if (is_service_running('squid')) { -- cgit v1.2.3