159 lines
3.0 KiB
Bash
Executable File
159 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Script um die cache_peer funktion von Squid manuell von der Website aus upzudaten.
|
|
# V1.0
|
|
# 13.10.2010
|
|
# Stoeckholzer, Haas
|
|
|
|
while [ "1" == "1" ];
|
|
do
|
|
|
|
zero=0
|
|
# ueberpruefen ob file vpnid_man vorhanden
|
|
if [ -e /var/vpn/vpnid_man ];
|
|
then
|
|
echo 1
|
|
zero=1
|
|
fi
|
|
|
|
# ueberpruefen ob file vpnid_next vorhanden
|
|
if [ -e /var/vpn/vpnid_next ];
|
|
then
|
|
echo 2
|
|
zero=2
|
|
fi
|
|
|
|
|
|
|
|
if [ "$zero" == "1" ];
|
|
then
|
|
# Manuelle ID als hex einlesen einlesen
|
|
hex=$(cat /var/vpn/vpnid_man)
|
|
id=$(printf "%d\n" $hex)
|
|
echo $id > /var/vpn/vpnid
|
|
rm /var/vpn/vpnid_man
|
|
echo $hex
|
|
# Login-Daten aus Datenbank holen
|
|
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
|
|
fi
|
|
|
|
if [ "$zero" == "2" ];
|
|
then
|
|
schleife="1"
|
|
rm /var/vpn/vpnid_next
|
|
|
|
while [ $schleife == "1" ] ;
|
|
do
|
|
# Zaehlvariable einlesen
|
|
id=$(cat /var/vpn/vpnid)
|
|
# id inkrementieren
|
|
let id=$id+1
|
|
|
|
# 255 Overflow verhindern
|
|
if [ $id -gt 254 ]
|
|
then
|
|
id=0
|
|
fi
|
|
|
|
# Variable id fuer naechsten Durchlauf speichern
|
|
echo $id > /var/vpn/vpnid
|
|
|
|
# id HEX wandeln
|
|
hex=$(echo "obase=16; $id" |bc)
|
|
|
|
# Abfrage ob Strinlaenge von hex kleiner als 2
|
|
if [ ${#hex} -lt 2 ];
|
|
then
|
|
hex=0$hex
|
|
fi
|
|
|
|
# Login-Daten aus Datenbank holen
|
|
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
|
|
|
|
# Abfrage ob Datensatz leer :
|
|
if [ ${#credentials} -gt 10 ];
|
|
then
|
|
schleife="0"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
|
|
# Abfrage ob Datensatz leer (zur Sicherheit):
|
|
if [ ${#credentials} -gt 10 ] && [ $zero != "0" ];
|
|
then
|
|
|
|
# stop squid
|
|
sudo killall -9 unlinkd
|
|
sudo killall -9 squid
|
|
|
|
sudo rm /etc/squid3/squid.conf
|
|
######################################################################################
|
|
# Config- Datei schreiben.
|
|
sudo echo -e -n "
|
|
# Squid config by h44z
|
|
|
|
# TAG: http_port
|
|
# Usage: port
|
|
# hostname:port
|
|
# 1.2.3.4:port
|
|
http_port 10.8.0.1:3128 transparent
|
|
http_port 10.8.0.1:8080
|
|
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
|
|
|
|
|
|
visible_hostname vpnrack
|
|
|
|
# TAG: icp_port
|
|
icp_port 0
|
|
|
|
# TAG: no_cache
|
|
acl QUERY urlpath_regex cgi-bin \\?
|
|
no_cache deny QUERY
|
|
|
|
# TAG: cache_mem (bytes)
|
|
cache_mem 32 MB
|
|
|
|
# TAG: cache_dir
|
|
cache_dir ufs /var/cache/squid 100 16 256
|
|
|
|
# TAG: cache_access_log
|
|
cache_access_log /var/log/squid/access.log
|
|
|
|
# TAG: cache_log
|
|
cache_log /var/log/squid/cache.log
|
|
|
|
# TAG: cache_store_log
|
|
cache_store_log /var/log/squid/store.log
|
|
|
|
# TAG: emulate_httpd_log on|off
|
|
emulate_httpd_log on
|
|
|
|
# TAG: pid_filename
|
|
pid_filename /var/run/squid.pid
|
|
|
|
# TAG: cache_mgr
|
|
cache_mgr christoph.haas2@students.htlinn.ac.at
|
|
|
|
http_access allow all
|
|
acl https port 443
|
|
http_access allow https
|
|
|
|
|
|
# TAG: http_reply_access
|
|
# Allow replies to client requests. This is complementary to http_access.
|
|
#http_reply_access allow all
|
|
|
|
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
|
|
|
|
never_direct allow all
|
|
" > /etc/squid3/squid.conf
|
|
######################################################################################
|
|
|
|
echo "Written: $credentials"
|
|
|
|
#start squid
|
|
squid -D -YC -f /etc/squid3/squid.conf
|
|
fi
|
|
sleep 2
|
|
done
|