Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dgoo2308/bbff9b5d70f7b0787d91 to your computer and use it in GitHub Desktop.
Save dgoo2308/bbff9b5d70f7b0787d91 to your computer and use it in GitHub Desktop.

Revisions

  1. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 10 additions and 11 deletions.
    21 changes: 10 additions & 11 deletions CentOS-Install-gitlab_ci.sh
    Original file line number Diff line number Diff line change
    @@ -79,15 +79,15 @@ bundle exec whenever -w RAILS_ENV=production
    exit

    ### the service script
    ### ATTENSION ###
    ### ### ATTENSION ###
    ### gitlab-ci must start up after mysql and redis
    ###
    ### so if you found gitlab_ci service starts after mysql or redis.
    ### please check mysql and redis service and change the start order of gitlab_ci

    ### for example, insert this line in startup script head:
    ### so if you found gitlab_ci service starts BEFORE mysql or redis.
    ### please check mysql and redis service and change the start order of service gitlab_ci
    ###
    ### for example, insert this in startup script to the second line:
    ### `# chkconfig: - 70 30`

    ###
    ### then `chkconfig --del gitlab_ci; chkconfig -add gitlab_ci`

    wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/init.d/gitlab_ci -P /etc/init.d/
    @@ -99,25 +99,24 @@ chown -R gitlab_ci:gitlab_ci /home/gitlab_ci

    ### nginx config
    cd /etc/nginx
    mkdir -p sites-available sites-enabled
    mkdir sites-available sites-enabled
    sudo wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/nginx/gitlab_ci -P /etc/nginx/sites-available/
    sudo ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci
    vim /etc/nginx/sites-available/gitlab_ci
    # - change the server_name of this server
    # - dont forget delete default_server after `listen 80`
    chkconfig nginx on
    service nginx start

    ### disable user gitlab_ci login
    usermod -s /sbin/nologin gitlab_ci

    ### make sure user `gitlab_ci` can execute commands by sudo without tty started
    ### because the init.d script need `sudo -u gitlab_ci ...`
    ### so replace `Defaults requiretty` by this line in file `/etc/sudoers`:
    ### because the init.d script needs `sudo -u gitlab_ci ...` to launch
    ### replace `Defaults requiretty` by this line in file `/etc/sudoers`:
    ### `Defaults:gitlab_ci !requiretty`
    visudo

    ### done!
    ### default account and password:
    ### use this account and password to login:
    ### [email protected]
    ### 5iveL!fe
  2. @ETiV ETiV renamed this gist Jun 4, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,9 @@ yum -y install nginx
    chkconfig nginx on
    chkconfig mysqld on
    chkconfig redis on

    ### start redis server
    ### otherwise the `Background Jobs` page says "Internal Server Error"
    service redis start

    ### mysql
  4. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,7 @@ yum -y install nginx
    chkconfig nginx on
    chkconfig mysqld on
    chkconfig redis on
    service redis start

    ### mysql
    service mysqld start
  5. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -107,6 +107,12 @@ service nginx start
    ### disable user gitlab_ci login
    usermod -s /sbin/nologin gitlab_ci

    ### make sure user `gitlab_ci` can execute commands by sudo without tty started
    ### because the init.d script need `sudo -u gitlab_ci ...`
    ### so replace `Defaults requiretty` by this line in file `/etc/sudoers`:
    ### `Defaults:gitlab_ci !requiretty`
    visudo

    ### done!
    ### default account and password:
    ### [email protected]
  6. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -84,7 +84,7 @@ exit
    ### for example, insert this line in startup script head:
    ### `# chkconfig: - 70 30`

    ### then `chkconfig gitlab_ci off ; chkconfig gitlab_ci on`
    ### then `chkconfig --del gitlab_ci; chkconfig -add gitlab_ci`

    wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/init.d/gitlab_ci -P /etc/init.d/
    chmod +x /etc/init.d/gitlab_ci
  7. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 22 additions and 3 deletions.
    25 changes: 22 additions & 3 deletions install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,15 @@ curl -L https://get.rvm.io | bash -s stable
    rvm install 2.0.0
    rvm use 2.0.0@global --default

    # for chinese user, if you have a wonderful speed ignore this part
    # to have a faster download speed
    # switch gem source to ruby.taobao.org
    # see http://ruby.taobao.org/ for more
    gem source -r https://rubygems.org/
    gem source -a http://ruby.taobao.org/
    gem sources -l

    ### install bundler and rails
    gem install bundler
    gem install rails

    @@ -21,6 +24,7 @@ yum -y install redis
    yum -y install mysql-devel mysql-server mysql
    yum -y install nginx

    chkconfig nginx on
    chkconfig mysqld on
    chkconfig redis on

    @@ -47,9 +51,11 @@ cd gitlab-ci
    git checkout 2-2-stable
    mkdir -p tmp/pids
    mkdir -p tmp/sockets
    chmod -R 755 tmp/

    ### AGAIN for chinese users.
    ### modify Gemfile.
    ### change the first line into
    ### change the first line `source ...` into
    ### `source 'http://ruby.taobao.org/'`
    vim Gemfile

    @@ -62,16 +68,29 @@ vim config/database.yml
    # - change the username and password for mysql user gitlab_ci

    bundle exec rake db:setup RAILS_ENV=production

    ### install crontab job for user gitlab_ci
    su gitlab_ci
    bundle exec whenever -w RAILS_ENV=production
    exit

    ### service script
    ### the service script
    ### ATTENSION ###
    ### gitlab-ci must start up after mysql and redis
    ###
    ### so if you found gitlab_ci service starts after mysql or redis.
    ### please check mysql and redis service and change the start order of gitlab_ci

    ### for example, insert this line in startup script head:
    ### `# chkconfig: - 70 30`

    ### then `chkconfig gitlab_ci off ; chkconfig gitlab_ci on`

    wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/init.d/gitlab_ci -P /etc/init.d/
    chmod +x /etc/init.d/gitlab_ci
    chkconfig gitlab_ci on

    ### give right back to gitlab_ci
    ### give the permissions back to user gitlab_ci
    chown -R gitlab_ci:gitlab_ci /home/gitlab_ci

    ### nginx config
  8. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,9 @@ yum -y install redis
    yum -y install mysql-devel mysql-server mysql
    yum -y install nginx

    chkconfig mysqld on
    chkconfig redis on

    ### mysql
    service mysqld start
    /usr/bin/mysql_secure_installation
  9. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -24,18 +24,16 @@ yum -y install nginx
    ### mysql
    service mysqld start
    /usr/bin/mysql_secure_installation
    # manually set password for root of mysql
    # - manually set password for root of mysql

    ### add user
    mysql -u root -p
    CREATE DATABASE IF NOT EXISTS `gitlab_ci_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
    CREATE USER 'gitlab_ci'@'localhost' IDENTIFIED BY '${PASSWORD}';
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlab_ci_production`.* TO 'gitlab_ci'@'localhost';


    ### user gitlab_ci
    useradd --comment 'GitLab CI' -m gitlab_ci
    # su gitlab_ci

    ### get gitlab-ci
    cd /home/gitlab_ci/
    @@ -58,7 +56,7 @@ bundle --without development test
    ### database config
    cp config/database.yml.mysql config/database.yml
    vim config/database.yml
    # set username and password for mysql
    # - change the username and password for mysql user gitlab_ci

    bundle exec rake db:setup RAILS_ENV=production
    su gitlab_ci
  10. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -84,6 +84,9 @@ vim /etc/nginx/sites-available/gitlab_ci
    chkconfig nginx on
    service nginx start

    ### disable user gitlab_ci login
    usermod -s /sbin/nologin gitlab_ci

    ### done!
    ### default account and password:
    ### [email protected]
  11. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 38 additions and 1 deletion.
    39 changes: 38 additions & 1 deletion install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,7 @@ yum -y update
    yum -y install wget curl gcc libxml2-devel libxslt-devel make openssh-server libyaml-devel postfix libicu-devel libcurl-devel libcurl readline-devel readline glibc glibc-devel openssl-devel openssl mysql++-devel postgresql-devel zlib-devel git
    yum -y install redis
    yum -y install mysql-devel mysql-server mysql
    yum -y install nginx

    ### mysql
    service mysqld start
    @@ -44,10 +45,46 @@ cd gitlab-ci
    ### prepare
    git checkout 2-2-stable
    mkdir -p tmp/pids
    mkdir -p tmp/sockets

    ### modify Gemfile.
    ### change the first line into
    ### `source 'http://ruby.taobao.org/'`
    vim Gemfile

    ### install bundler
    ### install
    bundle --without development test

    ### database config
    cp config/database.yml.mysql config/database.yml
    vim config/database.yml
    # set username and password for mysql

    bundle exec rake db:setup RAILS_ENV=production
    su gitlab_ci
    bundle exec whenever -w RAILS_ENV=production
    exit

    ### service script
    wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/init.d/gitlab_ci -P /etc/init.d/
    chmod +x /etc/init.d/gitlab_ci
    chkconfig gitlab_ci on

    ### give right back to gitlab_ci
    chown -R gitlab_ci:gitlab_ci /home/gitlab_ci

    ### nginx config
    cd /etc/nginx
    mkdir -p sites-available sites-enabled
    sudo wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/nginx/gitlab_ci -P /etc/nginx/sites-available/
    sudo ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci
    vim /etc/nginx/sites-available/gitlab_ci
    # - change the server_name of this server
    # - dont forget delete default_server after `listen 80`
    chkconfig nginx on
    service nginx start

    ### done!
    ### default account and password:
    ### [email protected]
    ### 5iveL!fe
  12. @ETiV ETiV revised this gist Jun 4, 2013. 1 changed file with 50 additions and 1 deletion.
    51 changes: 50 additions & 1 deletion install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,53 @@
    #!/bin/sh

    rpm -Uih https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
    curl -L https://get.rvm.io | bash -s stable --rails
    curl -L https://get.rvm.io | bash -s stable
    rvm install 2.0.0
    rvm use 2.0.0@global --default

    # to have a faster download speed
    # switch gem source to ruby.taobao.org
    # see http://ruby.taobao.org/ for more
    gem source -r https://rubygems.org/
    gem source -a http://ruby.taobao.org/
    gem sources -l
    gem install bundler
    gem install rails

    ### install dep-packages
    yum -y update
    yum -y install wget curl gcc libxml2-devel libxslt-devel make openssh-server libyaml-devel postfix libicu-devel libcurl-devel libcurl readline-devel readline glibc glibc-devel openssl-devel openssl mysql++-devel postgresql-devel zlib-devel git
    yum -y install redis
    yum -y install mysql-devel mysql-server mysql

    ### mysql
    service mysqld start
    /usr/bin/mysql_secure_installation
    # manually set password for root of mysql

    ### add user
    mysql -u root -p
    CREATE DATABASE IF NOT EXISTS `gitlab_ci_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
    CREATE USER 'gitlab_ci'@'localhost' IDENTIFIED BY '${PASSWORD}';
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlab_ci_production`.* TO 'gitlab_ci'@'localhost';


    ### user gitlab_ci
    useradd --comment 'GitLab CI' -m gitlab_ci
    # su gitlab_ci

    ### get gitlab-ci
    cd /home/gitlab_ci/
    git clone https://github.com/gitlabhq/gitlab-ci.git
    cd gitlab-ci

    ### prepare
    git checkout 2-2-stable
    mkdir -p tmp/pids

    ### modify Gemfile.
    ### change the first line into
    ### `source 'http://ruby.taobao.org/'`
    vim Gemfile

    ### install bundler
  13. @ETiV ETiV created this gist Jun 4, 2013.
    4 changes: 4 additions & 0 deletions install-gitlab_ci-centos.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    #!/bin/sh

    rpm -Uih https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
    curl -L https://get.rvm.io | bash -s stable --rails