SH:www.zip 调度解压脚本

#!/bin/sh

logfile=/root/s.log

logstr="BEGIN"" `date `"

if [ -d "/opt/apache-tomcat-8.0.36/webapps/PlanX" ];then

cd /opt/apache-tomcat-8.0.36/webapps/PlanX

md5str1=`md5sum www.zip |awk -F " " '{print $1}' |tr -d ' '`

omd5=`cat www.md5`

if [ "$md5str1" == "$omd5" ];then

#echo "www.zip is validated!"

#echo "begin to check if needs unzipping!"

logstr="$logstr""|v-check"

else

#echo "www.zip is uploading,or something wrong. exit!"

#echo "$md5str1:$omd5"

logstr="$logstr""|wrong exit"

echo $logstr

exit 1

fi

if [ -f "www.last.md5" ];then

md5str2=`cat www.last.md5`

# echo $md5str1:$md5str2

if [ "$md5str1" == "$md5str2" ];then

#echo "`date +"%Y-%m-%d %H:%M:%S"` no needs unzipping"

#echo " $md5str1:$md5str2 is the same."

logstr="$logstr""|same"

else

#echo "needs unzipping"

unzip www.zip

\cp -rf www/* .

rm -rfwww

echo $md5str1>www.last.md5

#echo "`date +"%Y-%m-%d %H:%M:%S"` www.zip is updated"

#echo "www.zip is unzipped to website"

logstr="$logstr""|updated"

fi

else

echo $md5str1>www.last.md5

#echo "`date +"%Y-%m-%d %H:%M:%S` first check"

logstr="$logstr""|first"

fi

fi

logstr="$logstr"" END: `date `"

echo $logstr

推荐阅读更多精彩内容