This commit is contained in:
zhangkun9038@dingtalk.com 2022-09-10 10:01:00 +00:00
parent eb898022f3
commit 852c55b516
2 changed files with 69 additions and 42 deletions

View File

@ -23,48 +23,75 @@ function uploadLog ()
fi fi
} }
cd $workDirectory function compare(){
echo "current path: $(pwd)" cd $workDirectory
if [ ! -f "$fileName" ];then echo "current path: $(pwd)"
if [ ! -f "$fileName" ];then
echo "文件 $fileName 不存在1!" echo "文件 $fileName 不存在1!"
exit 0 return -1
fi fi
oriSum=$(md5sum $fileName) oriSum=$(md5sum $fileName)
oriSum="${oriSum% *}" oriSum="${oriSum% *}"
echo "origin file $fileName md5sum: $oriSum" echo "origin local temp file $fileName md5sum: |${oriSum}|"
if [ ! -d "$projectPath" ]; then if [ ! -d "$projectPath" ]; then
echo "文件夹 $prjectPath 不存在!" echo "文件夹 $prjectPath 不存在!"
exit 0 return -1
fi fi
cd $projectPath cd $projectPath
desSum="" desSum=""
if [ ! -f "$fileName" ];then if [ ! -f "$fileName" ];then
cp ~/$fileName . cp ~/$fileName .
exit 0 return 0
else else
desSum=$(md5sum $fileName) desSum=$(md5sum $fileName)
desSum="${desSum% *}" desSum="${desSum% *}"
echo "current path: $(pwd)" echo "current path: $(pwd)"
echo "destination file ${fileName} md5sum: ${desSum}" echo "locfile in projectPath ${fileName} md5sum: |${desSum}|"
fi fi
if [ ${oriSum} = ${desSum} ];then if [ ${oriSum} = ${desSum} ];then
journalctl -n 1000 -xe -t autoDeploy > ${workDirectory}autoDeploy.log #journalctl -n 1000 -xe -t autoDeploy > ${workDirectory}autoDeploy.log
${workDirectory}ossutil cp ${workDirectory}autoDeploy.log oss://ztupload/${ossPath}autoDeploy.log return 0
echo "destination file is same with origin fileno need to replace" else
uploadLog return 1
exit 0 fi
fi }
systemctl restart $serviceName function restart(){
if [ $? -ne 0 ]; then systemctl restart $serviceName
if [ $? -ne 0 ]; then
echo "error: systemctl restart ${serviceName} failed!" echo "error: systemctl restart ${serviceName} failed!"
exit 0 exit 0
fi fi
echo "ok: systemctl restart ${serviceName} success!" echo "ok: systemctl restart ${serviceName} success!"
}
sleep 10 function main(){
uploadLog echo " "
echo "start checkService service"
compare
result=$?
echo "result $result"
if [ $result = 0 ];then
# uploadLog
echo "local temp file is same with oss fileno need to replace"
echo "ok: checkService done"
echo " "
exit 0
elif [ $result = 1 ]; then
echo "local temp file $fileName is different from oss, will download..."
else
exit 0
fi
restart
sleep 10
uploadLog
echo "ok: checkService done"
echo " "
exit 0
}
main

View File

@ -8,7 +8,7 @@ fileName=$2
serviceName=$3 serviceName=$3
projectName="${fileName%.*}" projectName="${fileName%.*}"
function foundNew(){ function compare(){
cd ~ cd ~
./ossutil stat oss://ztupload/${ossPath}$fileName > ${projectName}_oss.info ./ossutil stat oss://ztupload/${ossPath}$fileName > ${projectName}_oss.info
ossInfo=$(cat ${projectName}_oss.info) ossInfo=$(cat ${projectName}_oss.info)
@ -64,7 +64,7 @@ function process(){
function main(){ function main(){
echo " " echo " "
echo "start ossUpgrade service" echo "start ossUpgrade service"
foundNew compare
result=$? result=$?
echo "result $result" echo "result $result"
if [ $result = 0 ];then if [ $result = 0 ];then