#!/usr/bin/perl -w
my $squidfile='./squid-3.0.STABLE24.tar.gz';
system("tar -zxvf $squidfile");
#system("cd squid-3.0.STABLE24");
system("./squid-3.0.STABLE24/configure --prefix=/usr/local/squid2 --enable-storeio=aufs,diskd,ufs");
system("make");
system("make install");
#init file
my $squidconf='/usr/local/squid2/etc/squid.conf';
system("mkdir -p /var/log/squid");
system("useradd -s /sbin/nologin squid");
system("mkdir /cache1 /cache2");
system("chown -R squid /var/log/squid");
system("chown -R squid /cache1 /cache2");
system("cp /usr/local/squid2/etc/squid.conf{,.bak}");
#chage config files
use strict;
use IO::File;
my $CONFIG;
my $a;
open $CONFIG, '<', '/usr/local/squid2/etc/squid.conf'
or die "Could not open this file: $!";
open $a, ">>", '/usr/local/squid2/etc/squid.conf.orig'
or die "Could not open this file: $!";
select $a;
while (<$CONFIG>) {
#chomp;
s/#\s*TAG:\s*visible_hostname/visible_hostname linscora/;
s/^access_log.*/access_log \/var\/log\/squid\/access.log squid/;
s/# cache_log.*/cache_log \/var\/log\/squid\/cache.log squid/;
s/# cache_effective_user\snobody/cache_effective_user squid/;
s/# cache_effective_group\snobody/cache_effective_group squid/;
s/^# cache_dir.*/cache_dir aufs \/cache1 18432 16 256/;
s/^icp_port.*/icp_port 0/;
s/# cache_mem.*/cache_mem 768 MB/;
s/# cache_swap_low.*/cache_swap_low 85 MB/;
s/# cache_swap_high.*/cache_swap_high 90 MB/;
s/# cache_store_log.*/cache_store_log none/;
print "$_";
}
close $CONFIG;
close $a;
system("yes|cp /usr/local/squid2/etc/squid.conf.orig /usr/local/squid2/etc/squid.conf");
|