From fe1656d2ad446c1e1333a661bcb3c15c83627433 Mon Sep 17 00:00:00 2001 From: maniacikarus Date: Tue, 17 Feb 2009 19:31:14 +0100 Subject: [PATCH] Added recent proxy modifications to core27 Ability to change filedescriptors up to 16000 Ability to use cachemanager website to monitor squid Ability to reconfigure squid wihtout restart --- config/rootfiles/core/27/files | 3 ++ config/rootfiles/core/27/update.sh | 6 +++- html/cgi-bin/proxy.cgi | 52 +++++++++++++++++++++++++++--- langs/de/cgi-bin/de.pl | 5 +++ langs/en/cgi-bin/en.pl | 5 +++ lfs/squid | 10 ++++-- src/initscripts/init.d/squid | 4 +++ src/misc-progs/squidctrl.c | 6 ++-- 8 files changed, 81 insertions(+), 10 deletions(-) diff --git a/config/rootfiles/core/27/files b/config/rootfiles/core/27/files index 6c1e603dc8..6b3bbbc552 100644 --- a/config/rootfiles/core/27/files +++ b/config/rootfiles/core/27/files @@ -1,3 +1,4 @@ +etc/init.d/squid etc/sysctl.conf etc/squid/errors usr/bin/squidclient @@ -17,6 +18,7 @@ usr/lib/squid/smb_auth.pl usr/lib/squid/smb_auth.sh usr/lib/squid/squid_ldap_auth usr/lib/squid/unlinkd +usr/local/bin/squidctrl usr/sbin/squid var/ipfire/updatexlrator/bin/checkdeaddl var/ipfire/updatexlrator/bin/checkup @@ -25,6 +27,7 @@ var/ipfire/updatexlrator/bin/download var/ipfire/updatexlrator/bin/lscache var/ipfire/updatexlrator/updxlrator-lib.pl srv/web/ipfire/cgi-bin/proxy.cgi +srv/web/ipfire/cgi-bin/cachemgr.cgi srv/web/ipfire/cgi-bin/updatexlrator.cgi var/ipfire/langs lib/modules/2.6.25.19-ipfire/kernel/drivers/net/imq.ko diff --git a/config/rootfiles/core/27/update.sh b/config/rootfiles/core/27/update.sh index c8e847c3c4..d28e9dc8cb 100644 --- a/config/rootfiles/core/27/update.sh +++ b/config/rootfiles/core/27/update.sh @@ -1,10 +1,14 @@ #!/bin/bash . /opt/pakfire/lib/functions.sh /usr/local/bin/backupctrl exclude >/dev/null 2>&1 +/etc/init.d/squid stop extract_files [ -e /var/ipfire/qos/enable ] && qosctrl stop qosctrl generate [ -e /var/ipfire/qos/enable ] && qosctrl start perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" sysctl -p -/etc/init.d/squid restart +mv /etc/squid/cachemgr.conf /var/ipfire/proxy/cachemgr.conf +ln -sf /var/ipfire/proxy/cachemgr.conf /etc/squid/cachemgr.conf +chown nobody.nobody /var/ipfire/proxy/cachemgr.conf +/etc/init.d/squid start \ No newline at end of file diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi index 7aba37a00f..780fe5b92f 100644 --- a/html/cgi-bin/proxy.cgi +++ b/html/cgi-bin/proxy.cgi @@ -192,6 +192,7 @@ $proxysettings{'TRANSPARENT_BLUE'} = 'off'; $proxysettings{'PROXY_PORT'} = '800'; $proxysettings{'VISIBLE_HOSTNAME'} = ''; $proxysettings{'ADMIN_MAIL_ADDRESS'} = ''; +$proxysettings{'ADMIN_PASSWORD'} = ''; $proxysettings{'ERR_LANGUAGE'} = 'German'; $proxysettings{'ERR_DESIGN'} = 'ipfire'; $proxysettings{'SUPPRESS_VERSION'} = 'off'; @@ -203,8 +204,10 @@ $proxysettings{'UPSTREAM_PROXY'} = ''; $proxysettings{'UPSTREAM_USER'} = ''; $proxysettings{'UPSTREAM_PASSWORD'} = ''; $proxysettings{'LOGGING'} = 'off'; +$proxysettings{'CACHEMGR'} = 'off'; $proxysettings{'LOGQUERY'} = 'off'; $proxysettings{'LOGUSERAGENT'} = 'off'; +$proxysettings{'FILEDESCRIPTORS'} = '4096'; $proxysettings{'CACHE_MEM'} = '2'; $proxysettings{'CACHE_SIZE'} = '50'; $proxysettings{'MAX_SIZE'} = '4096'; @@ -331,7 +334,7 @@ if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'}) $proxysettings{'NCSA_PASS_CONFIRM'} = $proxysettings{'NCSA_PASS'}; } -if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'})) +if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'})) { if ($proxysettings{'ENABLE'} !~ /^(on|off)$/ || $proxysettings{'TRANSPARENT'} !~ /^(on|off)$/ || @@ -354,6 +357,12 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} goto ERROR; } } + if (!($proxysettings{'FILEDESCRIPTORS'} =~ /^\d+/) || + ($proxysettings{'FILEDESCRIPTORS'} < 1) || ($proxysettings{'FILEDESCRIPTORS'} > 16384)) + { + $errormessage = $Lang::tr{'proxy errmsg filedescriptors'}; + goto ERROR; + } if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/) || ($proxysettings{'CACHE_MEM'} < 1)) { @@ -625,6 +634,8 @@ ERROR: &writeconfig; &writepacfile; + if ($proxysettings{'CACHEMGR'} eq 'on'){&writecachemgr;} + system ('/usr/local/bin/squidctrl', 'disable'); unlink "${General::swroot}/proxy/enable"; unlink "${General::swroot}/proxy/transparent"; @@ -643,7 +654,8 @@ ERROR: system ('/usr/bin/touch', "${General::swroot}/proxy/transparent_blue"); } if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); } - } + if ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}) { system('/usr/local/bin/squidctrl reconfigure >/dev/null 2>&1'); } + } } if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy clear cache'}) @@ -704,6 +716,9 @@ $checked{'OFFLINE_MODE'}{$proxysettings{'OFFLINE_MODE'}} = "checked='checked'"; $checked{'LOGGING'}{'off'} = ''; $checked{'LOGGING'}{'on'} = ''; $checked{'LOGGING'}{$proxysettings{'LOGGING'}} = "checked='checked'"; +$checked{'CACHEMGR'}{'off'} = ''; +$checked{'CACHEMGR'}{'on'} = ''; +$checked{'CACHEMGR'}{$proxysettings{'CACHEMGR'}} = "checked='checked'"; $checked{'LOGQUERY'}{'off'} = ''; $checked{'LOGQUERY'}{'on'} = ''; $checked{'LOGQUERY'}{$proxysettings{'LOGQUERY'}} = "checked='checked'"; @@ -915,8 +930,7 @@ if ($netsettings{'BLUE_DEV'}) { print " "; } print <$Lang::tr{'advproxy admin mail'}: * - +   END @@ -1038,6 +1052,18 @@ print < $Lang::tr{'advproxy cache management'} + + $Lang::tr{'proxy cachemgr'}: + + $Lang::tr{'advproxy admin mail'}: * + + + + $Lang::tr{'proxy filedescriptors'}: + + $Lang::tr{'proxy admin password'}: * + + @@ -2111,6 +2137,7 @@ print <   +   @@ -3856,7 +3883,11 @@ END print FILE " $proxysettings{'VISIBLE_HOSTNAME'}\n\n"; } - if (!($proxysettings{'ADMIN_MAIL_ADDRESS'} eq '')) { print FILE "cache_mgr $proxysettings{'ADMIN_MAIL_ADDRESS'}\n\n"; } + if (!($proxysettings{'ADMIN_MAIL_ADDRESS'} eq '')) { print FILE "cache_mgr $proxysettings{'ADMIN_MAIL_ADDRESS'}\n"; } + if (!($proxysettings{'ADMIN_PASSWORD'} eq '')) { print FILE "cachemgr_passwd $proxysettings{'ADMIN_PASSWORD'} all\n"; } + print FILE "\n"; + + print FILE "max_filedescriptors $proxysettings{'FILEDESCRIPTORS'}\n\n"; # Write the parent proxy info, if needed. if ($remotehost ne '') @@ -3954,3 +3985,14 @@ sub deluser } # ------------------------------------------------------------------- + +sub writecachemgr +{ + open(FILE, ">${General::swroot}/proxy/cachemgr.conf"); + flock(FILE, 2); + print FILE "$netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}\n"; + print FILE "localhost"; + return; +} + +# ------------------------------------------------------------------- \ No newline at end of file diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index efaf8f0fa2..06dae3b8eb 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -2006,6 +2006,11 @@ 'you can only define one roadwarrior connection when using pre-shared key authentication' => 'Sie können nur eine Roadwarrior Verbindung definieren, wenn die Pre-shared Schlüsselauthentifizierung verwendet wird.
Entweder haben Sie bereits eine Roadwarrior Verbindung mit Pre-shared Schlüsselauthentifizierung, oder Sie versuchen gerade eine hinzuzufügen.', 'your department' => 'Ihre Abteilung', 'your e-mail' => 'Ihre E-mail Adresse', +'proxy errmsg filedescriptors' => 'Ungültiger Anzahl Filedescriptoren', +'proxy filedescriptors' => 'Anzahl Fildescriptoren', +'proxy admin password' => 'Cache Administrator Passwort', +'proxy cachemgr' => 'Cachemanager aktivieren', +'proxy reconfigure' => 'Speichern und Laden', ); #EOF diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 230e47fa38..51780964ca 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -2039,6 +2039,11 @@ 'you can only define one roadwarrior connection when using pre-shared key authentication' => 'You can only define one Roadwarrior connection when using pre-shared key authentication.
Either you already have a Roadwarrior connection with pre-shared key authentication, or you\'re trying to add one now.', 'your department' => 'Your Department', 'your e-mail' => 'Your E-mail Address', +'proxy errmsg filedescriptors' => 'Wrong amount of filedescriptors', +'proxy filedescriptors' => 'Amount of fildescriptors', +'proxy admin password' => 'Cache administrator password', +'proxy cachemgr' => 'Activate cachemanager', +'proxy reconfigure' => 'Save and Reload', ); #EOF diff --git a/lfs/squid b/lfs/squid index f4bc5f00c2..b91faa13c7 100644 --- a/lfs/squid +++ b/lfs/squid @@ -86,14 +86,17 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --enable-ntlm-auth-helpers="SMB" \ --enable-useragent-log \ --enable-referer-log \ - --enable-snmp \ - --with-pthreads --with-dl + --enable-snmp \ + --with-pthreads --with-dl \ + --with-maxfd="16384" cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make install rm -f /etc/squid/squid.conf ln -sf /var/ipfire/proxy/squid.conf /etc/squid/squid.conf + rm -f /etc/squid/cachemgr.conf + ln -sf /var/ipfire/proxy/cachemgr.conf /etc/squid/cachemgr.conf rm -f /etc/squid/errors ln -sf /usr/lib/squid/errors/English /etc/squid/errors @@ -101,6 +104,9 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) touch /var/log/squid/access.log chown -R squid:squid /var/log/squid /var/log/cache /var/log/updatexlrator + cp /usr/lib/squid/cachemgr.cgi /srv/web/ipfire/cgi-bin/cachemgr.cgi + chown nobody.nobody /srv/web/ipfire/cgi-bin/cachemgr.cgi + cp -f $(DIR_SRC)/config/updxlrator/updxlrator /usr/sbin/updxlrator cp -f $(DIR_SRC)/config/updxlrator/checkup /var/ipfire/updatexlrator/bin/checkup cp -f $(DIR_SRC)/config/updxlrator/download /var/ipfire/updatexlrator/bin/download diff --git a/src/initscripts/init.d/squid b/src/initscripts/init.d/squid index 25fcac0c4e..85c1a4311f 100644 --- a/src/initscripts/init.d/squid +++ b/src/initscripts/init.d/squid @@ -90,6 +90,10 @@ case "$1" in $0 start ;; + reconfigure) + /usr/sbin/squid -k reconfigure + ;; + status) statusproc /usr/sbin/squid statusproc /usr/lib/squid/unlinkd diff --git a/src/misc-progs/squidctrl.c b/src/misc-progs/squidctrl.c index 1196620309..9f3ba5dd9a 100644 --- a/src/misc-progs/squidctrl.c +++ b/src/misc-progs/squidctrl.c @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) { exit(1); if (argc < 2) { - fprintf(stderr, "\nNo argument given.\n\nsquidctrl (start|stop|restart|flush)\n\n"); + fprintf(stderr, "\nNo argument given.\n\nsquidctrl (start|stop|restart|flush|reconfigure)\n\n"); exit(1); } @@ -29,6 +29,8 @@ int main(int argc, char *argv[]) { safe_system("/etc/rc.d/init.d/squid stop"); } else if (strcmp(argv[1], "restart") == 0) { safe_system("/etc/rc.d/init.d/squid restart"); + } else if (strcmp(argv[1], "reconfigure") == 0) { + safe_system("/etc/rc.d/init.d/squid reconfigure"); } else if (strcmp(argv[1], "flush") == 0) { safe_system("/etc/rc.d/init.d/squid flush"); } else if (strcmp(argv[1], "enable") == 0) { @@ -37,7 +39,7 @@ int main(int argc, char *argv[]) { } else if (strcmp(argv[1], "disable") == 0) { safe_system("rm -f /etc/rc.d/rc*.d/*squid >/dev/null 2>&1"); } else { - fprintf(stderr, "\nBad argument given.\n\nsquidctrl (start|stop|restart|flush)\n\n"); + fprintf(stderr, "\nBad argument given.\n\nsquidctrl (start|stop|restart|flush|reconfigure)\n\n"); exit(1); } -- 2.39.2