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

View File

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