From 34b30baf2fb443e7d62d6cbf010cbf578d5a89f6 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" <zhangkun9038@dingtalk.com> Date: Mon, 3 Apr 2023 18:14:43 +0800 Subject: [PATCH] obs --- backUpDB.sh | 4 +++- checkService.sh | 3 ++- dbUpgrade.sh | 5 +++-- frontEndUpgrade.sh | 4 +++- ossDetect.sh | 3 ++- ossUpgrade.sh | 8 ++++---- uplaodLog.sh | 3 ++- upload.sh | 3 ++- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/backUpDB.sh b/backUpDB.sh index c49be41..89991d5 100755 --- a/backUpDB.sh +++ b/backUpDB.sh @@ -8,6 +8,8 @@ dbName=$5 backUpPath=$6 ossPath=$7 +protal=obs + PATH=PATH:/usr/bin:/usr/sbin:/usr/local/bin cd $backUpPath @@ -24,4 +26,4 @@ mv ${dbName}.sql sql tar -czvf ${dbName}.sql.tar.gz sql echo "ossPath: "${ossPath} -ossutil cp ${dbName}.sql.tar.gz oss://${ossPath}/ -f +ossutil cp ${dbName}.sql.tar.gz ${protol}://${ossPath}/ -f diff --git a/checkService.sh b/checkService.sh index 9feadab..91d3d03 100755 --- a/checkService.sh +++ b/checkService.sh @@ -11,6 +11,7 @@ workPath=$4 ossLogPath=$5 preName="${fileName%.*}" +protal=obs PATH=PATH:/usr/bin:/usr/sbin:/usr/local/bin @@ -28,7 +29,7 @@ function uploadLog() echo "current user is ${USER}" echo "current log is " ${workPath}/${identify}.log journalctl -n $count -xe -${ctype} $identify | grep -wv " at " > ${workPath}/${identify}.log - ossutil cp -f ${workPath}/${identify}.log oss://${ossLogPath}/logs/${identify}.log + ossutil cp -f ${workPath}/${identify}.log ${protol}://${ossLogPath}/logs/${identify}.log if [ $? -eq 0 ]; then echo "ok: log ${identify} uploaded to oss!" return 0 diff --git a/dbUpgrade.sh b/dbUpgrade.sh index c44669a..613e86f 100755 --- a/dbUpgrade.sh +++ b/dbUpgrade.sh @@ -13,6 +13,7 @@ ossPath=$7 projectName="sql" projectPath=${tempPath}/${projectName} +protal=obs function init(){ cd $tempPath @@ -51,7 +52,7 @@ function replaceAndExec(){ rm sqlOut.log cp $tempPath/$sqlFile . /usr/bin/mysql -u${dbUser} -p${dbPassword} -P${dbPort} -e "$(cat ${sqlFile})" | tee sqlOut.log - ossutil cp -f sqlOut.log oss://${ossPath}/${dbHost}/sqlOut.log + ossutil cp -f sqlOut.log ${protol}://${ossPath}/${dbHost}/sqlOut.log } function uploadLog() { @@ -60,7 +61,7 @@ function uploadLog() count=$3 echo "current user is ${USER}" journalctl -n $count -xe -${ctype} $identify > ${tempPath}/${identify}.log - ossutil cp -f ${tempPath}/${identify}.log oss://${ossPath}/${dbHost}/${identify}.log + ossutil cp -f ${tempPath}/${identify}.log ${protol}://${ossPath}/${dbHost}/${identify}.log if [ $? -eq 0 ]; then echo "ok: log ${identify} uploaded to oss!" return 0 diff --git a/frontEndUpgrade.sh b/frontEndUpgrade.sh index 0bd99ad..00190a3 100755 --- a/frontEndUpgrade.sh +++ b/frontEndUpgrade.sh @@ -8,6 +8,8 @@ workPath=$3 ossLogPath=$4 user=$USER +protal=obs + if [ -n $5 ]; then user=$5 fi @@ -28,7 +30,7 @@ function uploadLog() count=$3 echo "current user is ${USER}" journalctl -n $count -xe -${ctype} $identify > ${workPath}/${identify}.log - ossutil cp -f ${workPath}/${identify}.log oss://${ossLogPath}/logs/${identify}.log + ossutil cp -f ${workPath}/${identify}.log ${protol}://${ossLogPath}/logs/${identify}.log if [ $? -eq 0 ]; then echo "ok: log ${identify} uploaded to oss!" return 0 diff --git a/ossDetect.sh b/ossDetect.sh index bdc6c88..08a00b8 100755 --- a/ossDetect.sh +++ b/ossDetect.sh @@ -1,7 +1,8 @@ #!/bin/bash +protal=obs cd /tmp/autoDeploy -ossutil stat oss://ztupload/html.zip > html_oss.info +ossutil stat ${protol}://ztupload/html.zip > html_oss.info ossInfo=$(cat html_oss.info) out1=${ossInfo##*Etag} echo $out1 diff --git a/ossUpgrade.sh b/ossUpgrade.sh index f8a100a..aacdc91 100755 --- a/ossUpgrade.sh +++ b/ossUpgrade.sh @@ -20,8 +20,8 @@ function compare(){ if [ ! -f ${fileName}_oss.info ]; then touch ${fileName}_oss.info fi - echo upstream ossPath: oss://${ossPath}$fileName - ( ossutil stat oss://${ossPath}$fileName | head -n -2) > ${fileName}_upstream_oss.info + echo upstream ossPath: ${protol}://${ossPath}$fileName + ( ossutil stat ${protol}://${ossPath}$fileName | head -n -2) > ${fileName}_upstream_oss.info upstreamOssInfoMd5=$(md5sum ${fileName}_upstream_oss.info) upstreamOssInfoMd5="${upstreamOssInfoMd5% *}" locOssInfoMd5=$(md5sum ${fileName}_oss.info) @@ -42,10 +42,10 @@ function compare(){ function downloadFromOss(){ cd $basePath echo "fileName: " $fileName - ossutil cp -f oss://${ossPath}${fileName} ${fileName}_tmp + ossutil cp -f ${protol}://${ossPath}${fileName} ${fileName}_tmp rm $fileName mv ${fileName}_tmp $fileName - ( ossutil stat oss://${ossPath}$fileName | head -n -2) > ${fileName}_oss.info + ( ossutil stat ${protol}://${ossPath}$fileName | head -n -2) > ${fileName}_oss.info } function main(){ diff --git a/uplaodLog.sh b/uplaodLog.sh index 1a6aaaf..2123bc4 100755 --- a/uplaodLog.sh +++ b/uplaodLog.sh @@ -4,6 +4,7 @@ # ./ossUpgrade.sh "stage/ztsjxxxt/frontEnd/" ztsjxxxt ossPath=$1 #末尾别忘了加/ serviceName=$2 +protal=obs sudo journalctl -n 2000 -xeu $serviceName > ${serviceName}.log -ossutil cp ${serviceName}.log > oss://${ossPath} +ossutil cp ${serviceName}.log > ${protol}://${ossPath} diff --git a/upload.sh b/upload.sh index c954dde..8a6dff6 100755 --- a/upload.sh +++ b/upload.sh @@ -1,4 +1,5 @@ dataCenterPath=~/data_center +protal=obs function fetch() { for file in ${dataCenterPath}/jars/*.jar @@ -6,7 +7,7 @@ function fetch() if [ -f "$file" ] then fileName=${file##*/} - ossutil cp -f $file oss://ztupload/stage/dataCenter/backEnd/$fileName & + ossutil cp -f $file ${protol}://ztupload/stage/dataCenter/backEnd/$fileName & echo file: $fileName fi done