About Author

Hyon-Young Choi
blog: http://commani.net
twitter: @
github:

Engineering mind always..

  • Research Professor at Korea University
  • Internet, Mobile Network, Handover, QoS, ns-3, C++, Qt

About this Article

Date Released:
Wednesday, November 13 2013 11:02 PM

1. Packages / Dependencies

Optware packages

package source of TS-212 is at http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable

Update ipkg package list.

# ipkg update

# ipkg upgrade

Install packages via ipkg

# ipkg install python27 binutils coreutils git svn git-svn gcc perl patch sudo gawk grep sed make zlib openssl-dev gdbm readline ncurses-dev libxml2 libxslt m4 redis findutils man

Soft-link pkill (required for start/stop gitlab)

# ln -sf /opt/bin/pgrep /opt/bin/pkill

Redis-server configuration

Copy configuration file:

# cp /opt/share/doc/redis/examples/redis.conf /opt/etc/redis.conf
# vi /opt/etc/redis.conf

Change setting in redis.conf file: daemonize bind

damonize yes

bind 127.0.0.1

Start redis-server

# redis-server /opt/etc/redis.conf

register to init script MySettings.sh, refer here

start)

   /opt/bin/redis-server /opt/etc/redis.conf
   ;;

stop)

   killall redis-server
   ;;

Manual install: libyaml, libicu, libffi, and libatomic_ops

libyaml: site

# cd /share/homes/admin

# curl http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz | tar xz

# cd yaml-0.1.4

# ./configure --prefix=/opt

# make

# make install

libatomic_ops: site

# cd /share/homes/admin

# curl http://www.hpl.hp.com/research/linux/atomic_ops/download/libatomic_ops-1.1.tar.gz | tar xz

# cd libatomic_ops-1.1

# ./configure --prefix=/opt

# make

# make install

libicu: site

# cd /share/homes/admin

# curl http://download.icu-project.org/files/icu4c/52.1/icu4c-52_1-src.tgz | tar xz

# cd icu/source

# ./configure --prefix=/opt

# make

# make install

libffi: site

# cd /share/homes/admin

# curl ftp://sourceware.org/pub/libffi/libffi-3.0.13.tar.gz | tar xz

# cd libffi-3.0.13

# ./configure --prefix=/opt

# make

# make install

# cp /opt/lib/libffi-3.0.13/include/* /opt/include/

2. Ruby

Ruby 2.0 and above versions have compile error in TS-212. We use 1.9.3-p448, the last version of 1.9.

# cd /share/homes/admin

# curl ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p448.tar.bz2 | tar xj

# cd ruby-1.9.3-p448

# ./configure --prefix=/opt --disable-install-rdoc

# make

# make install

Update RubyGems:

# gem update --system

Download default cert.pem

# curl -fsSL curl.haxx.se/ca/cacert.pem -o "$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE')"

Install Bundler and Charlock_holmes Gem:

# gem install bundler --no-ri --no-rdoc

# gem install charlock_holmes --version '0.6.9.4'

Manual install: libv8

Libv8 Gem is required to run gitlab. The bundler in gitlab needs Libv8 version , however, that version has ia32 error on TS-212. And recent libv8 also has some configuration problem.

Download base git and required gems:

# cd /share/homes/admin

# git clone git://github.com/cowboyd/libv8.git

# cd libv8

# bundle install

Some modifications:

  • disable hardfp
  • put -fno-strict-aliasing
  • disable check_git-svn!
  • remove -Wno-unused-local-typedefs

This is a patch:

diff --git a/ext/libv8/builder.rb b/ext/libv8/builder.rb
index 7407515..e51de3e 100755
--- a/ext/libv8/builder.rb
+++ b/ext/libv8/builder.rb
@@ -18,13 +18,14 @@ module Libv8
       # compilation failures due to warnings about aliasing.
       # http://svnweb.freebsd.org/ports/head/lang/v8/Makefile?view=markup
       flags << "strictaliasing=off" if RUBY_PLATFORM.include?("freebsd") and !check_gcc_compiler(compiler)
+      flags << "strictaliasing=off"

       # Avoid compilation failures on the Raspberry Pi.
       flags << "vfp2=off vfp3=off" if RUBY_PLATFORM.include? "arm"

       # FIXME: Determine when to activate this instead of leaving it on by
       # default.
-      flags << "hardfp=on" if RUBY_PLATFORM.include? "arm"
+      flags << "hardfp=off" if RUBY_PLATFORM.include? "arm"

       # Fix Malformed archive issue caused by GYP creating thin archives by
       # default.
diff --git a/ext/libv8/checkout.rb b/ext/libv8/checkout.rb
index 71a5308..5ac56cd 100644
--- a/ext/libv8/checkout.rb
+++ b/ext/libv8/checkout.rb
@@ -21,7 +21,7 @@ module Libv8

       return unless git?(GYP_Source)

-      check_git_svn!
+      #check_git_svn!

       Dir.chdir(GYP_Source) do
         mkf = File.readlines(File.join(V8_Source, 'Makefile'))
diff --git a/patches/gcc48-wno-unused-local-typedefs.patch b/patches/gcc48-wno-unused-local-typedefs.patch
deleted file mode 100644
index d45276d..0000000
--- a/patches/gcc48-wno-unused-local-typedefs.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff --git a/build/common.gypi b/build/common.gypi
-index 3a59639..365178a 100644
---- a/build/common.gypi
-+++ b/build/common.gypi
-@@ -376,7 +376,8 @@
-           }],
-           ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
-             'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
--                        '-Wnon-virtual-dtor', '-Woverloaded-virtual' ],
-+                        '-Wnon-virtual-dtor', '-Woverloaded-virtual',
-+                        '-Wno-unused-local-typedefs' ],
-           }],
-           ['OS=="linux" and v8_enable_backtrace==1', {
-             # Support for backtrace_symbols.
-diff --git a/build/standalone.gypi b/build/standalone.gypi
-index 125c5bf..32eaf85 100644
---- a/build/standalone.gypi
-+++ b/build/standalone.gypi
-@@ -98,7 +98,8 @@
-       'target_defaults': {
-         'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
-                     '-Wnon-virtual-dtor', '-pthread', '-fno-rtti',
--                    '-fno-exceptions', '-pedantic' ],
-+                    '-fno-exceptions', '-pedantic',
-+                    '-Wno-unused-local-typedefs' ],
-         'ldflags': [ '-pthread', ],
-         'conditions': [
-           [ 'OS=="linux"', {

Apply the patch:

# curl http://www.commani.net/post/ts-212-gitlab/@data/ts-212-armv5tel.patch | patch -p1

Then, checkout module and compile

# bundle exec rake checkout

# bundle exec rake compile

Make gem file

# bundle exec rake binary

3. System Users

Create a git user for Gitlab:

# adduser -h /share/homes/git -g "Gitlab" -s /bin/bash -D git

# passwd -u git

sudo setting:

# echo "admin ALL=(ALL) ALL" > /opt/etc/sudoers.d/admin

# chmod 0440 /opt/etc/sudoers.d/admin

4. GitLab shell

Login into git account

# sudo -u git -i

Clone gitlab shell

$ cd /share/homes/git

$ git clone https://github.com/gitlabhq/gitlab-shell.git

$ cd gitlab-shell

$ git checkout v1.7.4

$ cp config.yml.example config.yml

Edit config: gitlab_url repos_path auth_file redis:bin

gitlab_url: "http://git.example.com/"

repos_path: "/share/HDA_DATA/homes/git/repositories"

auth_file: "/share/homes/git/.ssh/authorized_keys"

redis:
  bin: /opt/bin/redis-cli

Important repos_path MUST not contain any symlink!

Do setup

$ ./bin/install

5. Database

Use MySQL

Generate random password (this is an option)

$ dd if=/dev/random bs=1 count=4 | sha256sum | head -c 40

Copy the generated password something like this: 6838821069eed7a87cf0d2228e1020d6b14edb47

$ /usr/local/mysql/bin/mysql -u root -p
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED by '6838821069eed7a87cf0d2228e1020d6b14edb47';

mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';

mysql> flush privileges;

mysql> \q

6. GitLab

Clone the source

$ cd /share/homes/git

$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab

$ cd gitlab

$ git checkout 6-2-stable

Configure it

$ cp config/gitlab.yml.example config/gitlab.yml

$ vi config/gitlab.yml

Edit config: gitlab:host satellites:path gitlabshell:repospath gitlabshell:hookspath git:bin_path

gitlab:
  host: git.example.com

satellites:
  path: /share/homes/git/gitlab-satellites/

gitlab_shell:
  repos_path: /share/HDA_DATA/homes/git/repositories/
  hooks_path: /share/homes/git/gitlab-shell/hooks/

git:
  bin_path: /opt/bin/git

Make sure GitLab can write to the log/ and tmp/ directories

$ chown -R git log/ tmp/

$ chmod -R u+rwx log/ tmp/

Create directory for satellites

$ mkdir /share/homes/git/gitlab-satellites

Create directories for sockets/pids and make sure GitLab can write to them

$ mkdir tmp/pids/ tmp/sockets/

$ chmod -R u+rwx tmp/pids/ tmp/sockets/

Create public/uploads directory otherwise backup will fail

$ mkdir public/uploads

$ chmod -R u+rwx public/uploads

Copy the example Unicorn config

$ cp config/unicorn.rb.example config/unicorn.rb

$ vi config/unicorn.rb

Edit config: worker_processes working_directory listen timeout pid stderr_path stdout_path

worker_processes 1

working_directory "/share/homes/git/gitlab" # available in 0.94.0+

listen "/share/homes/git/gitlab/tmp/sockets/gitlab.socket", :backlog => 64
#listen "127.0.0.1:8080", :tcp_nopush => true

timeout 60

pid "/share/homes/git/gitlab/tmp/pids/unicorn.pid"

stderr_path "/share/homes/git/gitlab/log/unicorn.stderr.log"
stdout_path "/share/homes/git/gitlab/log/unicorn.stdout.log"

Confiugre Git global settings for git user, useful when editing via web Edit user.email according to what is set in gitlab.yml

$ git config --global user.name "GitLab"

$ git config --global user.email "gitlab@localhost"

$ git config --global core.autocrlf input

Configure GitLab DB settings

MySQL

$ cp config/database.yml.mysql config/database.yml

$ vi config/database.yml

Edit config: production:password production:socket

production:
  password: "6838821069eed7a87cf0d2228e1020d6b14edb47"
  socket: /tmp/mysql.sock

Install Gems

Change directory into gitlab:

$ cd /share/homes/git/gitlab

Edit Gemfile.lock:

File Before After
Gemfile.lock libv8 (3.11.8.17) libv8 (3.16.14.3)
therubyracer (0.11.4) therubyracer (0.12.0)
libv8 (~> 3.11.8.12) libv8 (~> 3.16.14.3)

Like this patch:

diff --git a/Gemfile.lock b/Gemfile.lock
index f919e6e..685233c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -264,7 +264,7 @@ GEM
       addressable (~> 2.3)
     letter_opener (1.1.1)
       launchy (~> 2.2)
-    libv8 (3.11.8.17)
+    libv8 (3.16.14.3)
     listen (1.2.2)
       rb-fsevent (>= 0.9.3)
       rb-inotify (>= 0.9)
@@ -494,8 +494,8 @@ GEM
     term-ansicolor (1.2.2)
       tins (~> 0.8)
     test_after_commit (0.2.1)
-    therubyracer (0.11.4)
-      libv8 (~> 3.11.8.12)
+    therubyracer (0.12.0)
+      libv8 (~> 3.16.14.3)
       ref
     thin (1.5.1)
       daemons (>= 1.0.9)

Install libv8 manually:

$ gem install -i vendor/bundle/ruby/1.9.1/ /share/homes/admin/libv8/pkg/libv8-3.16.14.3-armv5tel-linux.gem

Install gems:

$ bundle install --deployment --without development test postgres aws

Initialize Database and Activate Advenced Features

$ rake gitlab:setup RAILS_ENV=production

Compile javascript:

$ rake assets:precompile RAILS_ENV=production

Install Init Script

(by admin)

# cd /share/homes/git/gitlab/

# cp lib/support/init.d/gitlab /opt/etc/init.d/S99gitlab

# chmod +x /opt/etc/init.d/S99gitlab

Modify the path: app_root

app_root="/share/homes/git/gitlab"

Omit -i option from sudo:

if [ "$USER" != "$app_user" ]; then
  sudo -u "$app_user" -H $0 "$@"; exit;
fi

Register init script into MySettings.sh:

start)

   /opt/etc/init.d/S99gitlab start
   ;;

stop)

   /opt/etc/init.d/S99gitlab stop
   ;;

Check Application Status

Check if GitLab and its environment are configured correctly:

$ cd /share/homes/git/gitlab

$ rake gitlab:env:info RAILS_ENV=production

7. Nginx

Installation

# ipkg install nginx

Create nobody and nogroup

# addgroup nogroup

# adduser -s /bin/false -G nogroup -D -H nobody

Site Configuration

This is my own configuration I use NAS only for GitLab with nginx.

# vi /opt/etc/nginx/nginx.conf
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    upstream gitlab {
        server unix:/share/homes/git/gitlab/tmp/sockets/gitlab.socket;
    }

    server {
        listen  80;
        server_name  git.example.com;

        access_log  /opt/var/log/gitlab_access.log;
        error_log   /opt/var/log/gitlab_error.log;

        location / {
            proxy_read_timeout 300;
            proxy_connect_timeout 300;
            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_pass http://gitlab;
        }
   }
}

Register init script into MySettings.sh:

start)

   /opt/etc/init.d/S80nginx start

   /opt/bin/redis-server /opt/etc/redis.conf

   /opt/etc/init.d/S99gitlab start
   ;;

stop)

   /opt/etc/init.d/S80nginx stop

   killall redis-server

   /opt/etc/init.d/S99gitlab stop
   ;;

Restart and check

# /opt/etc/init.d/S80nginx restart

# /opt/etc/init.d/S99gitlab restart

# sudo -u git -i

$ cd /share/homes/git/gitlab

$ rake gitlab:check RAILS_ENV=production

Done


blog comments powered by Disqus