#!/bin/bash
function cache(){
for i in `curl xxx.fe.xxx.cn/uplist.txt`;do
url=`echo $i|awk -F"#" '{print $1}'`
md5=`echo $i|awk -F"#" '{print $2}'`
file_name=`echo $url|awk -F'\/' '{print $NF}'`
cd /tmp;curl -O $url -x 127.0.0.1:80
if [ "`md5sum /tmp/$file_name|awk '{print $1}'`" == "$md5" ];then
echo "$file_name is ok"
elif [ "`md5sum /tmp/$file_name|awk '{print $1}'`" != "$md5" ];then
echo "$file_name is fail"
FILE=`echo $i|awk -F"#" '{print $1}' |awk -F '/' '{print $3}'`
CACHE_DIR=/xdfapp/data/cache/
echo "The file : $FILE to be clean nginx Cache ,please waiting ....."
for h in `echo $FILE `;do
grep -ra $h ${CACHE_DIR}| awk -F':' '{print $1}' > /tmp/cache_list.txt
for j in `cat /tmp/cache_list.txt`;do
rm -rf $j
echo "$h $j is Deleted Success !"
done
done
echo "echo "$h $j is Deleted Success !""
curl -O $url -x 127.0.0.1:80
[ $? -ne 0 ] && echo "Download fail!" && exit 1
else
echo "$file_name is fail------"
fi
done
}
cache