Skip to content

Instantly share code, notes, and snippets.

@bmoore
Forked from padcom/install.sh
Created December 7, 2012 21:08
Show Gist options
  • Save bmoore/4236547 to your computer and use it in GitHub Desktop.
Save bmoore/4236547 to your computer and use it in GitHub Desktop.
Gitorious installation on Ubuntu 12.04
#!/bin/bash
#------------------------------------------------------------------------------
# SETTINGS
#------------------------------------------------------------------------------
MYSQL_ROOT_PASSWORD=password
MYSQL_GITORIOUS_PASSWORD=password
GITORIOUS_HOST=gitorious
SYSADMIN=sysadmin
SYSADMIN_EMAIL=git@$GITORIOUS_HOST
SYSADMIN_PASSWORD=password
#------------------------------------------------------------------------------
# INSTALLATION STARTS HERE
#------------------------------------------------------------------------------
# Binary packages
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev libcurl4-openssl-dev apache2 apg geoip-bin libgeoip1 libgeoip-dev libpcre3 libpcre3-dev zlib1g zlib1g-dev libyaml-dev apache2-dev libonig-dev zip unzip memcached git-core git-svn git-doc git-cvs libreadline-dev sqlite3 libsqlite3-dev libmagick++4 libmagick++-dev libapache2-mod-xsendfile libxslt-dev libxml2-dev uuid uuid-dev imagemagick
# Packages built from sources
mkdir ~/src
# Ruby Enterprise
cd ~/src
wget -c http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2012.02.tar.gz
tar zxf ruby-enterprise-1.8.7-2012.02.tar.gz
wget -c https://raw.github.com/gist/1122244/ruby-ee.patch
patch -p0 < ruby-ee.patch
sudo ruby-enterprise-1.8.7-2012.02/installer
cd /opt
sudo ln -s ruby-enterprise-1.8.7-2012.02/ ruby-enterprise
sudo ln -s /opt/ruby-enterprise/bin/ruby /opt/ruby-enterprise/bin/rake /opt/ruby-enterprise/bin/gem /usr/local/bin
sudo ln -s /opt/ruby-enterprise/bin/irb /usr/bin/irb
sudo sed -e '$ a\export PATH=\/opt\/ruby-enterprise\/bin:$PATH' -i /etc/profile
sudo sed -e '$ a\export LD_LIBRARY_PATH=\"\/usr\/local\/lib\"' -i /etc/profile
sudo sed -e '$ a\export LDFLAGS=\"-L\/usr\/local\/lib -Wl,-rpath,\/usr\/local\/lib\"' -i /etc/profile
sudo sed -e '1 i\\/usr\/local\/lib' -i /etc/ld.so.conf
source /etc/profile
sudo ldconfig
# MySQL
echo "mysql-server-5.5 mysql-server/root_password password $MYSQL_ROOT_PASSWORD" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password seen true" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again seen true" | sudo debconf-set-selections
sudo apt-get install -y mysql-client-5.5 mysql-server-5.5 libmysqlclient-dev
mysql -u root --password=$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE gitorious"
mysql -u root --password=$MYSQL_ROOT_PASSWORD -e "CREATE USER 'gitorious'@'localhost' IDENTIFIED BY '$MYSQL_GITORIOUS_PASSWORD'"
mysql -u root --password=$MYSQL_ROOT_PASSWORD -e "GRANT ALL PRIVILEGES ON gitorious.* TO 'gitorious'@'localhost'"
# Sphinx
cd ~/src
wget -c http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz
tar zxf sphinx-0.9.9.tar.gz
cd sphinx-0.9.9
./configure
make
sudo make install
# Memcached
sudo update-rc.d memcached defaults
# Adding gitorious group
sudo groupadd gitorious
sudo usermod -a -G gitorious $SYSADMIN
# Cloning gitorious project
sudo git clone https://git.gitorious.org/gitorious/mainline.git /var/www/gitorious
sudo chown -R $SYSADMIN:gitorious /var/www/gitorious
sudo chmod -R g+sw /var/www/gitorious
sudo ln -s /var/www/gitorious/script/gitorious /usr/local/bin/gitorious
cd /var/www/gitorious/
git submodule init
git submodule update
mv public/.htaccess public/.htaccess-DISABLED
mkdir -p tmp/pids
sudo chmod ug+x script/*
sudo chmod -R g+w config/ log/ public/ tmp/
sudo ln -s /var/www/gitorious/doc/templates/ubuntu/git-ultrasphinx /etc/init.d/git-ultrasphinx
sudo ln -s /var/www/gitorious/doc/templates/ubuntu/git-daemon /etc/init.d/git-daemon
sudo ln -s /var/www/gitorious/doc/templates/ubuntu/git-poller /etc/init.d/git-poller
sudo ln -s /var/www/gitorious/doc/templates/ubuntu/stomp /etc/init.d/stomp
sudo chmod +x /etc/init.d/git-ultrasphinx
sudo chmod +x /etc/init.d/git-daemon
sudo chmod +x /etc/init.d/git-poller
sudo chmod +x /etc/init.d/stomp
sudo update-rc.d -f git-daemon start 99 2 3 4 5 .
sudo update-rc.d -f git-ultrasphinx start 99 2 3 4 5 .
sudo update-rc.d -f git-poller start 99 2 3 4 5 .
sudo update-rc.d -f stomp start 99 2 3 4 5 .
sudo gem install --no-ri --no-rdoc bundler
sudo ln -s /opt/ruby-enterprise/bin/bundle /usr/bin/bundle
cd /var/www/gitorious
sudo bundle install
sudo bundle pack
sudo bundle install --path vendor/cache
#sudo adduser git
sudo adduser --system --home /var/www/gitorious/ --no-create-home --shell /bin/bash git
sudo usermod -a -G gitorious git
sudo mkdir /srv/git
sudo ln -s /srv/git /var/git
sudo mkdir /srv/git/repositories
sudo mkdir /srv/git/tarballs
sudo mkdir /srv/git/tarballs-work
sudo chown -R git:gitorious /srv/git
sudo chown -R git:gitorious /var/www/gitorious
sudo su git -c "mkdir ~/.ssh"
sudo su git -c "chmod 700 ~/.ssh"
sudo su git -c "touch ~/.ssh/authorized_keys"
sudo su git -c "touch ~/.bashrc"
sudo su git -c "echo 'export RUBY_HOME=/opt/ruby-enterprise' >> ~/.bashrc"
sudo su git -c "echo 'export GEM_HOME=\$RUBY_HOME/lib/ruby/gems/1.8/gems' >> ~/.bashrc"
sudo su git -c "echo 'export PATH=\$RUBY_HOME/bin:\$PATH' >> ~/.bashrc"
cd /var/www/gitorious
sudo bash -c "cat > config/broker.yml" << EOF
production:
adapter: stomp
EOF
sudo bash -c "cat > config/database.yml" << EOF
production:
adapter: mysql
database: gitorious
username: gitorious
password: $MYSQL_GITORIOUS_PASSWORD
host: localhost
encoding: utf8
EOF
sudo bash -c "cat > config/gitorious.yml" << EOF
production:
cookie_secret: `< /dev/urandom tr -dc A-Za-z0-9 | head -c64`
repository_base_path: "/srv/git/repositories"
extra_html_head_data:
system_message:
gitorious_client_port: 80
gitorious_client_host: $GITORIOUS_HOST
gitorious_host: $GITORIOUS_HOST
gitorious_user: git
exception_notification_emails: $SYSADMIN_EMAIL
mangle_email_addresses: true
public_mode: false
locale: en
archive_cache_dir: "/srv/git/tarballs"
archive_work_dir: "/srv/git/tarballs-work"
only_site_admins_can_create_projects: true
hide_http_clone_urls: true
is_gitorious_dot_org: false
use_ssl: false
EOF
sudo env RAILS_ENV=production rake _0.8.7_ db:migrate
sudo cat | sudo env RAILS_ENV=production script/create_admin << EOF
$SYSADMIN_EMAIL
$SYSADMIN_PASSWORD
EOF
sudo cat | script/console production << EOF
user = User.first
user.login = "$SYSADMIN"
user.activate
user.accept_terms
user.save
EOF
sudo env RAILS_ENV=production rake _0.8.7_ ultrasphinx:bootstrap
cd /var/www/gitorious
sudo chown -R git:gitorious config/environment.rb script/poller log tmp
sudo chmod -R g+w config/environment.rb script/poller log tmp
sudo chmod ug+x script/poller
sudo chmod g-w /var/www/gitorious
sudo gem install stompserver
sudo ln -s /opt/ruby-enterprise/bin/stompserver /usr/bin/stompserver
sudo /etc/init.d/stomp start
sudo env RAILS_ENV=production /etc/init.d/git-daemon start
sudo /etc/init.d/git-poller start
sudo gem install --no-ri --no-rdoc passenger --version 3.0.19
sudo /opt/ruby-enterprise/bin/passenger-install-apache2-module
sudo bash -c "cat > passenger.load" << EOF
LoadModule passenger_module /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-3.0.19
PassengerRuby /opt/ruby-enterprise/bin/ruby
EOF
sudo mv passenger.load /etc/apache2/mods-available/
sudo a2enmod passenger
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod expires
sudo bash -c "cat > gitorious" << EOF
<VirtualHost *:80>
<Directory /var/www/gitorious/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>
DocumentRoot /var/www/gitorious/public
ServerName $GITORIOUS_HOST
# Gzip/Deflate
# http://fluxura.com/2006/5/19/apache-for-static-and-mongrel-for-rails-with-mod_deflate-and-capistrano-support
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Far future expires date
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 year"
</FilesMatch>
# No Etags
FileETag None
RewriteEngine On
# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
</VirtualHost>
EOF
sudo mv gitorious /etc/apache2/sites-available/
sudo a2ensite gitorious
sudo a2dissite default
sudo a2dissite default-ssl
sudo invoke-rc.d apache2 restart
sudo chmod g-w /var/www/gitorious
sudo chown -R git:gitorious /var/www/gitorious
--- ruby-enterprise-1.8.7-2012.02/source/distro/google-perftools-1.7/src/tcmalloc.cc 2012-02-19 15:09:11.000000000 +0100
+++ ruby-enterprise-1.8.7-2012.02/source/distro/google-perftools-1.7/src/tcmalloc.cc 2012-07-05 13:34:17.677491684 +0200
@@ -1669,5 +1669,5 @@
MallocHook::InvokeNewHook(result, size);
return result;
}
-void *(*__memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
+void *(* volatile __memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
#endif // #ifndef TCMALLOC_FOR_DEBUGALLOCATION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment