Skip to content

Instantly share code, notes, and snippets.

@jhoughtelin
Forked from aortmannm/gitlab.sh
Last active January 2, 2016 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jhoughtelin/8298621 to your computer and use it in GitHub Desktop.
Save jhoughtelin/8298621 to your computer and use it in GitHub Desktop.
# Some Minor changes to un-break the script for...
#
# Joyent Instance (Base64 13.3.0)
## Install necessary packages
pkgin up
pkgin -y in \
bash \
coreutils \
curl \
gcc47 \
gcc47-runtime \
gmake \
icu \
libxml2 \
libxslt \
patch \
redis \
scmgit \
scons \
libyaml \
automake \
autoconf
## Done Snapshot: packagesinstalled
## Enable redis server
svcadm enable redis
## Done Snapshot: redisactivated
## Install RVM, Ruby and rails
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 1.9.3
rvm use 1.9.3 --default
## Done snapshot: rubyinstalled
## Create git user for gitlab
groupadd git
useradd -s /bin/sh -c 'Git Version Control' -g git -d /home/git -m git
passwd git # supermegaultralongpasswordthatnoonewilleverrememberyetaloneguess
useradd -s /bin/false -d /home/git -m -c GitLab gitlab
usermod -G git gitlab
## Done snapshot: gitusercreated
## Clone gitlab-shell for gitlabhq
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git /home/git/gitlab-shell
cd /home/git/gitlab-shell
git checkout v1.4.0
## Copy and edit config.yml (IPS Domains etc...)
cp config.yml.example config.yml
vi config.yml
## Do setup
./bin/install
## Done snapshot: gitlabshellinstalled
## Install mysql server and client and enable it
pkgin -y in mysql-server-5.6.13
svcadm enable mysql
## Connect to mysql no password at beginning
# mysql -u root -p
## Create a user for GitLab. (change $password to a real password)
mysql -u root -e "CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'CHANGE_THIS_PASSWORD';"
## Create the GitLab production database
mysql -u root -e "CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;"
## Grant the GitLab user necessary permissions on the table.
mysql -u root -e "GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';"
## Try connecting to the new database with the new user
# sudo -u git -H mysql -u gitlab -p $mysqlpass -D gitlabhq_production
## Done snapshot: mysqlworking
## Installing gitlab in git folder
cd /home/git/
## Clone GitLab repository
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
## Go to gitlab dir
cd /home/git/gitlab
## Checkout to stable release
sudo -u git -H git checkout 5-2-stable
## Done snapshot: gitlabcloned
## Copy the example GitLab config
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
## Make sure to change "localhost" to the fully-qualified domain name of your
## host serving GitLab where necessary
sudo -u git -H vi config/gitlab.yml
## Make sure GitLab can write to the log/ and tmp/ directories
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX log/
sudo chmod -R u+rwX tmp/
## Create directory for satellites
sudo -u git -H mkdir /home/git/gitlab-satellites
## Create directories for sockets/pids and make sure GitLab can write to them
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/
## Create public/uploads directory otherwise backup will fail
sudo -u git -H mkdir public/uploads
sudo chmod -R u+rwX public/uploads
## Copy the example Puma config and edit if necessary
sudo -u git -H cp config/puma.rb.example config/puma.rb
sudo -u git -H vi config/puma.rb
## Configure Git global settings for git user, useful when editing via web
## Edit user.email according to what is set in gitlab.yml
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@localhost"
## Done snapshot: gitlabconfigured
## Configure gitlab db settings
sudo -u git cp config/database.yml.mysql config/database.yml
sudo -u git vi config/database.yml
## Install gems
cd /home/git/gitlab
sudo gem install charlock_holmes --version '0.6.9.4'
## Doens't work snapshot: dontworkmysql
chmod 777 -R /usr/local/rvm/
bundle install --without development test postgres ## next try
## Done snapshot: bundleinstalled
## Let's fix this
gem install libv8 -v 3.11.8.13
## This command will ALSO fail. Don't worry!
gem install therubyracer -v 0.11.3
## Let's fix some more:
cd /usr/local/rvm/gems/ruby-1.9.3-p484/gems/therubyracer-0.11.3/ext/v8
vi Makefile
## Search for DLDFLAGS and append -mimpure-text
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) -mimpure-text
## Save and close
make
cd ../..
gem build therubyracer.gemspec
mkdir /home/git/gems
cp therubyracer-0.11.3.gem /home/git/gems
cd /home/git/gems
gem unpack therubyracer-0.11.3.gem
## Finally, update Gemfile again
cd /home/git/gitlab
vi Gemfile
## Search for therubyracer and add the version number and :path
gem "therubyracer", "0.11.3", :path => "/home/git/gems/therubyracer-0.11.3"
## Run bundle again
bundle install --without development test postgres
## Install the bundler, otherwise the git user won't find it.
## Yes, there's always one illogical step in any HowTo :-(
gem install bundler
chown git:other .bundle -R
chown gitlab:other .bundle -R
## Now run as user git
chmod 777 -R /usr/local/rvm/gems
chmod 777 -R /home/git/gems
chmod 777 -R /home/git/gitlab/
sudo -u git -H bundle install --deployment --without development test postgres
## Done snapshot: bundlecomplete
## Initialise Database and Activate Advanced Features
sudo -u git -H sh -c 'printf "%b\n%b\n" "PATH=\$PATH:/home/git/gitlab" "export PATH" >> /home/git/.profile'
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
## Done snapshot: dbtablecreated
## Install INIT script
sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab
cd /etc/rc2.d/
ln -s ../init.d/gitlab S99gitlab
## Some fixes for gitlab status checks
sudo chown -R git:git /home/git/repositories/
pkgin -y in ap22-py27-python-3.3.1
## Link that we can access with python2
sudo ln -s /opt/local/bin/python /opt/local/bin/python2
## Check gitlab status
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
## Done snapshot: stuck2
## Trying to start sidekiq (checked that redis server is running)
sudo -u git -H bundle exec rake sidekiq:start RAILS_ENV=production
## installing nginx
pkgin -y in nginx
mkdir -p /etc/nginx/sites-available
sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/nginx/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment