summaryrefslogtreecommitdiffstats
path: root/proxy_wizard/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'proxy_wizard/scripts')
-rw-r--r--proxy_wizard/scripts/Squidconf.pm66
1 files changed, 52 insertions, 14 deletions
diff --git a/proxy_wizard/scripts/Squidconf.pm b/proxy_wizard/scripts/Squidconf.pm
index 877d60d5..fa99558d 100644
--- a/proxy_wizard/scripts/Squidconf.pm
+++ b/proxy_wizard/scripts/Squidconf.pm
@@ -7,20 +7,58 @@ use MDK::Common;
use strict;
sub do_it_squid {
- my %mdk = Vareqval->get("/etc/sysconfig/mdk_serv");
- $mdk{wiz_squid_defdir} = $ENV{wiz_squid_defdir};
- $mdk{wiz_squid_level} = $ENV{wiz_squid_level};
- Vareqval->commit("/etc/sysconfig/mdk_serv");
my $file="/etc/squid/squid.conf";
- MDK::Common::cp_af($file, $file.".orig");
+ -f $file and MDK::Common::cp_af($file, $file.".orig");
MDK::Common::cp_af("__WIZ_HOME__/proxy_wizard/scripts/squid.conf.default", $file);
- %mdk = Varspaceval->get($file);
-# echo_debug "squid port ${wiz_squid_port}"
- $mdk{http_port} = $ENV{wiz_squid_port};
-# echo_debug "squid mem ${wiz_squid_mem}"
- $mdk{cache_mem} = "$ENV{wiz_squid_mem} MB";
- my %mdk = Varspaceval->commit($file, \%mdk);
-# echo_debug "squid disk ${wiz_squid_disk}"
- $t = `grep -E "^[[:space:]]*cache_dir[[:space:]]+[a-z]+[[:space:]]+$ENV{wiz_squid_defdir}[[:space:]]+[0-9]+" $file`;
-
+ print "$ENV{wiz_squid_defdir}\n";
+ substInFile {
+ s|^\s*\#?\s*(cache_dir.*$ENV{wiz_squid_defdir}\s*)\d*(.*)|$1$ENV{wiz_squid_disk}$2|;
+ s|^\s*\#?\s*(acl\s*mynetwork\s*src\s*).*$|$1$ENV{wiz_squid_mynetw}\n|;
+ s|^\s*\#?\s*(cache_mem\s*)\d*(\s*MB.*)|$1$ENV{wiz_squid_mem}$2|;
+ s|^\s*\#?\s*(http_port\s*)\d*(.*)|$1$ENV{wiz_squid_port}$2|;
+ } $file;
+ if ($ENV{wiz_squid_level} == 1) {
+ substInFile {
+ s|^\s*\#?\s*(http_access\s*)deny(\s*all.*)|\#$&$1allow$2|;
+ } $file;
+ }
+ elsif ($ENV{wiz_squid_level} == 2) {
+ substInFile {
+ s|^\s*\#?\s*(http_access\s*)allow(\s*all.*)|\#$&$1deny$2|;
+ s|^\s*\#?\s*(http_access\s*allow\s*)localhost|\#$&$1mynetwork|;
+ } $file;
+ }
+ elsif ($ENV{wiz_squid_level} == 3) {
+ substInFile {
+ s|^\s*\#?\s*(http_access\s*)allow(\s*all.*)|\#$&$1deny$2|;
+ s|^\s*\#?\s*(http_access\s*allow\s*)mynetwork|\#$&$1localhost|;
+ } $file;
+ }
+ else { # should not happen
+ die "wiz_squid_level error";
+ }
+ my $t = 0;
+ foreach (cat_($file)) {
+ if (/^\s*cache_peer.*/) {
+ $t = $_;;
+ last;
+ }
+ }
+ if ($ENV{wiz_squid_menupeer} == 1 && length $t) {
+ substInFile {
+ s|^\s*!\#\s*(cache_peer.*)|\#$&|;
+ } $file;
+ }
+ elsif ($ENV{wiz_squid_menupeer} == 2 && length $ENV{wiz_squid_cachepeer}) {
+ if (lenght $t) {
+ substInFile {
+ s|^\s*\#?\s*(cache_peer.*)|\#$&|;
+ } $file;
+ }
+ append_to_file($file, "cache_peer $ENV{wiz_squid_cachepeer} parent $ENV{wiz_squid_peerport} 3130");
+ }
+ system("/sbin/chkconfig --level 345 squid on");
+ system("service squid start");
+ 10;
}
+1;