update scripts
parent
c1e96a7134
commit
e1773d60e6
|
@ -1,39 +1,47 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------
|
#!/usr/bin/env bash
|
||||||
# 控制台颜色
|
|
||||||
BLACK="\033[1;30m"
|
# ------------------------------------------------------------------------------
|
||||||
RED="\033[1;31m"
|
# CentOS 常用软件一键安装脚本
|
||||||
GREEN="\033[1;32m"
|
# @author Zhang Peng
|
||||||
YELLOW="\033[1;33m"
|
# ------------------------------------------------------------------------------
|
||||||
BLUE="\033[1;34m"
|
|
||||||
PURPLE="\033[1;35m"
|
# ------------------------------------------------------------------------------ libs
|
||||||
CYAN="\033[1;36m"
|
# 装载其它库
|
||||||
RESET="$(tput sgr0)"
|
LINUX_SCRIPTS_DIR=$(cd `dirname $0`; pwd)
|
||||||
# ---------------------------------------------------------------------------------
|
|
||||||
|
if [[ ! -x ${LINUX_SCRIPTS_DIR}/lib/utils.sh ]]; then
|
||||||
|
logError "必要脚本库 ${LINUX_SCRIPTS_DIR}/lib/utils.sh 不存在!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source ${LINUX_SCRIPTS_DIR}/lib/utils.sh
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------ functions
|
||||||
|
|
||||||
# 打印头部信息
|
# 打印头部信息
|
||||||
printHeadInfo() {
|
printHeadInfo() {
|
||||||
printf "${BLUE}\n"
|
printf "${C_B_BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 欢迎使用 Dunwu Shell 运维脚本
|
# 欢迎使用 Dunwu Shell 运维脚本
|
||||||
# 适用于 Linux CentOS 环境
|
# 适用于 Linux CentOS 环境
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
EOF
|
EOF
|
||||||
printf "${RESET}\n"
|
printf "${C_RESET}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 打印尾部信息
|
# 打印尾部信息
|
||||||
printFootInfo() {
|
printFootInfo() {
|
||||||
printf "${BLUE}\n"
|
printf "${C_B_BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 脚本执行结束,感谢使用!
|
# 脚本执行结束,感谢使用!
|
||||||
###################################################################################
|
###################################################################################
|
||||||
EOF
|
EOF
|
||||||
printf "${RESET}\n"
|
printf "${C_RESET}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 检查操作系统环境
|
# 检查操作系统环境
|
||||||
|
@ -41,13 +49,13 @@ checkOsVersion() {
|
||||||
if (($1 == 1)); then
|
if (($1 == 1)); then
|
||||||
platform=`uname -i`
|
platform=`uname -i`
|
||||||
if [[ ${platform} != "x86_64" ]]; then
|
if [[ ${platform} != "x86_64" ]]; then
|
||||||
printf "\n${RED}脚本仅支持 64 位操作系统!${RESET}\n"
|
logError "脚本仅支持 64 位操作系统!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version=`cat /etc/redhat-release | awk '{print substr($4,1,1)}'`
|
version=`cat /etc/redhat-release | awk '{print substr($4,1,1)}'`
|
||||||
if [[ ${version} != 7 ]]; then
|
if [[ ${version} != 7 ]]; then
|
||||||
printf "\n${RED}脚本仅支持 CentOS 7!${RESET}\n"
|
logError "脚本仅支持 CentOS 7!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -70,7 +78,7 @@ selectAndExecTask() {
|
||||||
printFootInfo
|
printFootInfo
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*)
|
*)
|
||||||
printf "\n${RED}输入项不支持!${RESET}\n"
|
logWarn "输入项不支持!"
|
||||||
selectAndExecTask ;;
|
selectAndExecTask ;;
|
||||||
esac
|
esac
|
||||||
break
|
break
|
||||||
|
@ -78,6 +86,7 @@ selectAndExecTask() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
######################################## MAIN ########################################
|
# ------------------------------------------------------------------------------ main
|
||||||
|
|
||||||
checkOsVersion 1
|
checkOsVersion 1
|
||||||
selectAndExecTask
|
selectAndExecTask
|
||||||
|
|
|
@ -1,30 +1,38 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# 控制台颜色
|
# CentOS 常用软件一键安装脚本
|
||||||
BLACK="\033[1;30m"
|
# @author Zhang Peng
|
||||||
RED="\033[1;31m"
|
# ------------------------------------------------------------------------------
|
||||||
GREEN="\033[1;32m"
|
|
||||||
YELLOW="\033[1;33m"
|
|
||||||
BLUE="\033[1;34m"
|
|
||||||
PURPLE="\033[1;35m"
|
|
||||||
CYAN="\033[1;36m"
|
|
||||||
RESET="$(tput sgr0)"
|
|
||||||
# ---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
printf "${BLUE}\n"
|
# ------------------------------------------------------------------------------ libs
|
||||||
|
# 装载其它库
|
||||||
|
LINUX_SCRIPTS_DIR=$(cd `dirname $0`; pwd)
|
||||||
|
|
||||||
|
if [[ ! -x ${LINUX_SCRIPTS_DIR}/lib/utils.sh ]]; then
|
||||||
|
logError "必要脚本库 ${LINUX_SCRIPTS_DIR}/lib/utils.sh 不存在!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source ${LINUX_SCRIPTS_DIR}/lib/utils.sh
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------ functions
|
||||||
|
# 打印头部信息
|
||||||
|
printHeadInfo() {
|
||||||
|
printf "${C_B_BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 欢迎使用 Dunwu Shell 软件安装脚本
|
# 欢迎使用 CentOS 常用软件一键安装脚本
|
||||||
# 适用于 Linux CentOS 环境
|
# 适用于 Linux CentOS 环境
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
EOF
|
EOF
|
||||||
printf "${RESET}\n"
|
printf "${C_RESET}\n"
|
||||||
|
}
|
||||||
|
|
||||||
# print menu
|
# print menu
|
||||||
printMenu() {
|
printMenu() {
|
||||||
printf "${PURPLE}"
|
printf "${C_B_MAGENTA}"
|
||||||
menus=( docker fastdfs gitlab jdk8 jenkins kafka maven mongodb mysql nacos nexus nginx nodejs redis rocketmq tomcat8 zookeeper zsh exit )
|
menus=( docker fastdfs gitlab jdk8 jenkins kafka maven mongodb mysql nacos nexus nginx nodejs redis rocketmq tomcat8 zookeeper zsh exit )
|
||||||
for i in "${!menus[@]}"; do
|
for i in "${!menus[@]}"; do
|
||||||
index=`expr ${i} + 1`
|
index=`expr ${i} + 1`
|
||||||
|
@ -35,7 +43,7 @@ printMenu() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "\n\n${BLUE}请选择需要安装的软件:${RESET}"
|
printf "\n\n${C_B_BLUE}请选择需要安装的软件:${C_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# exec shell to install soft
|
# exec shell to install soft
|
||||||
|
@ -46,22 +54,24 @@ main() {
|
||||||
no=`expr ${index} - 1`
|
no=`expr ${index} - 1`
|
||||||
len=${#menus[*]}
|
len=${#menus[*]}
|
||||||
if [[ ${index} -gt ${len} ]]; then
|
if [[ ${index} -gt ${len} ]]; then
|
||||||
printf "${RED}输入项不支持!\n${RESET}"
|
logWarn "输入项不支持!"
|
||||||
exit -1
|
exit 1
|
||||||
fi
|
fi
|
||||||
key=${menus[$no]}
|
key=${menus[$no]}
|
||||||
if [[ ${key} == 'exit' ]]; then
|
if [[ ${key} == 'exit' ]]; then
|
||||||
printf "${GREEN}退出 Dunwu 软件安装脚本。\n${RESET}"
|
logInfo "退出软件安装脚本。"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
sh soft/${key}-install.sh
|
sh soft/${key}-install.sh
|
||||||
printf "\n"
|
printf "\n"
|
||||||
main
|
main
|
||||||
else
|
else
|
||||||
printf "${RED}输入项不支持!\n${RESET}"
|
logWarn "输入项不支持!"
|
||||||
exit -1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################## MAIN ########################################
|
# ------------------------------------------------------------------------------ main
|
||||||
|
|
||||||
|
printHeadInfo
|
||||||
main
|
main
|
||||||
|
|
|
@ -1,18 +1,26 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# 控制台颜色
|
# CentOS 环境初始化脚本
|
||||||
BLACK="\033[1;30m"
|
# @author Zhang Peng
|
||||||
RED="\033[1;31m"
|
# ------------------------------------------------------------------------------
|
||||||
GREEN="\033[1;32m"
|
|
||||||
YELLOW="\033[1;33m"
|
|
||||||
BLUE="\033[1;34m"
|
|
||||||
PURPLE="\033[1;35m"
|
|
||||||
CYAN="\033[1;36m"
|
|
||||||
RESET="$(tput sgr0)"
|
|
||||||
# ---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
printf "${BLUE}\n"
|
# ------------------------------------------------------------------------------ libs
|
||||||
|
# 装载其它库
|
||||||
|
LINUX_SCRIPTS_DIR=$(cd `dirname $0`; pwd)
|
||||||
|
|
||||||
|
if [[ ! -x ${LINUX_SCRIPTS_DIR}/lib/utils.sh ]]; then
|
||||||
|
logError "必要脚本库 ${LINUX_SCRIPTS_DIR}/lib/utils.sh 不存在!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source ${LINUX_SCRIPTS_DIR}/lib/utils.sh
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------ functions
|
||||||
|
|
||||||
|
# 打印头部信息
|
||||||
|
printHeadInfo() {
|
||||||
|
printf "${C_B_BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 欢迎使用 Dunwu Shell 环境初始化脚本(设置环境配置、安装基本的命令工具)
|
# 欢迎使用 Dunwu Shell 环境初始化脚本(设置环境配置、安装基本的命令工具)
|
||||||
|
@ -20,7 +28,8 @@ cat << EOF
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
EOF
|
EOF
|
||||||
printf "${RESET}\n"
|
printf "${C_RESET}\n"
|
||||||
|
}
|
||||||
|
|
||||||
menus=( "替换yum镜像" "安装基本的命令工具" "安装常用libs" "系统配置" "全部执行" "退出" )
|
menus=( "替换yum镜像" "安装基本的命令工具" "安装常用libs" "系统配置" "全部执行" "退出" )
|
||||||
main() {
|
main() {
|
||||||
|
@ -29,33 +38,34 @@ main() {
|
||||||
do
|
do
|
||||||
case ${item} in
|
case ${item} in
|
||||||
"替换yum镜像")
|
"替换yum镜像")
|
||||||
sh ${path}/sys/change-yum-repo.sh
|
sh ${LINUX_SCRIPTS_DIR}/sys/change-yum-repo.sh
|
||||||
main ;;
|
main ;;
|
||||||
"安装基本的命令工具")
|
"安装基本的命令工具")
|
||||||
sh ${path}/sys/install-tools.sh
|
sh ${LINUX_SCRIPTS_DIR}/sys/install-tools.sh
|
||||||
main ;;
|
main ;;
|
||||||
"安装常用libs")
|
"安装常用libs")
|
||||||
sh ${path}/sys/install-libs.sh
|
sh ${LINUX_SCRIPTS_DIR}/sys/install-libs.sh
|
||||||
main ;;
|
main ;;
|
||||||
"系统配置")
|
"系统配置")
|
||||||
sh ${path}/sys/sys-settings.sh ${path}/sys
|
sh ${LINUX_SCRIPTS_DIR}/sys/sys-settings.sh ${LINUX_SCRIPTS_DIR}/sys
|
||||||
main ;;
|
main ;;
|
||||||
"全部执行")
|
"全部执行")
|
||||||
sh ${path}/sys/change-yum-repo.sh
|
sh ${LINUX_SCRIPTS_DIR}/sys/change-yum-repo.sh
|
||||||
sh ${path}/sys/install-tools.sh
|
sh ${LINUX_SCRIPTS_DIR}/sys/install-tools.sh
|
||||||
sh ${path}/sys/install-libs.sh
|
sh ${LINUX_SCRIPTS_DIR}/sys/install-libs.sh
|
||||||
sh ${path}/sys/sys-settings.sh ${path}/sys
|
sh ${LINUX_SCRIPTS_DIR}/sys/sys-settings.sh ${LINUX_SCRIPTS_DIR}/sys
|
||||||
printf "${GREEN}执行完毕,退出。${RESET}\n" ;;
|
logInfo "执行完毕,退出" ;;
|
||||||
"退出")
|
"退出")
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*)
|
*)
|
||||||
printf "${RED}输入项不支持!${RESET}\n"
|
logWarn "输入项不支持!"
|
||||||
main ;;
|
main ;;
|
||||||
esac
|
esac
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################## MAIN ########################################
|
# ------------------------------------------------------------------------------ main
|
||||||
path=$(pwd)
|
|
||||||
|
printHeadInfo
|
||||||
main
|
main
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# 构建 Docker 镜像 脚本
|
||||||
|
# @author Zhang Peng
|
||||||
|
# @since 2020/1/14
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# 装载其它库
|
||||||
|
LINUX_SCRIPTS_LIB_DIR=`dirname ${BASH_SOURCE[0]}`
|
||||||
|
source ${LINUX_SCRIPTS_LIB_DIR}/utils.sh
|
||||||
|
|
||||||
|
dockerBuild() {
|
||||||
|
if [[ ! $1 ]] || [[ ! $2 ]] || [[ ! $3 ]]; then
|
||||||
|
logError "you must input following params in order:"
|
||||||
|
echo -e "${C_B_RED}"
|
||||||
|
echo " (1) source"
|
||||||
|
echo " (2) repository"
|
||||||
|
echo " (3) tag"
|
||||||
|
echo -e "\nEg. dockerBuild /home/workspace dunwu/dockerApp 0.0.1"
|
||||||
|
echo -e "${C_RESET}"
|
||||||
|
return ${FAILED}
|
||||||
|
fi
|
||||||
|
|
||||||
|
local source=$1
|
||||||
|
local repository=$2
|
||||||
|
local tag=$3
|
||||||
|
|
||||||
|
dockerCheck ${source}
|
||||||
|
if [[ "${SUCCEED}" != "$?" ]]; then
|
||||||
|
return ${FAILED}
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ${source}
|
||||||
|
callAndLog docker build -t ${repository}:${tag} .
|
||||||
|
if [[ "${SUCCEED}" != "$?" ]]; then
|
||||||
|
logError "docker build -t ${repository}:${tag} failed"
|
||||||
|
return ${FAILED}
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd -
|
||||||
|
}
|
||||||
|
|
||||||
|
dockerPush() {
|
||||||
|
if [[ ! $1 ]] || [[ ! $2 ]]; then
|
||||||
|
logError "you must input following params in order:"
|
||||||
|
echo -e "${C_B_RED}"
|
||||||
|
echo " (1) repository"
|
||||||
|
echo " (2) tag"
|
||||||
|
echo -e "\nEg. dockerBuild dunwu/dockerApp 0.0.1"
|
||||||
|
echo -e "${C_RESET}"
|
||||||
|
return ${FAILED}
|
||||||
|
fi
|
||||||
|
|
||||||
|
local repository=$1
|
||||||
|
local tag=$2
|
||||||
|
|
||||||
|
# 如果 docker 镜像已存在,则删除镜像
|
||||||
|
local dockerHashId=$(docker image ls | grep ${repository} | grep ${tag} | awk '{print $3}')
|
||||||
|
if [[ ! ${dockerHashId} ]]; then
|
||||||
|
logInfo "try to delete existed image: ${repository}:${tag}"
|
||||||
|
callAndLog docker rmi ${dockerHashId}
|
||||||
|
fi
|
||||||
|
|
||||||
|
logInfo "try to push new image: ${repository}:${tag}"
|
||||||
|
callAndLog docker push ${repository}:${tag}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 判断指定路径下是否为 docker 工程
|
||||||
|
# @param $1: 第一个参数为 docker 项目路径
|
||||||
|
dockerCheck() {
|
||||||
|
local source=$1
|
||||||
|
if [[ -d "${source}" ]]; then
|
||||||
|
cd ${source}
|
||||||
|
if [[ -f "${source}/Dockerfile" ]]; then
|
||||||
|
return ${YES}
|
||||||
|
else
|
||||||
|
logError "Dockerfile is not exists"
|
||||||
|
return ${NO}
|
||||||
|
fi
|
||||||
|
cd -
|
||||||
|
return ${YES}
|
||||||
|
else
|
||||||
|
logError "${source} is not valid docker project"
|
||||||
|
return ${NO}
|
||||||
|
fi
|
||||||
|
}
|
|
@ -1,103 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# 常用变量库
|
|
||||||
# @author Zhang Peng
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------ 颜色状态
|
|
||||||
|
|
||||||
# Regular Color
|
|
||||||
C_BLACK="\033[0;30m"
|
|
||||||
C_RED="\033[0;31m"
|
|
||||||
C_GREEN="\033[0;32m"
|
|
||||||
C_YELLOW="\033[0;33m"
|
|
||||||
C_BLUE="\033[0;34m"
|
|
||||||
C_MAGENTA="\033[0;35m"
|
|
||||||
C_CYAN="\033[0;36m"
|
|
||||||
C_WHITE="\033[0;37m"
|
|
||||||
|
|
||||||
# Bold Color
|
|
||||||
C_B_BLACK="\033[1;30m"
|
|
||||||
C_B_RED="\033[1;31m"
|
|
||||||
C_B_GREEN="\033[1;32m"
|
|
||||||
C_B_YELLOW="\033[1;33m"
|
|
||||||
C_B_BLUE="\033[1;34m"
|
|
||||||
C_B_MAGENTA="\033[1;35m"
|
|
||||||
C_B_CYAN="\033[1;36m"
|
|
||||||
C_B_WHITE="\033[1;37m"
|
|
||||||
|
|
||||||
# Underline Color
|
|
||||||
C_U_BLACK="\033[4;30m"
|
|
||||||
C_U_RED="\033[4;31m"
|
|
||||||
C_U_GREEN="\033[4;32m"
|
|
||||||
C_U_YELLOW="\033[4;33m"
|
|
||||||
C_U_BLUE="\033[4;34m"
|
|
||||||
C_U_MAGENTA="\033[4;35m"
|
|
||||||
C_U_CYAN="\033[4;36m"
|
|
||||||
C_U_WHITE="\033[4;37m"
|
|
||||||
|
|
||||||
# Background Color
|
|
||||||
C_BG_BLACK="\033[40m"
|
|
||||||
C_BG_RED="\033[41m"
|
|
||||||
C_BG_GREEN="\033[42m"
|
|
||||||
C_BG_YELLOW="\033[43m"
|
|
||||||
C_BG_BLUE="\033[44m"
|
|
||||||
C_BG_MAGENTA="\033[45m"
|
|
||||||
C_BG_CYAN="\033[46m"
|
|
||||||
C_BG_WHITE="\033[47m"
|
|
||||||
|
|
||||||
# Reset Color
|
|
||||||
C_RESET="$(tput sgr0)"
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------ 常用状态值
|
|
||||||
|
|
||||||
YES=0
|
|
||||||
NO=1
|
|
||||||
SUCCEED=0
|
|
||||||
FAILED=1
|
|
||||||
|
|
||||||
# 显示打印日志的时间
|
|
||||||
DATE=`date "+%Y-%m-%d %H:%M:%S"`
|
|
||||||
# 那个用户在操作
|
|
||||||
USER=$(whoami)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------ log
|
|
||||||
|
|
||||||
logInfo() {
|
|
||||||
#($0脚本本身,$@将参数作为整体传输调用)
|
|
||||||
echo "[${DATE}] [${USER}] [INFO] [$0] [$@] execute succeed." >> /var/log/shell.log
|
|
||||||
}
|
|
||||||
|
|
||||||
logWarn() {
|
|
||||||
#($0脚本本身,$@将参数作为整体传输调用)
|
|
||||||
echo "[${DATE}] [${USER}] [WARN] [$0] [$@] execute succeed." >> /var/log/shell.log
|
|
||||||
}
|
|
||||||
|
|
||||||
logError() {
|
|
||||||
#($0脚本本身,$@将参数作为整体传输调用)
|
|
||||||
echo "[${DATE}] [${USER}] [ERROR] [$0] [$@] execute failed." >> /var/log/shell.log
|
|
||||||
}
|
|
||||||
|
|
||||||
printInfo() {
|
|
||||||
echo -e "${C_B_GREEN}[INFO] $@${C_RESET}"
|
|
||||||
}
|
|
||||||
|
|
||||||
printWarn() {
|
|
||||||
echo -e "${C_B_YELLOW}[WARN] $@${C_RESET}"
|
|
||||||
}
|
|
||||||
|
|
||||||
printError() {
|
|
||||||
echo -e "${C_B_RED}[ERROR] $@${C_RESET}"
|
|
||||||
}
|
|
||||||
|
|
||||||
callAndLog () {
|
|
||||||
$*
|
|
||||||
if [[ $? -eq ${SUCCEED} ]]; then
|
|
||||||
logInfo "$@ succeed"
|
|
||||||
echo -e "${C_B_GREEN}[INFO] [$0] [$@] execute succeed.${C_RESET}"
|
|
||||||
else
|
|
||||||
logError "$@ failed"
|
|
||||||
echo -e "${C_B_RED}[ERROR] [$0] [$@] execute failed.${C_RESET}"
|
|
||||||
fi
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# 装载其它库
|
# 装载其它库
|
||||||
ROOT=`dirname ${BASH_SOURCE[0]}`
|
ROOT=`dirname ${BASH_SOURCE[0]}`
|
||||||
source ${ROOT}/env.sh
|
source ${ROOT}/utils.sh
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------ 文件操作函数
|
# ------------------------------------------------------------------------------ 文件操作函数
|
||||||
|
|
||||||
|
|
|
@ -6,24 +6,38 @@
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 装载其它库
|
# 装载其它库
|
||||||
ROOT=`dirname ${BASH_SOURCE[0]}`
|
LINUX_SCRIPTS_LIB_DIR=`dirname ${BASH_SOURCE[0]}`
|
||||||
source ${ROOT}/env.sh
|
|
||||||
|
if [[ ! -x ${LINUX_SCRIPTS_LIB_DIR}/utils.sh ]]; then
|
||||||
|
logError "必要脚本库 ${LINUX_SCRIPTS_LIB_DIR}/utils.sh 不存在!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source ${LINUX_SCRIPTS_LIB_DIR}/utils.sh
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------ git 操作函数
|
# ------------------------------------------------------------------------------ git 操作函数
|
||||||
|
|
||||||
|
GIT_LOCAL_BRANCH=
|
||||||
|
getGitLocalBranch() {
|
||||||
|
GIT_LOCAL_BRANCH=$(git symbolic-ref -q --short HEAD)
|
||||||
|
}
|
||||||
|
|
||||||
|
GIT_ORIGIN_BRANCH=
|
||||||
|
getGitOriginBranch() {
|
||||||
|
GIT_ORIGIN_BRANCH=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}")
|
||||||
|
}
|
||||||
|
|
||||||
# 检查指定的路径是不是一个 git 项目
|
# 检查指定的路径是不是一个 git 项目
|
||||||
checkGit() {
|
checkGit() {
|
||||||
local source=$1
|
local source=$1
|
||||||
if [[ -d "${source}" ]]; then
|
if [[ -d "${source}" ]]; then
|
||||||
cd ${source} || return ${NO}
|
cd ${source} || return ${NO}
|
||||||
# (1)删除git状态零时文件
|
# (1)删除git状态零时文件
|
||||||
if [[ -f "gitstatus.tmp" ]]; then
|
if [[ -f "gitstatus.tmp" ]]; then
|
||||||
rm -rf gitstatus.tmp
|
rm -rf gitstatus.tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# (2)判断是否存在 .git 目录
|
# (2)判断git是否可用
|
||||||
if [[ -d "./.git" ]]; then
|
|
||||||
# (3)判断git是否可用
|
|
||||||
git status &> gitstatus.tmp
|
git status &> gitstatus.tmp
|
||||||
local gitStatus=false
|
local gitStatus=false
|
||||||
grep -iwq 'not a git repository' gitstatus.tmp && gitStatus=false || gitStatus=true
|
grep -iwq 'not a git repository' gitstatus.tmp && gitStatus=false || gitStatus=true
|
||||||
|
@ -33,13 +47,12 @@ checkGit() {
|
||||||
else
|
else
|
||||||
return ${NO}
|
return ${NO}
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
return ${NO}
|
return ${NO}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "${C_B_YELLOW}${source} is invalid dir.${C_RESET}\n"
|
logError "${source} is invalid dir."
|
||||||
return ${NO}
|
return ${NO}
|
||||||
}
|
}
|
||||||
|
|
||||||
# clone 或 fetch 操作
|
# clone 或 fetch 操作
|
||||||
|
@ -54,18 +67,18 @@ cloneOrPullGit() {
|
||||||
local root=$5
|
local root=$5
|
||||||
|
|
||||||
if [[ ! ${repository} ]] || [[ ! ${group} ]] || [[ ! ${project} ]] || [[ ! ${branch} ]] || [[ ! ${root} ]]; then
|
if [[ ! ${repository} ]] || [[ ! ${group} ]] || [[ ! ${project} ]] || [[ ! ${branch} ]] || [[ ! ${root} ]]; then
|
||||||
printf "${C_B_YELLOW}Please input root, group, project, branch.${C_RESET}\n"
|
logError "Please input root, group, project, branch."
|
||||||
return ${FAILED}
|
return ${FAILED}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d "${root}" ]]; then
|
if [[ ! -d "${root}" ]]; then
|
||||||
printf "${C_B_YELLOW}${root} is not directory.${C_RESET}\n"
|
logError "${root} is not directory."
|
||||||
return ${FAILED}
|
return ${FAILED}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local source=${root}/${group}/${project}
|
local source=${root}/${group}/${project}
|
||||||
printf "${C_B_MAGENTA}project directory is ${source}.${C_RESET}\n"
|
logInfo "project directory is ${source}."
|
||||||
printf "${C_B_MAGENTA}git url is ${repository}:${group}/${project}.git.${C_RESET}\n"
|
logInfo "git url is ${repository}:${group}/${project}.git."
|
||||||
mkdir -p ${root}/${group}
|
mkdir -p ${root}/${group}
|
||||||
|
|
||||||
checkGit ${source}
|
checkGit ${source}
|
||||||
|
@ -75,44 +88,46 @@ cloneOrPullGit() {
|
||||||
|
|
||||||
git checkout -f ${branch}
|
git checkout -f ${branch}
|
||||||
if [[ "${SUCCEED}" != "$?" ]]; then
|
if [[ "${SUCCEED}" != "$?" ]]; then
|
||||||
printf "${C_B_RED}<<<< git checkout ${branch} failed.${C_RESET}\n"
|
logError "<<<< git checkout ${branch} failed."
|
||||||
return ${FAILED}
|
return ${FAILED}
|
||||||
fi
|
fi
|
||||||
printf "${C_B_GREEN}git checkout ${branch} succeed.${C_RESET}\n"
|
logInfo "git checkout ${branch} succeed."
|
||||||
|
|
||||||
git reset --hard
|
getGitOriginBranch
|
||||||
|
git fetch --all
|
||||||
|
git reset --hard ${GIT_ORIGIN_BRANCH}
|
||||||
if [[ "${SUCCEED}" != "$?" ]]; then
|
if [[ "${SUCCEED}" != "$?" ]]; then
|
||||||
printf "${C_B_RED}<<<< git reset --hard failed.${C_RESET}\n"
|
logError "<<<< git reset --hard ${GIT_ORIGIN_BRANCH} failed."
|
||||||
return ${FAILED}
|
return ${FAILED}
|
||||||
fi
|
fi
|
||||||
printf "${C_B_GREEN}git reset --hard succeed.${C_RESET}\n"
|
logInfo "git reset --hard ${GIT_ORIGIN_BRANCH} succeed."
|
||||||
|
|
||||||
git pull
|
git pull
|
||||||
if [[ "${SUCCEED}" != "$?" ]]; then
|
if [[ "${SUCCEED}" != "$?" ]]; then
|
||||||
printf "${C_B_RED}<<<< git pull failed.${C_RESET}\n"
|
logError "<<<< git pull failed."
|
||||||
return ${FAILED}
|
return ${FAILED}
|
||||||
fi
|
fi
|
||||||
printf "${C_B_GREEN}git pull succeed.${C_RESET}\n"
|
logInfo "git pull succeed."
|
||||||
else
|
else
|
||||||
# 如果 ${source} 不是 git 项目,执行 clone 操作
|
# 如果 ${source} 不是 git 项目,执行 clone 操作
|
||||||
|
|
||||||
git clone "${repository}:${group}/${project}.git" ${source}
|
git clone "${repository}:${group}/${project}.git" ${source}
|
||||||
if [[ "${SUCCEED}" != "$?" ]]; then
|
if [[ "${SUCCEED}" != "$?" ]]; then
|
||||||
printf "${C_B_RED}<<<< git clone ${project} failed.${C_RESET}\n"
|
logError "<<<< git clone ${project} failed."
|
||||||
return ${FAILED}
|
return ${FAILED}
|
||||||
fi
|
fi
|
||||||
printf "${C_B_GREEN}git clone ${project} succeed.${C_RESET}\n"
|
logInfo "git clone ${project} succeed."
|
||||||
|
|
||||||
cd ${source} || return ${FAILED}
|
cd ${source} || return ${FAILED}
|
||||||
|
|
||||||
git checkout -f ${branch}
|
git checkout -f ${branch}
|
||||||
if [[ "${SUCCEED}" != "$?" ]]; then
|
if [[ "${SUCCEED}" != "$?" ]]; then
|
||||||
printf "${C_B_RED}<<<< git checkout ${branch} failed.${C_RESET}\n"
|
logError "<<<< git checkout ${branch} failed."
|
||||||
return ${FAILED}
|
return ${FAILED}
|
||||||
fi
|
fi
|
||||||
printf "${C_B_GREEN}git checkout ${branch} succeed.${C_RESET}\n"
|
logInfo "git checkout ${branch} succeed."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "${C_B_GREEN}Clone or pull git project [$2/$3:$4] succeed.${C_RESET}\n"
|
logInfo "Clone or pull git project [$2/$3:$4] succeed."
|
||||||
return ${SUCCEED}
|
return ${SUCCEED}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# ------------------------------------------------------------------------------ env preparation
|
# ------------------------------------------------------------------------------ env preparation
|
||||||
# load libs
|
# load libs
|
||||||
CURRENT_PATH=`dirname ${BASH_SOURCE[0]}`
|
CURRENT_PATH=`dirname ${BASH_SOURCE[0]}`
|
||||||
source ${CURRENT_PATH}/env.sh
|
source ${CURRENT_PATH}/utils.sh
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------ functions
|
# ------------------------------------------------------------------------------ functions
|
||||||
|
|
||||||
|
|
|
@ -6,31 +6,52 @@
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 装载其它库
|
# 装载其它库
|
||||||
ROOT=`dirname ${BASH_SOURCE[0]}`
|
LINUX_SCRIPTS_LIB_DIR=`dirname ${BASH_SOURCE[0]}`
|
||||||
source ${ROOT}/env.sh
|
|
||||||
|
|
||||||
mavenBuild() {
|
if [[ ! -x ${LINUX_SCRIPTS_LIB_DIR}/utils.sh ]]; then
|
||||||
|
echo "必要脚本库 ${LINUX_SCRIPTS_LIB_DIR}/utils.sh 不存在!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source ${LINUX_SCRIPTS_LIB_DIR}/utils.sh
|
||||||
|
|
||||||
|
# 执行 maven 操作
|
||||||
|
# @param $1: 第一个参数为 maven 项目路径
|
||||||
|
# @param $2: 第二个参数为 maven 操作,如 package、install、deploy
|
||||||
|
# @param $3: 第三个参数为 maven profile 【非必填】
|
||||||
|
mavenOperation() {
|
||||||
local source=$1
|
local source=$1
|
||||||
mavenCheck $1
|
local lifecycle=$2
|
||||||
|
local profile=$3
|
||||||
|
|
||||||
|
mavenCheck ${source}
|
||||||
if [[ "${SUCCEED}" != "$?" ]]; then
|
if [[ "${SUCCEED}" != "$?" ]]; then
|
||||||
return ${FAILED}
|
return ${FAILED}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "${source}" ]]; then
|
if [[ ! "${lifecycle}" ]]; then
|
||||||
cd ${source}
|
logError "please input maven lifecycle"
|
||||||
if [[ -f "${source}/settings.xml" ]]; then
|
return ${FAILED}
|
||||||
callAndLog "mvn clean install -B -U -s ${source}/settings.xml -Dmaven.test.skip=true"
|
fi
|
||||||
else
|
|
||||||
callAndLog "mvn clean install -DskipTests=true -B -U"
|
local mvnCli="mvn clean ${lifecycle} -DskipTests=true -B -U"
|
||||||
fi
|
|
||||||
cd -
|
if [[ ${profile} ]]; then
|
||||||
return ${SUCCEED}
|
mvnCli="${mvnCli} -P${profile}"
|
||||||
else
|
fi
|
||||||
printf "${C_B_RED}please input valid maven project path.${C_RESET}\n"
|
|
||||||
return ${FAILED}
|
cd ${source}
|
||||||
fi
|
if [[ -f "${source}/settings.xml" ]]; then
|
||||||
|
mvnCli="${mvnCli} -s ${source}/settings.xml"
|
||||||
|
fi
|
||||||
|
|
||||||
|
callAndLog "${mvnCli}"
|
||||||
|
cd -
|
||||||
|
return ${SUCCEED}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 判断指定路径下是否为 maven 工程
|
||||||
|
# @param $1: 第一个参数为 maven 项目路径
|
||||||
mavenCheck() {
|
mavenCheck() {
|
||||||
local source=$1
|
local source=$1
|
||||||
if [[ -d "${source}" ]]; then
|
if [[ -d "${source}" ]]; then
|
||||||
|
@ -38,29 +59,13 @@ mavenCheck() {
|
||||||
if [[ -f "${source}/pom.xml" ]]; then
|
if [[ -f "${source}/pom.xml" ]]; then
|
||||||
return ${YES}
|
return ${YES}
|
||||||
else
|
else
|
||||||
printf "${C_B_RED}pom.xml is not exists.${C_RESET}\n"
|
logError "pom.xml is not exists"
|
||||||
return ${NO}
|
return ${NO}
|
||||||
fi
|
fi
|
||||||
cd -
|
cd -
|
||||||
return ${YES}
|
return ${YES}
|
||||||
else
|
else
|
||||||
printf "${C_B_RED}please input valid maven project path.${C_RESET}\n"
|
logError "please input valid maven project path"
|
||||||
return ${NO}
|
return ${NO}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
##################################### MAIN #####################################
|
|
||||||
printf "\n${C_B_GREEN}>>>> maven build begin.${C_RESET}\n\n"
|
|
||||||
|
|
||||||
printf "${C_B_MAGENTA}Current path is ${ROOT}.${C_RESET}\n"
|
|
||||||
|
|
||||||
mavenBuild ${ROOT}/..
|
|
||||||
r1=$?
|
|
||||||
|
|
||||||
if [[ "${r1}" == "${SUCCEED}" ]]; then
|
|
||||||
printf "\n${C_B_GREEN}<<<< maven build succeed.${C_RESET}\n\n"
|
|
||||||
exit ${SUCCEED}
|
|
||||||
else
|
|
||||||
printf "\n${C_B_RED}<<<< maven build failed.${C_RESET}\n\n"
|
|
||||||
exit ${FAILED}
|
|
||||||
fi
|
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Shell Utils
|
||||||
|
# @author Zhang Peng
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------ 颜色状态
|
||||||
|
|
||||||
|
# Regular Color
|
||||||
|
export C_BLACK="\033[0;30m"
|
||||||
|
export C_RED="\033[0;31m"
|
||||||
|
export C_GREEN="\033[0;32m"
|
||||||
|
export C_YELLOW="\033[0;33m"
|
||||||
|
export C_BLUE="\033[0;34m"
|
||||||
|
export C_MAGENTA="\033[0;35m"
|
||||||
|
export C_CYAN="\033[0;36m"
|
||||||
|
export C_WHITE="\033[0;37m"
|
||||||
|
|
||||||
|
# Bold Color
|
||||||
|
export C_B_BLACK="\033[1;30m"
|
||||||
|
export C_B_RED="\033[1;31m"
|
||||||
|
export C_B_GREEN="\033[1;32m"
|
||||||
|
export C_B_YELLOW="\033[1;33m"
|
||||||
|
export C_B_BLUE="\033[1;34m"
|
||||||
|
export C_B_MAGENTA="\033[1;35m"
|
||||||
|
export C_B_CYAN="\033[1;36m"
|
||||||
|
export C_B_WHITE="\033[1;37m"
|
||||||
|
|
||||||
|
# Underline Color
|
||||||
|
export C_U_BLACK="\033[4;30m"
|
||||||
|
export C_U_RED="\033[4;31m"
|
||||||
|
export C_U_GREEN="\033[4;32m"
|
||||||
|
export C_U_YELLOW="\033[4;33m"
|
||||||
|
export C_U_BLUE="\033[4;34m"
|
||||||
|
export C_U_MAGENTA="\033[4;35m"
|
||||||
|
export C_U_CYAN="\033[4;36m"
|
||||||
|
export C_U_WHITE="\033[4;37m"
|
||||||
|
|
||||||
|
# Background Color
|
||||||
|
export C_BG_BLACK="\033[40m"
|
||||||
|
export C_BG_RED="\033[41m"
|
||||||
|
export C_BG_GREEN="\033[42m"
|
||||||
|
export C_BG_YELLOW="\033[43m"
|
||||||
|
export C_BG_BLUE="\033[44m"
|
||||||
|
export C_BG_MAGENTA="\033[45m"
|
||||||
|
export C_BG_CYAN="\033[46m"
|
||||||
|
export C_BG_WHITE="\033[47m"
|
||||||
|
|
||||||
|
# Reset Color
|
||||||
|
export C_RESET="$(tput sgr0)"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------ 常用状态值
|
||||||
|
|
||||||
|
export YES=0
|
||||||
|
export NO=1
|
||||||
|
export SUCCEED=0
|
||||||
|
export FAILED=1
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------ 常用状态值
|
||||||
|
|
||||||
|
# 显示打印日志的时间
|
||||||
|
DATE=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
|
# 那个用户在操作
|
||||||
|
USER=$(whoami)
|
||||||
|
# 日志路径
|
||||||
|
LOG_DIR=/var/log/dunwu
|
||||||
|
LOG_PATH=${LOG_DIR}/shell.log
|
||||||
|
|
||||||
|
createLogFileIfNotExists() {
|
||||||
|
if [[ ! -f "${LOG_PATH}" ]]; then
|
||||||
|
sudo mkdir -p "${LOG_DIR}"
|
||||||
|
touch "${LOG_PATH}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
logInfo() {
|
||||||
|
echo -e "${C_B_GREEN}[INFO] $@${C_RESET}"
|
||||||
|
createLogFileIfNotExists
|
||||||
|
echo "[${DATE}] [${USER}] [INFO] [$0] [$@] execute succeed." >> "${LOG_PATH}"
|
||||||
|
}
|
||||||
|
|
||||||
|
logWarn() {
|
||||||
|
echo -e "${C_B_YELLOW}[WARN] $@${C_RESET}"
|
||||||
|
createLogFileIfNotExists
|
||||||
|
echo "[${DATE}] [${USER}] [WARN] [$0] [$@] execute succeed." >> "${LOG_PATH}"
|
||||||
|
}
|
||||||
|
|
||||||
|
logError() {
|
||||||
|
echo -e "${C_B_RED}[ERROR] $@${C_RESET}"
|
||||||
|
createLogFileIfNotExists
|
||||||
|
echo "[${DATE}] [${USER}] [ERROR] [$0] [$@] execute failed." >> "${LOG_PATH}"
|
||||||
|
}
|
||||||
|
|
||||||
|
printInfo() {
|
||||||
|
echo -e "${C_B_GREEN}[INFO] $@${C_RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
printWarn() {
|
||||||
|
echo -e "${C_B_YELLOW}[WARN] $@${C_RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
printError() {
|
||||||
|
echo -e "${C_B_RED}[ERROR] $@${C_RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
callAndLog () {
|
||||||
|
$*
|
||||||
|
if [[ $? -eq ${SUCCEED} ]]; then
|
||||||
|
logInfo "$@ succeed"
|
||||||
|
echo -e "${C_B_GREEN}[INFO] [$0] [$@] execute succeed.${C_RESET}"
|
||||||
|
return ${SUCCEED}
|
||||||
|
else
|
||||||
|
logError "$@ failed"
|
||||||
|
echo -e "${C_B_RED}[ERROR] [$0] [$@] execute failed.${C_RESET}"
|
||||||
|
return ${FAILED}
|
||||||
|
fi
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# 装载其它库
|
# 装载其它库
|
||||||
source ../lib/env.sh
|
source ../lib/utils.sh
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------ 颜色变量测试
|
# ------------------------------------------------------------------------------ 颜色变量测试
|
||||||
printf "${C_B_YELLOW}测试彩色打印:${C_RESET}\n"
|
printf "${C_B_YELLOW}测试彩色打印:${C_RESET}\n"
|
||||||
|
@ -11,7 +11,7 @@ printf "${C_RED}Hello.${C_RESET}\n"
|
||||||
printf "${C_GREEN}Hello.${C_RESET}\n"
|
printf "${C_GREEN}Hello.${C_RESET}\n"
|
||||||
printf "${C_YELLOW}Hello.${C_RESET}\n"
|
printf "${C_YELLOW}Hello.${C_RESET}\n"
|
||||||
printf "${C_BLUE}Hello.${C_RESET}\n"
|
printf "${C_BLUE}Hello.${C_RESET}\n"
|
||||||
printf "${C_PURPLE}Hello.${C_RESET}\n"
|
printf "${C_MAGENTA}Hello.${C_RESET}\n"
|
||||||
printf "${C_CYAN}Hello.${C_RESET}\n"
|
printf "${C_CYAN}Hello.${C_RESET}\n"
|
||||||
|
|
||||||
printf "${C_B_BLACK}Hello.${C_RESET}\n"
|
printf "${C_B_BLACK}Hello.${C_RESET}\n"
|
||||||
|
@ -19,7 +19,7 @@ printf "${C_B_RED}Hello.${C_RESET}\n"
|
||||||
printf "${C_B_GREEN}Hello.${C_RESET}\n"
|
printf "${C_B_GREEN}Hello.${C_RESET}\n"
|
||||||
printf "${C_B_YELLOW}Hello.${C_RESET}\n"
|
printf "${C_B_YELLOW}Hello.${C_RESET}\n"
|
||||||
printf "${C_B_BLUE}Hello.${C_RESET}\n"
|
printf "${C_B_BLUE}Hello.${C_RESET}\n"
|
||||||
printf "${C_B_PURPLE}Hello.${C_RESET}\n"
|
printf "${C_B_MAGENTA}Hello.${C_RESET}\n"
|
||||||
printf "${C_B_CYAN}Hello.${C_RESET}\n"
|
printf "${C_B_CYAN}Hello.${C_RESET}\n"
|
||||||
|
|
||||||
printf "${C_U_BLACK}Hello.${C_RESET}\n"
|
printf "${C_U_BLACK}Hello.${C_RESET}\n"
|
||||||
|
@ -27,7 +27,7 @@ printf "${C_U_RED}Hello.${C_RESET}\n"
|
||||||
printf "${C_U_GREEN}Hello.${C_RESET}\n"
|
printf "${C_U_GREEN}Hello.${C_RESET}\n"
|
||||||
printf "${C_U_YELLOW}Hello.${C_RESET}\n"
|
printf "${C_U_YELLOW}Hello.${C_RESET}\n"
|
||||||
printf "${C_U_BLUE}Hello.${C_RESET}\n"
|
printf "${C_U_BLUE}Hello.${C_RESET}\n"
|
||||||
printf "${C_U_PURPLE}Hello.${C_RESET}\n"
|
printf "${C_U_MAGENTA}Hello.${C_RESET}\n"
|
||||||
printf "${C_U_CYAN}Hello.${C_RESET}\n"
|
printf "${C_U_CYAN}Hello.${C_RESET}\n"
|
||||||
|
|
||||||
printf "${C_BG_BLACK}Hello.${C_RESET}\n"
|
printf "${C_BG_BLACK}Hello.${C_RESET}\n"
|
||||||
|
@ -35,6 +35,6 @@ printf "${C_BG_RED}Hello.${C_RESET}\n"
|
||||||
printf "${C_BG_GREEN}Hello.${C_RESET}\n"
|
printf "${C_BG_GREEN}Hello.${C_RESET}\n"
|
||||||
printf "${C_BG_YELLOW}Hello.${C_RESET}\n"
|
printf "${C_BG_YELLOW}Hello.${C_RESET}\n"
|
||||||
printf "${C_BG_BLUE}Hello.${C_RESET}\n"
|
printf "${C_BG_BLUE}Hello.${C_RESET}\n"
|
||||||
printf "${C_BG_PURPLE}Hello.${C_RESET}\n"
|
printf "${C_BG_MAGENTA}Hello.${C_RESET}\n"
|
||||||
printf "${C_BG_CYAN}Hello.${C_RESET}\n"
|
printf "${C_BG_CYAN}Hello.${C_RESET}\n"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source ../lib/utils.sh
|
||||||
source ../lib/git.sh
|
source ../lib/git.sh
|
||||||
|
|
||||||
##################################### MAIN #####################################
|
##################################### MAIN #####################################
|
||||||
|
@ -9,13 +10,18 @@ else
|
||||||
DIR=$(pwd)
|
DIR=$(pwd)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "${C_B_BLUE}Current path is: ${DIR} ${C_RESET}\n"
|
printInfo "Current path is: ${DIR}."
|
||||||
|
|
||||||
|
# 判断是否为 git 项目
|
||||||
checkGit ${DIR}
|
checkGit ${DIR}
|
||||||
if [[ "${YES}" == "$?" ]]; then
|
if [[ "${YES}" == "$?" ]]; then
|
||||||
printf "${C_B_GREEN}${DIR} is git project.${C_RESET}\n"
|
printInfo "${DIR} is git project."
|
||||||
exit ${YES}
|
|
||||||
else
|
else
|
||||||
printf "${C_B_RED}${DIR} is not git project.${C_RESET}\n"
|
printError "${DIR} is not git project."
|
||||||
exit ${NO}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 获取 git 分支
|
||||||
|
getGitLocalBranch
|
||||||
|
printInfo "git local branch: ${GIT_LOCAL_BRANCH}"
|
||||||
|
getGitOriginBranch
|
||||||
|
printInfo "git origin branch: ${GIT_ORIGIN_BRANCH}"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source ../lib/env.sh
|
source ../lib/utils.sh
|
||||||
source ../lib/git.sh
|
source ../lib/git.sh
|
||||||
|
|
||||||
doCloneOrPullGit() {
|
doCloneOrPullGit() {
|
||||||
|
|
Loading…
Reference in New Issue