checkService

This commit is contained in:
zhangkun9038@dingtalk.com 2022-09-08 14:23:26 +00:00
parent 3075caa9cf
commit 66b020b005
6 changed files with 1106 additions and 0 deletions

1001
a.log Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
fileName=$1 fileName=$1
projectPath=$2 projectPath=$2
PATH=PATH:/usr/bin:/usr/sbin
cd ~ cd ~
echo "current path: $(pwd)" echo "current path: $(pwd)"

49
checkService.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
fileName=$1
projectPath=$2
serviceName=$3
workDirectory=$4
ossPath=$5
PATH=PATH:/usr/bin:/usr/sbin
## Usage
## ./checkService.sh ztsjxxxt.jar "/usr/local/jar" ztsjxxxt "/home/ubuntu/"
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% *}"
echo "current path: $(pwd)"
echo "destination file ${fileName} md5sum: ${desSum}"
fi
if [ ${oriSum} = ${desSum} ];then
echo "destination file is same with origin fileno need to replace"
exit 0
fi
sudo systemctl restart $serviceName
sleep 10
journalctl -n 1000 -xe -t autoDeploy > ${workDirectory}autoDeploy.log
${workDirectory}ossutil cp ${workDirectory}autoDeploy.log oss://ztupload/${ossPath}autoDeploy.log

View File

@ -3,6 +3,7 @@
# ./frontEndUpgrade.sh html.zip "/etc/nginx" # ./frontEndUpgrade.sh html.zip "/etc/nginx"
fileName=$1 fileName=$1
projectPath=$2 projectPath=$2
PATH=PATH:/usr/bin:/usr/sbin
echo "1" echo "1"
projectName="${fileName%.*}" projectName="${fileName%.*}"
cd ~ cd ~

46
ossUpgrade.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/bash
#usage:
# ./ossUpgrade.sh "stage/ztsjxxxt/frontEnd/" html.zip ztsjxxxt
ossPath=$1 #末尾别忘了加/
fileName=$2
projectName="${fileName%.*}"
PATH=PATH:/usr/bin:/usr/sbin
cd ~
./ossutil stat oss://ztupload/${ossPath}$fileName > ${projectName}_oss.info
ossInfo=$(cat ${projectName}_oss.info)
out=${ossInfo##*Etag}
out=${out%Last*}
out=${out#*: }
ossSum=${out,,}
ossSum="${ossSum% *}"
echo "oss md5:"$ossSum
result=$(echo $ossInfo | grep "error")
if [[ "$result" != "" ]]; then
echo $result
exit 0
fi
curSum=$(md5sum $fileName)
curSum="${curSum% *}"
if [ "${curSum}" = "" ];then
./ossutil cp oss://ztupload/${ossPath}$fileName > ${fileName}
curSum=$(md5sum $fileName)
curSum="${curSum% *}"
fi
echo "local file $fileName md5:"$curSum
all=$ossSum
echo "oriMd5: "$all
all=$curSum
echo "curMd5: "$all
if [ ${ossSum} = ${curSum} ];then
echo "destination file is same with oss fileno need to replace"
exit 0
else
echo "local file $fileName is different from oss, will download..."
fi
rm $fileName
echo "fileName: " $fileName
./ossutil cp oss://ztupload/${ossPath}${fileName} ${fileName}
echo "replaced"

8
uplaodLog.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
#usage:
# ./ossUpgrade.sh "stage/ztsjxxxt/frontEnd/" ztsjxxxt
ossPath=$1 #末尾别忘了加/
serviceName=$2
sudo journalctl -n 2000 -xeu $serviceName > ${serviceName}.log
./ossutil cp ${serviceName}.log > oss://ztupload/${ossPath}