Forum archive
TKLPatch for Gitorious
This TKLPatch will convert turnkey-core-beta-lucid-x86 image to a Gitorious appliance setup to work in a private network. I'm not a git user yet but I'm learning quick (to be a cool rails dev). That said, it's important for me that if any community member has experience with git, please give this appliance a test drive and feel free to post bugs / recommendations.
IMPORTANT NOTE: you must add gitorious.localdomain to your OS hosts file to access this appliance using this url. Hosts file is located:
Windows: C:\windows\system32\drivers\etc\hosts
Linux: /etc/hosts
Mac: ???
Just add a line with the appliance IP and the hostname. Ex:
192.168.1.100 gitorious.localdomain
Features:
Deployed on apache using:
Ruby Enterprise 1.8.7
Passenger 2.2.15
Apache ActiveMQ
Postfix MTA
Access url: http://gitorious.localdomain/
User: admin@example.org
Pass: turnkey
What it does:
1. Sets hostname to gitorious.localdomain
# Set hostname HOSTNAME="gitorious" echo "$HOSTNAME" > /etc/hostname sed -i "s|127.0.1.1 \(.*\)|127.0.1.1 $HOSTNAME $HOSTNAME.localdomain|" /etc/hosts hostname gitorious
2. Updates packages information
apt-get update
3. Download and installs Ruby Enterprise & RubyGems 1.3.7. Creates symlinks to usr/bin
# Install Ruby Enterprise and RubyGems wget http://rubyforge.org/frs/download.php/71100/ruby-enterprise_1.8.7-2010.02_i386_ubuntu10.04.deb dpkg -i ruby-enterprise_1.8.7-2010.02_i386_ubuntu10.04.deb rm ruby-enterprise_1.8.7-2010.02_i386_ubuntu10.04.deb ln -s /usr/local/bin/ruby /usr/bin/ruby wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz tar xf rubygems-1.3.7.tgz cd rubygems-1.3.7/ ruby setup.rb ln -s /usr/local/bin/gem /usr/bin/gem cd /root/ rm -Rf rubygems-1.3.7/
4. Install apache, git, openjdk (for ActiveMQ), sphinx, mysql-server, Xsendfile apache module (needed by gitorious to work with tars), apg (for random key creation), Memcached for better performance, and other requirements. Gitorious uses sphinx to accelerate database searches, through a gem called ultrasphinx.
# Install required packages install build-essential apache2-mpm-prefork apache2-prefork-dev libapr1-dev libaprutil1-dev git-core git-svn git-doc git-cvs sphinxsearch postfix memcached mysql-server imagemagick libmagickwand-dev aspell libaspell-dev libapache2-mod-xsendfile jsvc openjdk-6-jre-headless apg
5. Install passenger and apache modules. Configure passenger to use Ruby Enterprise.
gem install --no-ri --no-rdoc --version 2.2.15 passenger /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15/bin/passenger-install-apache2-module -a echo "LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so" > /etc/apache2/mods-available/passenger.load echo "<IfModule mod_passenger.c>" > /etc/apache2/mods-available/passenger.conf echo " PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15" >> /etc/apache2/mods-available/passenger.conf echo " PassengerRuby /usr/local/bin/ruby" >> /etc/apache2/mods-available/passenger.conf echo "</IfModule>" >> /etc/apache2/mods-available/passenger.conf a2enmod passenger a2enmod rewrite a2enmod ssl echo "ServerName gitorious.localdomain" > /etc/apache2/httpd.conf service apache2 restart
6. Download & install Active MQ. Configured to use STOMP as comunication protocol. To use as a service, activemq file is overlayed to /etc/init.d
# Install ActiveMQ wget -O apache-activemq-5.3.2-bin.tar.gz http://www.carfab.com/apachesoftware/activemq/apache-activemq/5.3.2/apache-activemq-5.3.2-bin.tar.gz tar xf apache-activemq-5.3.2-bin.tar.gz -C /usr/share/ mv /usr/share/apache-activemq-5.3.2/ /usr/share/activemq rm apache-activemq-5.3.2-bin.tar.gz cp /usr/share/activemq/conf/activemq-stomp.xml /usr/share/activemq/conf/activemq.xml chmod +x /etc/init.d/activemq
7. Install required gems. All gems installed without documentation as this is a production system. Also made a symlink to rake in /usr/bin
# Install required gems gem install rack --no-rdoc --no-ri --version 1.0.1 gem install rails --no-rdoc --no-ri --version 2.3.8 gem install rdiscount --version "= 1.3.1.1" --no-ri --no-rdoc gem install stomp --version "= 1.1" --no-ri --no-rdoc gem install ruby-openid --version ">= 2.0.4" --no-ri --no-rdoc gem install --no-ri --no-rdoc ultrasphinx raspell mysql rake chronic rmagick json ruby-hmac geoip daemons echoe ruby-yadis ruby-openid mime-types diff-lcs ln -s /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake /usr/bin/rake
8. Create user and group git. Added apache user (www-data) to git group.
#Create git user and group adduser --system --home /var/www/gitorious/ --no-create-home --group --shell /bin/bash git usermod -a -G git www-data
9. Install gitorious by cloning the gitorious repository. Also configured the 3 main files (database.yml, broker.yml, and gitorios.yml, which was previously overlayed to /root/ and it's completed in this step adding the cookie_secret property as recommended by gitorious (using apg)
# Install gitorious git clone git://gitorious.org/gitorious/mainline.git /var/www/gitorious cd /var/www/gitorious echo "production:" > config/broker.yml echo " adapter: stomp" >> config/broker.yml echo "production:" > config/database.yml echo " adapter: mysql" >> config/database.yml echo " database: gitorious_production" >> config/database.yml echo " username: root" >> config/database.yml echo " password: " >> config/database.yml echo " host: localhost" >> config/database.yml echo " encoding: utf8" >> config/database.yml export SECRET=`apg -m 64 | tr -d '\n'` cat /root/gitorious.yml | sed \ -e "s/cookie_secret\:.*$/cookie_secret\: $SECRET/g" \ > /var/www/gitorious/config/gitorious.yml rm /root/gitorious.yml
10. Migrate production database, bootstrap ultrasphinx gem, and create initial user/pass. The script /root/create_admin_turnkey is a copy of script/create_admin script, modified to add the admin@example.org user and pass turnkey.
sed -i 's/0.0.0.0/localhost/' config/ultrasphinx/default.base RAILS_ENV=production rake db:create RAILS_ENV=production rake db:migrate RAILS_ENV=production rake ultrasphinx:bootstrap RAILS_ENV=production /root/create_admin_turnkey rm /root/create_admin_turnkey
11. Create various directories needed by the app and set correct ownership and permissions. Also create the gitorious symlink in /usr/bin.
mkdir -p /var/git/git-repos mkdir -p /var/git/tarballs-cache mkdir -p /var/git/tarballs-work mkdir /var/www/gitorious/tmp/pids mkdir /var/www/gitorious/.ssh touch /var/www/gitorious/.ssh/authorized_keys chown -R git:git /var/www/gitorious chown -R git:git /var/git chmod -R ug+rwx /var/git chmod 700 /var/www/gitorious/.ssh chmod 600 /var/www/gitorious/.ssh/authorized_keys ln -s /var/www/gitorious/script/gitorious /usr/bin
12. Disable default apache website and enable gitorious and gitorious-ssl websites (previously overlayed)
a2dissite default a2ensite gitorious a2ensite gitorious-ssl service apache2 reload
13.Configure overlayed scripts to start at system startup
#Make init scripts start on boot chown git:git /etc/init.d/git-ultrasphinx chown git:git /etc/init.d/git-daemon chown git:git /etc/init.d/git-poller chmod 755 /etc/init.d/git-ultrasphinx /etc/init.d/git-daemon /etc/init.d/git-poller update-rc.d git-daemon defaults update-rc.d git-ultrasphinx defaults update-rc.d git-poller defaults update-rc.d activemq defaults
14. Stop services and cleanup apt cache.
#Stop services and cleanup service mysql stop service apache2 stop cleanup_apt
Enjoy it! Please send some feedback in this forum.
Hi Rtreffer, thanks for trying the patch. Could you please provide more info on the patching process? yo can do it by issuing the following command:
And attach tklgit.log file to see what's happening during the patching process.