update
This commit is contained in:
parent
eb898022f3
commit
852c55b516
107
checkService.sh
107
checkService.sh
@ -23,48 +23,75 @@ function uploadLog ()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cd $workDirectory
|
function compare(){
|
||||||
echo "current path: $(pwd)"
|
cd $workDirectory
|
||||||
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 "current path: $(pwd)"
|
||||||
echo "destination file ${fileName} md5sum: ${desSum}"
|
if [ ! -f "$fileName" ];then
|
||||||
fi
|
echo "文件 $fileName 不存在1!"
|
||||||
|
return -1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${oriSum} = ${desSum} ];then
|
oriSum=$(md5sum $fileName)
|
||||||
journalctl -n 1000 -xe -t autoDeploy > ${workDirectory}autoDeploy.log
|
oriSum="${oriSum% *}"
|
||||||
${workDirectory}ossutil cp ${workDirectory}autoDeploy.log oss://ztupload/${ossPath}autoDeploy.log
|
echo "origin local temp file $fileName md5sum: |${oriSum}|"
|
||||||
echo "destination file is same with origin file,no need to replace"
|
|
||||||
|
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 file,no 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
|
uploadLog
|
||||||
|
echo "ok: checkService done"
|
||||||
|
echo " "
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
}
|
||||||
|
|
||||||
systemctl restart $serviceName
|
main
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "error: systemctl restart ${serviceName} failed!"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "ok: systemctl restart ${serviceName} success!"
|
|
||||||
|
|
||||||
sleep 10
|
|
||||||
uploadLog
|
|
||||||
|
@ -8,7 +8,7 @@ fileName=$2
|
|||||||
serviceName=$3
|
serviceName=$3
|
||||||
projectName="${fileName%.*}"
|
projectName="${fileName%.*}"
|
||||||
|
|
||||||
function foundNew(){
|
function compare(){
|
||||||
cd ~
|
cd ~
|
||||||
./ossutil stat oss://ztupload/${ossPath}$fileName > ${projectName}_oss.info
|
./ossutil stat oss://ztupload/${ossPath}$fileName > ${projectName}_oss.info
|
||||||
ossInfo=$(cat ${projectName}_oss.info)
|
ossInfo=$(cat ${projectName}_oss.info)
|
||||||
@ -64,7 +64,7 @@ function process(){
|
|||||||
function main(){
|
function main(){
|
||||||
echo " "
|
echo " "
|
||||||
echo "start ossUpgrade service"
|
echo "start ossUpgrade service"
|
||||||
foundNew
|
compare
|
||||||
result=$?
|
result=$?
|
||||||
echo "result $result"
|
echo "result $result"
|
||||||
if [ $result = 0 ];then
|
if [ $result = 0 ];then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user