blob: 4437e355475da7d3dc3c62b99851acc56ccf49b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#!/usr/bin/perl
package Squidconf;
require "__WIZ_HOME__/common/scripts/Vareqval.pm";
require "__WIZ_HOME__/common/scripts/Varspaceval.pm";
use MDK::Common;
use strict;
use standalone;
sub do_it_squid {
my $file="/etc/squid/squid.conf";
-f $file and MDK::Common::cp_af($file, $file.".orig");
MDK::Common::cp_af("__WIZ_HOME__/proxy_wizard/scripts/squid.conf.default", $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;
standalone::explanations("$file: cache_dir = $ENV{wiz_squid_defdir} $ENV{wiz_squid_disk}
mynetw = $ENV{wiz_squid_mynetw} cache_mem = $ENV{wiz_squid_mem} http_port = $ENV{wiz_squid_port}
level = $ENV{wiz_squid_level}");
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;
|