Brad Taylor wrote:

I know this is not directly related to Squid but hoping someone could
help me with this script.  The script is a check to see if (Squid) http
and https are both working and if not then change the iptables to route
the traffic to the backend server.  Also wondering if anyone knows of a
better way of doing this?

#!/bin/sh while [ 1 ]; do

You are missing a back tick on this line.   You need a closing `

TEST_SQUID=`netstat -a | grep -c https

Your test here is a string "" again a numeric. Change to: if [ -n "${TEST_SQUID}" ]; then

if [ "$TEST_SQUID" -gt 0 ]; then iptables -t nat -A PREROUTING -p tcp -i eth0 -d x.x.102.125
--dport 80 -j LOG iptables -A FORWARD -p tcp -i eth0 -d x.x.102.122 --dport 80 -j
LOG iptables -A FORWARD -p tcp -i eth0 -d x.x.102.122 --dport 80 -j
ACCEPT iptables -t nat -A PREROUTING -p tcp -i eth0 -d x.x.102.125
--dport 80 -j DNAT --to x.x.102.122:80 iptables -A FORWARD -p tcp -i eth0 -d x.x.102.122 --dport 80 -j
ACCEPT iptables -t nat -A POSTROUTING -o eth0 -p tcp -d x.x.102.122
--dport 80 -j SNAT --to x.x.102.125 fi


TEST_SQUID=`netstat -a | grep -c :http

Your test here is a string "" again a numeric. Change to: if [ -n "${TEST_SQUID}" ]; then

if [ "$TEST_SQUID" -gt 0 ]; then iptables -t nat -A PREROUTING -p tcp -i eth0 -d x.x.102.125
--dport 80 -j LOG iptables -A FORWARD -p tcp -i eth0 -d x.x.102.122 --dport 80 -j
LOG iptables -A FORWARD -p tcp -i eth0 -d x.x.102.122 --dport 80 -j
ACCEPT iptables -t nat -A PREROUTING -p tcp -i eth0 -d x.x.102.125
--dport 80 -j DNAT --to x.x.102.122:80 iptables -A FORWARD -p tcp -i eth0 -d x.x.102.122 --dport 80 -j
ACCEPT iptables -t nat -A POSTROUTING -o eth0 -p tcp -d x.x.102.122
--dport 80 -j SNAT --to x.x.102.125 fi sleep 60 done




The error I get is:

./squid_backup: line 2: [: : integer expression expected ./squid_backup: line 13: -a: command not found 0 ./squid_backup: line 14: [: : integer expression expected

Any help would be great.




As to a better way, I let someone guide you. I use redundant Squid servers with a "pac" file to control failover.

Tim

-----------------------------------------------------------
Timothy E. Neto
Computer Systems Engineer         Komatsu Canada Limited
Ph#: 905-625-6292 x265            1725B Sismet Road
Fax: 905-625-6348                 Mississauga, Canada
E-Mail: [EMAIL PROTECTED]          L4W 1P9
-----------------------------------------------------------



Reply via email to