linux-tutorial/codes/linux/soft/gitlab-install.sh

111 lines
3.1 KiB
Bash
Raw Normal View History

2019-02-22 17:09:40 +08:00
#!/usr/bin/env bash
2020-04-03 15:15:02 +08:00
# -----------------------------------------------------------------------------------------------------
2020-04-26 10:34:55 +08:00
# Gitlab 安装脚本
2019-02-22 17:09:40 +08:00
# 仅适用于 CentOS7 发行版本
2020-04-26 10:34:55 +08:00
# 官方安裝參考https://about.gitlab.com/install/#centos-7
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
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
2020-04-26 10:34:55 +08:00
# 官方安裝參考https://about.gitlab.com/install/#centos-7
printInfo ">>>> install gitlab on Centos7"
printInfo ">>>> Install and configure the necessary dependencies"
2020-04-03 15:15:02 +08:00
yum install -y curl policycoreutils-python openssh-server
systemctl enable sshd
systemctl start sshd
2020-04-26 10:34:55 +08:00
printInfo ">>>> open http, https and ssh access in the system firewall"
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
printInfo ">>>> install postfix"
2020-04-03 15:15:02 +08:00
yum install postfix
systemctl enable postfix
systemctl start postfix
2020-04-26 10:34:55 +08:00
printInfo ">>>> Add the GitLab package repository and install the package"
2020-04-03 15:15:02 +08:00
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