qingli.sh www.xiuxiukan.com
qingli.sh jpg
qingli.sh xiuxiukan.com 123 bbb jpg
- #!/bin/sh
- squidcache_path="/squidcache"
- squidclient_path="/home/local/squid/bin/squidclient"
- #grep -a -r $1 $squidcache_path/* | grep "http:" | awk -F 'http:' '{print "http:"$2;}' | awk -F\' '{print $1}' > cache.txt
- if [[ "$1" == "swf" || "$1" == "png" || "$1" == "jpg" || "$1" == "ico" || "$1" == "gif" || "$1" == "css" || "$1" == "js" || "$1" == "html" || "$1" == "shtml" || "$1" == "htm" ]]; then
- grep -a -r .$1 $squidcache_path/* | strings | grep "http:" | awk -F 'http:' '{print "http:"$2;}' | awk -F\' '{print $1}' | grep "$1$" | uniq > cache.txt
- else
- grep -a -r $1 $squidcache_path/* | strings | grep "http:" |grep $2$ |grep $3$|grep $4$|grep $5$ |grep $6$| awk -F 'http:' '{print "http:"$2;}' | awk -F\' '{print $1}' | uniq > cache.txt
- fi
- sed -i "s/\";$//g" cache.txt
- cat cache.txt | while read LINE
- do
- $squidclient_path -p 80 -m PURGE $LINE
- done
squid启动文件
- cat >> /etc/init.d/squid <<EOF
- #!/bin/bash
- #chkconfig: 345 85 15
- #description: squid test
- #BY liyaoyi 2012-05-04
- . /etc/rc.d/init.d/functions
- squid="/usr/local/squid/sbin/squid"
- prog="squid"
- RETVAL=0
- start() {
- echo -n $"Starting $prog: "
- daemon $squid -s
- RETVAL=$?
- echo
- return $RETVAL
- }
- stop () {
- echo -n $"Stoping $prog: "
- daemon $squid -k shutdown
- echo
- return $RETVAL
- }
- reload () {
- echo -n $"Reloading $prog: "
- daemon $squid -k reconfigure
- echo
- return $RETVAL
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- reload)
- reload
- ;;
- restart)
- stop
- start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload}"
- RETVAL=1
- esac
- exit $RETVAL
- EOF
- chmod a+x /etc/init.d/squid
- chkconfig --add squid
- chkconfig squid on
- /etc/init.d/squid start
