|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -################################################################################### |
| 3 | +# ----------------------------------------------------------------------------------------------------- |
4 | 4 | # 安装 Gitlab 脚本 |
5 | 5 | # 仅适用于 CentOS7 发行版本 |
6 | 6 | # @author: Zhang Peng |
7 | | -################################################################################### |
| 7 | +# ----------------------------------------------------------------------------------------------------- |
8 | 8 |
|
9 | | -echo -e "\n>>>>>>>>> install gitlab" |
| 9 | +# ------------------------------------------------------------------------------ env |
10 | 10 |
|
11 | | -echo -e "\n>>>>>>>>> 安装和配置必要依赖" |
12 | | -sudo yum install -y curl policycoreutils-python openssh-server |
13 | | -sudo systemctl enable sshd |
14 | | -sudo systemctl start sshd |
15 | | -sudo firewall-cmd --permanent --add-service=http |
16 | | -sudo systemctl reload firewalld |
| 11 | +# Regular Color |
| 12 | +export ENV_COLOR_BLACK="\033[0;30m" |
| 13 | +export ENV_COLOR_RED="\033[0;31m" |
| 14 | +export ENV_COLOR_GREEN="\033[0;32m" |
| 15 | +export ENV_COLOR_YELLOW="\033[0;33m" |
| 16 | +export ENV_COLOR_BLUE="\033[0;34m" |
| 17 | +export ENV_COLOR_MAGENTA="\033[0;35m" |
| 18 | +export ENV_COLOR_CYAN="\033[0;36m" |
| 19 | +export ENV_COLOR_WHITE="\033[0;37m" |
| 20 | +# Bold Color |
| 21 | +export ENV_COLOR_B_BLACK="\033[1;30m" |
| 22 | +export ENV_COLOR_B_RED="\033[1;31m" |
| 23 | +export ENV_COLOR_B_GREEN="\033[1;32m" |
| 24 | +export ENV_COLOR_B_YELLOW="\033[1;33m" |
| 25 | +export ENV_COLOR_B_BLUE="\033[1;34m" |
| 26 | +export ENV_COLOR_B_MAGENTA="\033[1;35m" |
| 27 | +export ENV_COLOR_B_CYAN="\033[1;36m" |
| 28 | +export ENV_COLOR_B_WHITE="\033[1;37m" |
| 29 | +# Reset Color |
| 30 | +export ENV_COLOR_RESET="$(tput sgr0)" |
17 | 31 |
|
18 | | -echo -e "\n>>>>>>>>> 安装和配置邮件服务" |
19 | | -sudo yum install postfix |
20 | | -sudo systemctl enable postfix |
21 | | -sudo systemctl start postfix |
| 32 | +# status |
| 33 | +export ENV_YES=0 |
| 34 | +export ENV_NO=1 |
| 35 | +export ENV_SUCCEED=0 |
| 36 | +export ENV_FAILED=1 |
22 | 37 |
|
23 | | -echo -e "\n>>>>>>>>> 通过 yum 安装 gitlab" |
24 | | -curl -o- https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash |
25 | | -sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce |
| 38 | +# ------------------------------------------------------------------------------ functions |
| 39 | + |
| 40 | +# 显示打印日志的时间 |
| 41 | +SHELL_LOG_TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S") |
| 42 | +# 那个用户在操作 |
| 43 | +USER=$(whoami) |
| 44 | + |
| 45 | +redOutput() { |
| 46 | + echo -e "${ENV_COLOR_RED} $@${ENV_COLOR_RESET}" |
| 47 | +} |
| 48 | + |
| 49 | +greenOutput() { |
| 50 | + echo -e "${ENV_COLOR_B_GREEN} $@${ENV_COLOR_RESET}" |
| 51 | +} |
| 52 | + |
| 53 | +yellowOutput() { |
| 54 | + echo -e "${ENV_COLOR_YELLOW} $@${ENV_COLOR_RESET}" |
| 55 | +} |
| 56 | + |
| 57 | +blueOutput() { |
| 58 | + echo -e "${ENV_COLOR_BLUE} $@${ENV_COLOR_RESET}" |
| 59 | +} |
| 60 | + |
| 61 | +magentaOutput() { |
| 62 | + echo -e "${ENV_COLOR_MAGENTA} $@${ENV_COLOR_RESET}" |
| 63 | +} |
| 64 | + |
| 65 | +cyanOutput() { |
| 66 | + echo -e "${ENV_COLOR_CYAN} $@${ENV_COLOR_RESET}" |
| 67 | +} |
| 68 | + |
| 69 | +whiteOutput() { |
| 70 | + echo -e "${ENV_COLOR_WHITE} $@${ENV_COLOR_RESET}" |
| 71 | +} |
| 72 | + |
| 73 | +printInfo() { |
| 74 | + echo -e "${ENV_COLOR_B_GREEN}[INFO] $@${ENV_COLOR_RESET}" |
| 75 | +} |
| 76 | + |
| 77 | +printWarn() { |
| 78 | + echo -e "${ENV_COLOR_B_YELLOW}[WARN] $@${ENV_COLOR_RESET}" |
| 79 | +} |
| 80 | + |
| 81 | +printError() { |
| 82 | + echo -e "${ENV_COLOR_B_RED}[ERROR] $@${ENV_COLOR_RESET}" |
| 83 | +} |
| 84 | + |
| 85 | +callAndLog () { |
| 86 | + $* |
| 87 | + if [[ $? -eq ${ENV_SUCCEED} ]]; then |
| 88 | + printInfo "$@" |
| 89 | + return ${ENV_SUCCEED} |
| 90 | + else |
| 91 | + printError "$@ EXECUTE FAILED" |
| 92 | + return ${ENV_FAILED} |
| 93 | + fi |
| 94 | +} |
| 95 | + |
| 96 | +# ------------------------------------------------------------------------------ main |
| 97 | + |
| 98 | +printInfo ">>>> 安装 gitlab" |
| 99 | +printInfo ">>>> 安装和配置必要依赖" |
| 100 | +yum install -y curl policycoreutils-python openssh-server |
| 101 | +systemctl enable sshd |
| 102 | +systemctl start sshd |
| 103 | +printInfo ">>>> 关闭防火墙" |
| 104 | +firewall-cmd --permanent --add-service=http |
| 105 | +systemctl reload firewalld |
| 106 | +printInfo ">>>> 安装和配置邮件服务" |
| 107 | +yum install postfix |
| 108 | +systemctl enable postfix |
| 109 | +systemctl start postfix |
| 110 | +printInfo ">>>> 通过 yum 安装 gitlab" |
| 111 | +curl -o- https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash |
| 112 | +EXTERNAL_URL="http://gitlab.transwarp.io" yum install -y gitlab-ce |
0 commit comments