This commit is contained in:
zhangkun9038@dingtalk.com 2022-09-15 09:09:47 +00:00
parent dc5c8c9f40
commit 8a8a4d3509
4 changed files with 21 additions and 35 deletions

View File

@ -51,3 +51,10 @@ if [ -f "$fileName" ];then
fi fi
cp ~/"${fileName}" . cp ~/"${fileName}" .
result=$?
if [ $result = 0 ];then
echo "file ${fileName} in ${projectPath} upgraded."
fi
newSum=$(md5sum $fileName)
newSum="${newSum% *}"
echo "the md5sum of new file is ${newSum} "

View File

@ -44,7 +44,7 @@ function compare(){
echo "origin local temp file $fileName md5sum: |${oriSum}|" echo "origin local temp file $fileName md5sum: |${oriSum}|"
if [ ! -d "$projectPath" ]; then if [ ! -d "$projectPath" ]; then
echo "文件夹 $prjectPath 不存在!" echo "文件夹 $projectPath 不存在!"
return -1 return -1
fi fi
@ -57,7 +57,7 @@ function compare(){
desSum=$(md5sum $fileName) desSum=$(md5sum $fileName)
desSum="${desSum% *}" desSum="${desSum% *}"
echo "current path: $(pwd)" echo "current path: $(pwd)"
echo "locfile in projectPath ${fileName} md5sum: |${desSum}|" echo "locfile in $projectPath ${fileName} md5sum: |${desSum}|"
fi fi
if [ ${oriSum} = ${desSum} ];then if [ ${oriSum} = ${desSum} ];then
@ -73,6 +73,8 @@ function restart(){
systemctl restart $serviceName systemctl restart $serviceName
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "error: systemctl restart ${serviceName} failed!" echo "error: systemctl restart ${serviceName} failed!"
sleep 3
uploadLog t "autoDeploy" 100
exit 0 exit 0
fi fi
echo "ok: systemctl restart ${serviceName} success!" echo "ok: systemctl restart ${serviceName} success!"
@ -101,7 +103,7 @@ function main(){
exit 0 exit 0
fi fi
restart restart
sleep 15 sleep 45
uploadLog u $serviceName 500 uploadLog u $serviceName 500
echo "ok: checkService done" echo "ok: checkService done"
echo " " echo " "

View File

@ -106,6 +106,11 @@ function replaceFile(){
return 0 return 0
} }
function verify() {
cd ~
cd $projectPath/${preName}
echo "the md5sum injected in ${projectPath}/${preName} is $(cat ${preName}_md5.txt)"
}
function main() { function main() {
echo " " echo " "
@ -130,8 +135,10 @@ function main() {
echo "error: replace faild" echo "error: replace faild"
exit 0 exit 0
fi fi
uploadLog t autoDeploy 100 sleep 3
verify
echo " " echo " "
uploadLog t autoDeploy 100
} }
main main

View File

@ -39,26 +39,6 @@ function downloadFromOss(){
(./ossutil stat oss://ztupload/${ossPath}$fileName | head -n -2) > ${projectName}_oss.info (./ossutil stat oss://ztupload/${ossPath}$fileName | head -n -2) > ${projectName}_oss.info
} }
# function uploadLog(){
# logPath=${ossPath%/*}
# logPath=${logPath%/*}/logs/
# osslogPath=oss://ztupload/${logPath}autoDeploy.log
# journalctl -n 1000 -xe -t autoDeploy > ~/autoDeploy.log
# if [ $? = 0 ];then
# echo "uploaded log to ${osslogPath}"
# fi
# }
# function isFrontEnd(){
# result=$(echo $fileName | grep ".zip")
# if [[ "$result" != "" ]]; then
# return 0
# else
# return 1
# fi
# }
function main(){ function main(){
echo " " echo " "
echo "start ossUpgrade service" echo "start ossUpgrade service"
@ -67,23 +47,13 @@ function main(){
if [ $result = 0 ];then if [ $result = 0 ];then
# uploadLog # uploadLog
echo "local temp file $fileName is same with oss fileno need to replace" echo "local temp file $fileName is same with oss fileno need to replace"
exit 0
echo "end ossUpgrade service" echo "end ossUpgrade service"
echo " " echo " "
exit 0
else else
echo "local temp file $fileName is different from oss, will download..." echo "local temp file $fileName is different from oss, will download..."
fi fi
downloadFromOss downloadFromOss
# uploadLog
echo "local temp file replaced"
# isFrontEnd
# result=$?
# if [ $result = 0 ];then
# preName=${fileName%/*}
# echo "frontEnd package ${preName} will cover to projectPath"
#
# fi
echo "end ossUpgrade service" echo "end ossUpgrade service"
echo " " echo " "
} }