From 3075caa9cf68d76b42d0953fc3241d3de72e428d Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Wed, 7 Sep 2022 05:41:39 +0000 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=EF=BC=8C=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backEndUpgrade.sh | 51 ++++++++++++++++++++++++++++++++ dist/a.log | 4 +++ frontEndUpgrade.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100755 backEndUpgrade.sh create mode 100644 dist/a.log create mode 100755 frontEndUpgrade.sh diff --git a/backEndUpgrade.sh b/backEndUpgrade.sh new file mode 100755 index 0000000..b9c948c --- /dev/null +++ b/backEndUpgrade.sh @@ -0,0 +1,51 @@ +#!/bin/bash +fileName=$1 +projectPath=$2 + +cd ~ +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 file,no need to replace" + exit 0 +fi + +if [ -f "$fileName"_bak2 ];then + rm "${fileName}"_bak2 +fi +if [ -f "${fileName}"_bak1 ];then + mv ${fileName}_bak1 ${fileName}_bak2 +fi +if [ -f "$fileName"_bak ];then + mv ${fileName}_bak ${fileName}_bak1 +fi +if [ -f "$fileName" ];then + mv ${fileName} ${fileName}_bak +fi + +cp ~/"${fileName}" . diff --git a/dist/a.log b/dist/a.log new file mode 100644 index 0000000..929e8a2 --- /dev/null +++ b/dist/a.log @@ -0,0 +1,4 @@ +asdfsadasaasdfsasdadsasdffddfasdasdfwsasdawf +asdfsadasaasdfsasdadsasdffddfasdasdfwsasdawf +asoasdfsadasaasdfsasdadsasdffddfasdasdfwsasdawf +fdq3awef23y14t diff --git a/frontEndUpgrade.sh b/frontEndUpgrade.sh new file mode 100755 index 0000000..f69d6d7 --- /dev/null +++ b/frontEndUpgrade.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# Usage: +# ./frontEndUpgrade.sh html.zip "/etc/nginx" +fileName=$1 +projectPath=$2 +echo "1" +projectName="${fileName%.*}" +cd ~ +echo "current path: $(pwd)" +if [ ! -f "$fileName" ];then + echo "文件 $fileName 不存在1!" + exit 0 +fi + +echo "2" +rm dist -fr +unzip $fileName +echo "projectName: ${projectName}" +mv dist ~/$projectName +echo "3" +oriSum=$(md5sum $fileName) +oriSum="${oriSum% *}" +echo "origin file $fileName md5sum: $oriSum" +echo "4" + +if [ ! -d "$projectPath" ]; then + echo "文件夹 $prjectPath 不存在!" + exit 0 +fi + +echo "5" +cd $projectPath +desSum="" +echo "6" +if [ ! -d "$projectName" ];then + echo "6.0" + cp ~/$projectName . -r + exit 0 +else + desSum=$(md5sum $fileName) + desSum="${desSum% *}" + echo "6.1" + echo "current path: $(pwd)" + echo "destination file ${fileName} md5sum: ${desSum}" + echo "6.2" +fi + +echo "7" +if [ ${oriSum} = ${desSum} ];then + echo "destination file is same with origin file,no need to replace" + exit 0 +fi + +echo "8" +if [ -d "$projectName"_bak2 ];then + rm "${projectName}"_bak2 -fr +fi +echo "9" +if [ -d "${projectName}"_bak1 ];then + mv ${projectName}_bak1 ${projectName}_bak2 +fi +echo "10" +if [ -d "$projectName"_bak ];then + mv ${projectName}_bak ${projectName}_bak1 +fi +echo "11" +if [ -d "$projectName" ];then + mv ${projectName} ${projectName}_bak +fi + +echo "12" +cp ~/"${projectName}" . -r +cp ~/"${fileName}" . +echo "done"