autoDeploy/frontEndUpgrade.sh
zhangkun9038@dingtalk.com 14d4970e82 update
2022-09-10 10:46:04 +00:00

83 lines
1.4 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
# Usage:
# ./frontEndUpgrade.sh html.zip "/etc/nginx"
fileName=$1
projectPath=$2
PATH=PATH:/usr/bin:/usr/sbin
echo "1"
projectName="${fileName%.*}"
cd ~
echo "current path: $(pwd)"
if [ ! -f "$fileName" ];then
echo "文件 $fileName 不存在1!"
exit 0
fi
echo "2"
rm dist -fr
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 fileno need to replace"
exit 0
fi
cd ~
rm dist -fr
rm $projectName -fr
unzip $fileName -fq
echo "projectName: ${projectName}"
mv dist ~/$projectName
cd $projectPath
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"