在51cto的博文《企业级GitLab仓库环境构建》中已全面的介绍过怎样搭建一个gitlab,这里把整个环境的搭建过程整理后用shell脚本的方式组织起来。
gitlab软件包安装和基础配置:
gitlab@gitlab-01:~/tools$ cat install_config_gitlab.sh
#!/bin/bash
#Program: configure gitlab
#Author: Neal
#E_mail: 419775240@qq.com
#Date: 2015-12-04
#platform: Debian 8 x86_64
#Version 1.0
# 通用安装包到http://mirror.tuna.tsinghua.edu.cn/gitlab-ce/进行下载
sudo dpkg -i gitlab-ce_8.2.1-ce.0_amd64.deb
# 修改gitlab数据存放目录
sudo vim /var/opt/gitlab/gitlab-shell/config.yml # repos_path: "/data/git-data/repositories"
sudo vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
#satellites:
# path: /data/git-data/gitlab-satellites
# ...
#gitlab_shell:
# path: /opt/gitlab/embedded/service/gitlab-shell/
# repos_path: /data/git-data/repositories
# 创建数据存放目录并修改权限
sudo mkdir -pv /data/git-data/gitlab-satellites
sudo mkdir -pv /data/git-data/repositories
sudo chown -R git.git /data/git-data/
sudo chmod 2770 /data/git-data/repositories
# restart gitlab service
sudo gitlab-ctl restart
启用https的安全访问:
1 |
|
启用smtp邮箱功能:
gitlab@gitlab-01:~/tools$ cat open_gitlab_smtp.sh
#!/bin/bash
#Program: open gitlab smtp
#Author: Neal
#E_mail: 419775240@qq.com
#Date: 2015-12-04
#platform: Debian 8 x86_64
#Version 1.0
#以163邮箱为例
sudo bash -c "cat <<- EOF >> /etc/gitlab/gitlab.rb
##### open smtp #####################
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = \"smtp.163.com\"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = \"XXXXX@163.com\"
gitlab_rails['smtp_password'] = \"***********\"
gitlab_rails['smtp_domain'] = \"163.com\"
gitlab_rails['smtp_authentication'] = \"login\"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = \"XXXX@163.com\"
EOF"
sudo gitlab-ctl reconfigure
end…