Thursday, November 25, 2010

Gitorious install on Debian Squeeze with stompserver

I have modified this install tutorial from Christian Johansen found here http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server

Some info from here as well http://www.bluequartz.net/projects/ElectronicImaging/SCMService/html/index.html

There is also source for a debian package by Marius MÃ¥rnes Mathiesen here http://gitorious.org/gitorious-for-debian/gitorious the most recent commits are forked here http://gitorious.org/~brodock/gitorious-for-debian/brodocks-gitorious

Squeeze is needed for the new magickwand stuff


Had issues with activemq so using stompserver instead


apt-get install -y sudo git-core git-svn apg build-essential libpcre3 libpcre3-dev sendmail \
make zlib1g zlib1g-dev ssh memcached apache2 \
libonig-dev libyaml-dev geoip-bin libgeoip-dev libgeoip1 \
uuid uuid-dev openjdk-6-jre apache2-prefork-dev curl openssl libcurl4-gnutls-dev

apt-get install -y imagemagick libmagickwand-dev && \
gem install --no-ri --no-rdoc rmagick

apt-get install -y mysql-client mysql-server libmysqlclient15-dev && \
gem install --no-ri --no-rdoc mysql

wget http://rubyforge.org/frs/download.php/71099/ruby-enterprise_1.8.7-2010.02_i386_ubuntu8.04.deb
sudo dpkg -i ruby-enterprise*

echo 'export PATH=/opt/ruby-enterprise/bin:$PATH
export LD_LIBRARY_PATH="/usr/local/lib"
export LDFLAGS="-L/usr/local/lib -Wl,-rpath,/usr/local/lib"' >> /etc/profile

