2019-02-22 17:09:40 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-04-03 15:15:02 +08:00
|
|
|
# -----------------------------------------------------------------------------------------------------
|
2019-02-22 17:09:40 +08:00
|
|
|
# 安装 Gitlab 脚本
|
|
|
|
# 仅适用于 CentOS7 发行版本
|
2019-05-07 14:29:16 +08:00
|
|
|
# @author: Zhang Peng
|
2020-04-03 15:15:02 +08:00
|
|
|
# -----------------------------------------------------------------------------------------------------
|
2019-02-22 17:09:40 +08:00
|
|
|
|
2020-04-03 15:15:02 +08:00
|
|
|
# ------------------------------------------------------------------------------ env
|
2019-02-22 17:09:40 +08:00
|
|
|
|
2020-04-03 15:15:02 +08:00
|
|
|
# Regular Color
|
|
|
|
export ENV_COLOR_BLACK="\033[0;30m"
|
|
|
|
export ENV_COLOR_RED="\033[0;31m"
|
|
|
|
export ENV_COLOR_GREEN="\033[0;32m"
|
|
|
|
export ENV_COLOR_YELLOW="\033[0;33m"
|
|
|
|
export ENV_COLOR_BLUE="\033[0;34m"
|
|
|
|
export ENV_COLOR_MAGENTA="\033[0;35m"
|
|
|
|
export ENV_COLOR_CYAN="\033[0;36m"
|
|
|
|
export ENV_COLOR_WHITE="\033[0;37m"
|
|
|
|
# Bold Color
|
|
|
|
export ENV_COLOR_B_BLACK="\033[1;30m"
|
|
|
|
export ENV_COLOR_B_RED="\033[1;31m"
|
|
|
|
export ENV_COLOR_B_GREEN="\033[1;32m"
|
|
|
|
export ENV_COLOR_B_YELLOW="\033[1;33m"
|
|
|
|
export ENV_COLOR_B_BLUE="\033[1;34m"
|
|
|
|
export ENV_COLOR_B_MAGENTA="\033[1;35m"
|
|
|
|
export ENV_COLOR_B_CYAN="\033[1;36m"
|
|
|
|
export ENV_COLOR_B_WHITE="\033[1;37m"
|
|
|
|
# Reset Color
|
|
|
|
export ENV_COLOR_RESET="$(tput sgr0)"
|
2019-02-22 17:09:40 +08:00
|
|
|
|
2020-04-03 15:15:02 +08:00
|
|
|
# status
|
|
|
|
export ENV_YES=0
|
|
|
|
export ENV_NO=1
|
|
|
|
export ENV_SUCCEED=0
|
|
|
|
export ENV_FAILED=1
|
2019-02-22 17:09:40 +08:00
|
|
|
|
2020-04-03 15:15:02 +08:00
|
|
|
# ------------------------------------------------------------------------------ functions
|
|
|
|
|
|
|
|
# 显示打印日志的时间
|
|
|
|
SHELL_LOG_TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
|
|
|
|
# 那个用户在操作
|
|
|
|
USER=$(whoami)
|
|
|
|
|
|
|
|
redOutput() {
|
|
|
|
echo -e "${ENV_COLOR_RED} $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
greenOutput() {
|
|
|
|
echo -e "${ENV_COLOR_B_GREEN} $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
yellowOutput() {
|
|
|
|
echo -e "${ENV_COLOR_YELLOW} $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
blueOutput() {
|
|
|
|
echo -e "${ENV_COLOR_BLUE} $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
magentaOutput() {
|
|
|
|
echo -e "${ENV_COLOR_MAGENTA} $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
cyanOutput() {
|
|
|
|
echo -e "${ENV_COLOR_CYAN} $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
whiteOutput() {
|
|
|
|
echo -e "${ENV_COLOR_WHITE} $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
printInfo() {
|
|
|
|
echo -e "${ENV_COLOR_B_GREEN}[INFO] $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
printWarn() {
|
|
|
|
echo -e "${ENV_COLOR_B_YELLOW}[WARN] $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
printError() {
|
|
|
|
echo -e "${ENV_COLOR_B_RED}[ERROR] $@${ENV_COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
callAndLog () {
|
|
|
|
$*
|
|
|
|
if [[ $? -eq ${ENV_SUCCEED} ]]; then
|
|
|
|
printInfo "$@"
|
|
|
|
return ${ENV_SUCCEED}
|
|
|
|
else
|
|
|
|
printError "$@ EXECUTE FAILED"
|
|
|
|
return ${ENV_FAILED}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ main
|
|
|
|
|
|
|
|
printInfo ">>>> 安装 gitlab"
|
|
|
|
printInfo ">>>> 安装和配置必要依赖"
|
|
|
|
yum install -y curl policycoreutils-python openssh-server
|
|
|
|
systemctl enable sshd
|
|
|
|
systemctl start sshd
|
|
|
|
printInfo ">>>> 关闭防火墙"
|
|
|
|
firewall-cmd --permanent --add-service=http
|
|
|
|
systemctl reload firewalld
|
|
|
|
printInfo ">>>> 安装和配置邮件服务"
|
|
|
|
yum install postfix
|
|
|
|
systemctl enable postfix
|
|
|
|
systemctl start postfix
|
|
|
|
printInfo ">>>> 通过 yum 安装 gitlab"
|
|
|
|
curl -o- https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
|
|
|
|
EXTERNAL_URL="http://gitlab.transwarp.io" yum install -y gitlab-ce
|