GITLAB 쉘스크립트 설치하기

개인적으로 private git 저장소가 필요한 경우나 회사 프로젝트의 협업을 위한 도구를 찾고자 하는 경우 gitlab을 구축하여 아주 유용하게 사용할수가 있습니다. 

GITLAB은 Ruby 기반으로 되어 있습니다. 그리고 DB는 MariaDB 을 이용하여 연동하였으며 웹서버는 Nginx 로 연동하였습니다. 일단 실제로 사내회사에서 유용하게 쓰고 있습니다.

여기서 GIT 관리툴은 SourceTree + Git flow 을 연동하면 최적의 조합이 됩니다.

나중에는 소스트리하고 Git flow 연동하는법을 포스팅 하겠습니다.



#!/bin/sh

 
hostname = ""
 
cd /usr/local/src
wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
touch /etc/yum.repos.d/PUIAS_6_computational.repo
echo "[PUIAS_6_computational]" >> /etc/yum.repos.d/PUIAS_6_computational.repo
echo "name=PUIAS computational Base $releasever - $basearch" >> /etc/yum.repos.d/PUIAS_6_computational.repo
echo "mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist" >> /etc/yum.repos.d/PUIAS_6_computational.repo
echo "enabled=1" >> /etc/yum.repos.d/PUIAS_6_computational.repo
echo "gpgcheck=1" >> /etc/yum.repos.d/PUIAS_6_computational.repo
echo "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias" >> /etc/yum.repos.d/PUIAS_6_computational.repo
wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
yum -y update
yum -y groupinstall 'Development Tools'
yum -y install vim-enhanced readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git patch libicu-devel ruby-devel
yum-config-manager --enable rhel-6-server-optional-rpms
chkconfig redis on
service redis start
yum -y remove git
yum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel
curl --progress https://git-core.googlecode.com/files/git-1.9.0.tar.gz | tar xz
cd git-1.9.0/
./configure
make
make prefix=/usr/local install
cd /usr/local/src
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz
tar xvfz ruby-2.1.1.tar.gz
cd ruby-2.1.1
./configure --disable-install-rdoc
make
make prefix=/usr/local install
cd /usr/local/src
echo "export PATH=/usr/local/bin:$PATH" >> /etc/bashrc
source /etc/bashrc
gem install bundler --no-ri --no-rdoc
adduser --system --shell /sbin/nologin --comment 'GitLab' --create-home --home-dir /home/git/ git
sed -i 's//sbin:/bin:/usr/sbin:/usr/bin//sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/g' /etc/sudoers
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.9.1
cd gitlab-shell
sudo -u git -H cp config.yml.example config.yml
sudo -u git -H sed -i 's/localhost/'$hostname'/g' config.yml
sudo -u git -H /usr/local/bin/ruby ./bin/install
yum install -y mysql-server mysql-devel
chkconfig mysqld on
service mysqld start
 
echo "setting mysql"
echo "/usr/bin/mysql_secure_installation"
echo "mysql -u root -p"
echo "CREATE USER 'git'@'localhost' IDENTIFIED BY 'password';"
echo "CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;"
echo "GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost';"
echo "q"
echo "mysql -u git -p -D gitlabhq_production"
echo "q"
echo "install1.sh"


#!/bin/sh
 
dbpw=""
hostname=""
 
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b master gitlab
cd /home/git/gitlab
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u git -H sed -i 's/localhost/'$hostname'/g' config/gitlab.yml
sudo -u git -H sed -i 's//usr/bin/git//usr/local/bin/git/g' config/gitlab.yml
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX  log/
sudo chmod -R u+rwX  tmp/
sudo -u git -H mkdir /home/git/gitlab-satellites
sudo -u git -H mkdir tmp/pids/
sudo -u git -H mkdir tmp/sockets/
sudo chmod -R u+rwX  tmp/pids/
sudo chmod -R u+rwX  tmp/sockets/
sudo -u git -H mkdir public/uploads
sudo chmod -R u+rwX  public/uploads
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@localhost"
sudo -u git -H git config --global core.autocrlf input
sudo -u git -H cp config/database.yml.mysql config/database.yml
sudo -u git -H sed -i 's/secure password/'$dbpw'/g' config/database.yml
cd /home/git/gitlab
sudo -u git -H /usr/local/bin/bundle install --deployment --without development test postgres aws
 
cd /home/git/gitlab
echo -e "yes" | sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
 
wget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn
chmod +x /etc/init.d/gitlab
chkconfig --add gitlab
chkconfig gitlab on
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
service gitlab start
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
 
#nginx install
yum update
yum -y install nginx
chkconfig nginx on
cp lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.conf
 
usermod -a -G git nginx
chmod g+rx /home/git/




upstream gitlab {
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}
 
server {
  listen *:80;         # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
  server_name 192.168.188.150;     # e.g., server_name source.example.com;
  server_tokens off;     # don't show the version number, a security best practice
  root /home/git/gitlab/public;
 
  # Increase this if you want to upload large attachments
  # Or if you want to accept large git objects over http
  client_max_body_size 20m;
 
  # individual nginx logs for this gitlab vhost
  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;
 
  location / {
    # serve static files from defined root folder;.
    # @gitlab is a named location for the upstream fallback, see below
    try_files $uri $uri/index.html $uri.html @gitlab;
  }
  location @gitlab {
    proxy_read_timeout 300; # Some requests take more than 30 seconds.
    proxy_connect_timeout 300; # Some requests take more than 30 seconds.
    proxy_redirect     off;
 
    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              $http_host;
    proxy_set_header   X-Real-IP         $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
 
    proxy_pass http://gitlab;
  }
 
  # Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
  location ~ ^/(assets)/  {
    root /home/git/gitlab/public;
    gzip_static on; # to serve pre-gzipped version
    expires max;
    add_header Cache-Control public;
  }
 
  error_page 502 /502.html;
}


접속 시 아이뒤/비번 : admin@local.host / 5iveL!fe



 댓글

댓글 목록 (0개)