echo '/usr/local/lib
include ld.so.conf.d/*.conf' >> /etc/ld.so.conf

ldconfig

cd /usr/src
wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
tar xvzf rubygems*
cd rubygems*
ruby setup.rb

cd /usr/src
wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
tar xvfz sphinx-*
cd sphinx-*
./configure
make && sudo make install
gem install --no-ri --no-rdoc ultrasphinx

gem install stompserver
echo '#!/bin/sh
# Start/stop the stompserver
# WATCH THE LINE WRAPPING BELOW
### BEGIN INIT INFO
# Provides: stomp
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Stomp
# Description: Stomp
### END INIT INFO
$DAEMON=/usr/local/bin/stompserver
test -f $DAEMON || exit 0
. /lib/lsb/init-functions
case $1 in
start) log_daemon_msg Starting stompserver stompserver
     start-stop-daemon --start --name stompserver --startas $DAEMON \
                                      --background --user git
     log_end_msg $?
    ;;
stop) log_daemon_msg Stopping stompserver stompserver
     start-stop-daemon --stop --name stompserver
     log_end_msg $?
     ;;
restart) log_daemon_msg Restarting stompserver stompserver
    start-stop-daemon --stop --retry 5 --name stompserver
    start-stop-daemon --start --name stompserver --startas $DAEMON \
                                       --background --user git
    log_end_msg $?
    ;;
status)
    status_of_proc $DAEMON stompserver && exit 0 || exit $?
    ;;
*) log_action_msg Usage: /etc/init.d/stomp {start|stop|restart|status}
    exit 2
    ;;
esac
exit 0' > /etc/init.d/stompserver
chmod +x /etc/init.d/stompserver
update-rc.d stompserver defaults

echo '#!/bin/sh
# Start/stop the git poller
#
### BEGIN INIT INFO
# Provides: git-poller
# Required-Start: stomp
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Gitorious poller
# Description: Gitorious poller
### END INIT INFO

GITORIOUS_ROOT=/var/www/gitorious
echo  `date` " Starting git-poller" >> "$GITORIOUS_ROOT/log/git-poller.log"
/bin/su -- git -c " cd $GITORIOUS_ROOT; RAILS_ENV=production script/poller $@"' > /etc/init.d/poller
chmod +x /etc/init.d/poller
update-rc.d poller defaults


git clone git://gitorious.org/gitorious/mainline.git gitorious
chmod -R g+sw /var/www/gitorious
ln -s /var/www/gitorious/script/gitorious /usr/local/bin/gitorious
cd gitorious/
rm public/.htaccess
mkdir -p tmp/pids
chmod ug+x script/*
chmod -R g+w config/ log/ public/ tmp/

which ruby
vi doc/templates/ubuntu/git-daemon
Gitorious ships with ready to use git-ultrasphinx and git-daemon scripts. Be aware that the git-daemon script has hardcoded paths to both Ruby Enterprise Edition and Gitorious. Pop open git-daemon and set correct paths to the Ruby you want to use (stick with REE if you installed it earlier) and your Gitorious installation. These are the lines you need to see (lines 16 and 18 at the time of writing):
GIT_DAEMON="/opt/ruby-enterprise/bin/ruby \
    /var/www/gitorious/script/git-daemon -d"
ln -s /var/www/gitorious/doc/templates/ubuntu/git-ultrasphinx /etc/init.d/.
ln -s /var/www/gitorious/doc/templates/ubuntu/git-daemon /etc/init.d/.

chmod +x /etc/init.d/git-ultrasphinx
chmod +x /etc/init.d/git-daemon
update-rc.d -f git-daemon start 99 2 3 4 5 .
update-rc.d -f git-ultrasphinx start 99 2 3 4 5 .

gem install --no-ri --no-rdoc rails mongrel mime-types textpow chronic \
    ruby-hmac daemons mime-types oniguruma textpow chronic BlueCloth \
    ruby-yadis ruby-openid geoip rspec rspec-rails RedCloth echoe
gem install --no-ri --no-rdoc --version="1.0.1" rack

adduser git
usermod -a -G gitorious git
mkdir /var/git
mkdir /var/git/repositories
mkdir /var/git/tarballs
mkdir /var/git/tarball-work
chown -R git:git /var/git

su git
mkdir ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
vi ~/.bashrc
Append the following to /home/git/.bashrc
# User specific aliases and functions
export RUBY_HOME=/opt/ruby-enterprise
export GEM_HOME=$RUBY_HOME/lib/ruby/gems/1.8/gems
export PATH=$RUBY_HOME/bin:$PATH

exit
cd /var/www/gitorious
cp config/database.sample.yml config/database.yml
cp config/gitorious.sample.yml config/gitorious.yml
cp config/broker.yml.example config/broker.yml
apg -m 64
config/gitorious.yml
See original doc for details on this config file
rake db:migrate RAILS_ENV=production
mysql -uroot -p
create database gitorious;
create database gitorious_test;
create database gitorious_dev;
grant all privileges on gitorious.* to YOURUSER@localhost \
    identified by 'YOURPASSWORD';
grant all privileges on gitorious_test.* to YOURUSER@localhost;
grant all privileges on gitorious_dev.* to YOURUSER@localhost;
sudo rake gems:install
vi config/database.yml
Make your config match your mysql db setup
rake db:migrate RAILS_ENV=production
cd /var/www/gitorious
env RAILS_ENV=production ruby script/create_admin
script/console
> user = User.first
> user.login = "yourname" # Change to your desired username
> user.activate
> user.accept_terms
> user.save
rake ultrasphinx:bootstrap RAILS_ENV=production
chown -R git:gitorious config/environment.rb script/poller log tmp
chmod -R g+w config/environment.rb script/poller log tmp
chmod ug+x script/poller
/etc/init.d/activemq start
env RAILS_ENV=production /etc/init.d/git-daemon start
su git -c \
  "cd /var/www/gitorious && \
    env RAILS_ENV=production script/poller run"

su git -c \
  "cd /var/www/gitorious && script/server -e production"

echo '* */1 * * * root cd /var/www/gitorious && rake ultrasphinx:index RAILS_ENV=production' >> /etc/crontab
cp doc/templates/ubuntu/gitorious-logrotate /etc/logrotate.d/gitorious
sudo chmod +x /etc/logrotate.d/gitorious
gem install passenger
passenger-install-apache2-module

a2enmod rewrite
a2enmod deflate
a2enmod passenger
a2enmod expires
a2enmod rewrite

vi conf/vhost.conf
Update config
ln -s /var/www/gitorious/conf/vhost.conf /etc/apache2/sites-available/gitorious
a2ensite gitorious

No comments: