#!/bin/bash SQUID_STATUS=$(/sbin/e-smith/db configuration getprop squid status) WEB_REQ=$(/sbin/e-smith/db configuration getprop chilli WebRequests) if [[ $SQUID_STATUS == 'enabled' && $WEB_REQ == 'squid' ]]; then SQUID_PORT=$(/sbin/e-smith/db configuration getprop squid TransparentPort) # We need to insert rules just before the accept, so we'll have to compute this position POSITION=$(LANG=C iptables -t nat -L PREROUTING_FROM_CHILLI -n | \ egrep -v '(Chain|target)' | grep -n ACCEPT | cut -d':' -f1) /sbin/iptables -t nat -I PREROUTING_FROM_CHILLI $POSITION -s $2 \ -p tcp --dport 80 -j DNAT --to $1:$SQUID_PORT /sbin/iptables -I IN_FROM_CHILLI 7 -s $2 \ -p tcp --dport $SQUID_PORT --syn -j ACCEPT fi