#!/bin/sh # # squid version 2.5.STABLE3 fn2() { ps | sed -n '/\ squid/P'; } stp() { [ "`fn2`" ] || return echo -n "Stopping squid... " /usr/local/squid/sbin/squid -k kill = $? killall squid -15 } str() { [ "`fn2`" ] && return echo -n "Starting squid... " # [ -s /mnt/hd2/var/squid_cache -a ] && /usr/local/squid/sbin/squid -sD = $? } edthlp() { cat <<~ Now you can edit the configuration file(s) for squid After you are finished editing the configuration scripts. Exit and save with + or and then Any key to continue. ~ } case "$1" in firewall) PORT=`cat /usr/local/squid/etc/squid.conf |sed -n 's/^http_port\ //P'` ipfwadm -I -a deny -P tcp -W $INET -D 0/0 $PORT -o ipfwadm -I -a deny -P udp -W $INET -D 0/0 $PORT -o # for transparent proxy . /etc/system.cfg #nets for apply the transparent redirection NETS="0 1 2 3 4 5 6 7 8 9" echo -n " Set rules for transpatrent proxy... " if [ "`fn2`" ]; then for i in $NETS; do neti=`eval 'echo $INTNAME'$i` LOCAL_IPs="$LOCAL_IPs `ifconfig $neti 2> /dev/null | sed -n 's/inet addr:\(.*\) Bcast:.*/\1/P'`" done for i in $NETS; do if [ "`eval 'echo $NET'$i`" ]; then for ip in $LOCAL_IPs; do ipfwadm -I -a acc -P tcp -S `eval 'echo $NET'$i` -D $ip 80 -W `eval 'echo $INTNAME'$i` done ipfwadm -I -a acc -P tcp -S `eval 'echo $NET'$i` -D 0/0 80 -r $PORT -W `eval 'echo $INTNAME'$i` fi done fi # = $? ;; setup) edthlp read t edit /usr/local/squid/squid.conf sync; sync rc_squid restart ;; start) str # rc_masq restart ;; stop) stp # rc_masq restart ;; restart)stp;str # rc_masq restart ;; status) if [ "`fn2`" ] then echo "Running squid"; fn2 else echo No running squid fi;; esac