autoDeploy/checkService.sh
zhangkun9038@dingtalk.com 66b020b005 checkService
2022-09-08 14:23:26 +00:00

50 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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