From 97e2a358e8ebe5996910b54dd381677b4870e913 Mon Sep 17 00:00:00 2001 From: lizw <1183409807@qq.com> Date: Mon, 13 Jun 2022 14:52:40 +0800 Subject: [PATCH] 01yvan-ext.sh --- 00base/01yvan-ext.sh | 99 +++++++++++++++++++++++++++++++++++++++ 00base/02yvan-ext-mobile.sh | 0 00base/03xxl-job.sh | 0 01dongying_guokang/01wms8-test.sh | 0 4 files changed, 99 insertions(+) create mode 100644 00base/01yvan-ext.sh create mode 100644 00base/02yvan-ext-mobile.sh create mode 100644 00base/03xxl-job.sh create mode 100644 01dongying_guokang/01wms8-test.sh diff --git a/00base/01yvan-ext.sh b/00base/01yvan-ext.sh new file mode 100644 index 0000000..06c0c93 --- /dev/null +++ b/00base/01yvan-ext.sh @@ -0,0 +1,99 @@ +#!/bin/bash +#set -x +set -e + +codePath=/home/www/deploy/yvan-ext +gitUrlArr=( + "http://git.yvanui.com/jztd/yvan-ext.git" +) + +branchArr=( + "master" +) +positionArr=( + "." +) +# 是否需要构建,-1:自动;0:不需要;1:需要 +needBuild=( +"1" +) + +echoPrefix="\033[36m+" +echoSuffix="\033[0m" + +isChange="1" +pullCode() { + # Usage: pullCode "codePath" "gitUrl" "branch" "position" + path=$1 # 代码保存路径 + gitUrl=$2 # git仓库地址 + branch=${3:-"master"} # git分支 + position=${4:-""} # 使用“.”clone到当前文件夹 + isChange="1" + # 创建文件夹 + if [ ! -d "$path" ]; then + echo -e "$echoPrefix 请检查服务器是否正确,再执行: mkdir -p $path $echoSuffix" + exit + fi + + # git clone + echo -e "$echoPrefix cd $path $echoSuffix" + cd $path + if [ "`ls -A $path`" == "" ] || [ ! -d "$path/$position" ] || [ "`ls -A $path/$position`" = "" ]; then + echo -e "$echoPrefix git clone $gitUrl $position $echoSuffix" + git clone $gitUrl $position + isChange="2" + fi + + # 进入文件夹,切换分支,git pull + if [ "$position" != "" ]; then + echo -e "$echoPrefix cd $position $echoSuffix" + cd $position + fi + echo -e "$echoPrefix git checkout $branch $echoSuffix" + git checkout $branch + echo -e "$echoPrefix git checkout . $echoSuffix" + git checkout . + echo -e "$echoPrefix git pull $echoSuffix" + if [ "`git pull`" == "Already up-to-date." ] && [ $isChange == "1" ]; then + isChange="0" + fi + echo "" +} + +buildCode() { + # 构建 yvan-ext + if [ "${needBuild[0]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath $echoSuffix" + cd "$codePath" + echo -e "$echoPrefix yarn $echoSuffix" + yarn + echo -e "$echoPrefix yarn link $echoSuffix" + yarn link + echo -e "$echoPrefix yarn build $echoSuffix" + yarn build + echo "" + else + echo "yvan-ext 文件未变化" + fi +} + +deployPull() { + for ((idx=0; idx<${#gitUrlArr[@]}; idx++)); do + pullCode $codePath ${gitUrlArr[idx]} ${branchArr[idx]} ${positionArr[idx]} + if [ "${needBuild[idx]}" == "-1" ]; then + needBuild[idx]=$isChange + fi + done + echo "###--代码更新完成--------------------------------------------------------------------------###" + echo "" +} + +cmd=$1 +if [ "$cmd" == "deploy" ];then + deployPull + buildCode +else + echo "输入操作参数: deploy" +fi + +# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/01yvan-ext.sh) [cmd] diff --git a/00base/02yvan-ext-mobile.sh b/00base/02yvan-ext-mobile.sh new file mode 100644 index 0000000..e69de29 diff --git a/00base/03xxl-job.sh b/00base/03xxl-job.sh new file mode 100644 index 0000000..e69de29 diff --git a/01dongying_guokang/01wms8-test.sh b/01dongying_guokang/01wms8-test.sh new file mode 100644 index 0000000..e69de29