Instalação automatizada do Squid 2.5 STABLE14

Publicado por Josevaldo da Rocha Santos 05/09/2006

[ Hits: 7.586 ]

Download squid14




É comum encontrar usuários que sentem dificuldades em instalar um servidor de proxy (Squid). Com esse script é possivel fazer todo o processo de maneira automática e sem nenhum quebra cabeças. Ele irá criar todos os diretórios necessários e deixar o Squid funcionando sem problema algum.

  



Esconder código-fonte

#!/bin/sh

# download

groupadd squid
useradd squid -g squid -d /var/cache/squid -s /bin/false -c 'Squid proxy cache'

mkdir /var/cache/squid -p
mkdir /etc/squid -p
mkdir /var/log/squid -p

touch /var/log/squid/access.log
touch /var/log/squid/store.log
touch /var/log/squid/cache.log
touch /var/log/squid/swap.log

chown squid.squid /var/log/squid -R
chown squid.squid /var/cache/squid -R

pacote="squid-2.5.STABLE14.tar.gz"
pasta="squid-2.5.STABLE14"
url="http://www.squid-cache.org/Versions/v2/2.5/$pacote"
opcoes="--enable-delay-pools --enable-cache-digests --enable-poll --disable-ident-lookups --enable-truncate --enable-removal-policies --enable-arp-acl --enable-linux-netfilter --enable-ssl --sysconfdir=/etc/squid"
cd /usr/local/src
if [ ! -f $pacote ]; then
wget $url
fi
tar -xvzf $pacote
cd $pasta

./configure $opcoes
make
make all
make install

hostname=`cat /etc/HOSTNAME`
    
echo "
http_port 8080

ssl_unclean_shutdown off
icp_port 0
hierarchy_stoplist cgi-bin ?

acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY

acl CAIXA02 dst 200.201.173.0/24
no_cache deny CAIXA02

acl CAIXA03 dst 200.201.174.0/24
no_cache deny CAIXA03
 
cache_mem 128 MB
cache_swap_low 90
cache_swap_high 95
    
maximum_object_size 6144 KB
minimum_object_size 0 KB
maximum_object_size_in_memory 80 KB
    
ipcache_size 1024
ipcache_low 90
ipcache_high 95
    
cache_dir ufs      /var/cache/squid 15000 128 256
cache_access_log   /var/log/squid/access.log
cache_log      /var/log/squid/cache.log
cache_store_log      /var/log/squid/store.log
    
mime_table /etc/squid/mime.conf

pid_filename /usr/local/squid/var/logs/squid.pid
    
ftp_user Squid@
ftp_list_width 32
ftp_passive on

auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
    
refresh_pattern ^ftp:      1440   20%   10080
refresh_pattern ^gopher:   1440   0%   1440
refresh_pattern .      0   20%   4320
    
    
acl intranet src 172.16.2.0/24
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443 563   # https, snews
acl Safe_ports port 70      # gopher
acl Safe_ports port 210      # wais
acl Safe_ports port 1025-65535   # unregistered ports
acl Safe_ports port 280      # http-mgmt
acl Safe_ports port 488      # gss-http
acl Safe_ports port 591      # filemaker
acl Safe_ports port 777      # multiling http
acl CONNECT method CONNECT
    
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
    
http_access deny spyware
http_access allow intranet
http_access deny all

http_reply_access allow all
icp_access allow all
    
cache_effective_user squid
cache_effective_group squid
    
httpd_accel_port 80
httpd_accel_host virtual
httpd_accel_single_host off
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
ie_refresh on
    
icon_directory /usr/local/squid/share/icons
error_directory /usr/local/squid/share/errors/Portuguese
coredump_dir /usr/local/squid/var/cache
memory_pools off
    
dns_testnames $hostname
" > /etc/squid/squid.conf

    
echo "#!/bin/sh

squidconf=/etc/squid/squid.conf
pid=\`cat \$squidconf | grep pid_filename | awk '{print \$2}'\`
    
prefix=/usr/local/squid
    
squid_start() {
    echo starting squid ...
    \$prefix/sbin/squid
}
       
squid_stop() {
    echo stopping squid ...
    \$prefix/sbin/squid -k shutdown 2>/dev/null
    sleep 1
    \$prefix/sbin/squid -k kill 2>/dev/null
    \$prefix/sbin/squid -k kill 2>/dev/null
    killall squid 2>/dev/null
    killall squid 2>/dev/null
    rm \$pid 2>/dev/null
}
                   
case \"\$1\" in
   'start')
        squid_stop
        squid_start
   ;;
   'stop')
        squid_stop
        ;;
   'restart')
        squid_stop
        squid_start
        ;;
   *)
      echo usage \$0 start|stop|restart
      ;;
esac
" > /etc/rc.d/rc.squid
                                        
chmod +x /etc/rc.d/rc.squid

Scripts recomendados

Carregando automaticamente wireless via ndiswrapper II

Port scanner

Importação de IPs do Whatsapp como Objeto do Zentyal

Script de conectividade wireless

Forensic Net Tools


  

Comentários
[1] Comentário enviado por removido em 05/09/2006 - 22:12h

Script shell sh na seção Perl? =|


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts