OpenVPN_Management_GUI/Admin/Modules/Squid/squid_dynamic/write_conf

116 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Zaehlvariable einlesen
id=$ID_VPN
# Abfrage ob Stringlaenge von id NULL ist
if [ ${#ID_VPN} == 0 ];
then id=0
fi
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then id=0
fi
# Variable id fuer naechsten Durchlauf speichern
export ID_VPN=$id
# 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=$(./squidy $hex)
# Abfrage ob Datensatz leer :
zero="0"
if [ "$credentials" == ":" ];
then
. write_conf &
zero="1"
fi
if [ ${#credentials} == 0 ];
then
. write_conf &
zero="1"
fi
######################################################################################
# Config- Datei schreiben.
if [ $zero == "0" ]
then
echo "
# 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
######################################################################################
#restart squid
killall -9 squid
squid -D -YC -f /etc/squid3/squid.conf
fi