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

View File

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

View File

@ -39,26 +39,6 @@ function downloadFromOss(){
(./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(){
echo " "
echo "start ossUpgrade service"
@ -67,23 +47,13 @@ function main(){
if [ $result = 0 ];then
# uploadLog
echo "local temp file $fileName is same with oss fileno need to replace"
exit 0
echo "end ossUpgrade service"
echo " "
exit 0
else
echo "local temp file $fileName is different from oss, will download..."
fi
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 " "
}