Created
April 14, 2013 19:29
-
-
Save kaspergrubbe/5383877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# <UDF name="HOSTNAME" Label="server hostname" default="linode"/> | |
# Update system | |
apt-get update | |
apt-get -y install aptitude | |
aptitude -y full-upgrade | |
# Setup needed packages for building Ruby | |
apt-get -y install gcc make git zlib1g-dev build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev | |
# Setting up SSH-keys | |
wget https://raw.github.com/kaspergrubbe/publickey/master/id_rsa.pub -O key | |
# Setup root: | |
mkdir -p /root/.ssh | |
touch /root/.ssh/authorized_keys | |
cat key | cat >> /root/.ssh/authorized_keys | |
# colors for root: | |
sed -i "s/#force_color_prompt=yes/force_color_prompt=yes/g" /root/.bashrc | |
# Add deploy user with ssh | |
adduser deployer --ingroup sudo --disabled-password --gecos "" | |
usermod -a -G sudo deployer | |
sudo -u deployer mkdir -p /home/deployer/.ssh | |
sudo -u deployer touch /home/deployer/.ssh/authorized_keys | |
cat key | cat >> /home/deployer/.ssh/authorized_keys | |
sudo -u deployer ssh-keygen -q -t rsa -N '' -f /home/deployer/.ssh/id_rsa | |
rm key | |
# enable colors for deployer | |
sed -i "s/#force_color_prompt=yes/force_color_prompt=yes/g" /home/deployer/.bashrc | |
sudo -u deployer mkdir /home/deployer/bin | |
sudo -u deployer sed -i '1i PATH=/home/deployer/bin:$PATH' /home/deployer/.bashrc | |
sudo -u deployer source /home/deployer/.bashrc | |
# Ruby GC-tweaks (deployer) | |
echo export RUBY_HEAP_MIN_SLOTS=1000000 >> /home/deployer/.bashrc | |
echo export RUBY_HEAP_SLOTS_INCREMENT=1000000 >> /home/deployer/.bashrc | |
echo export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 >> /home/deployer/.bashrc | |
echo export RUBY_GC_MALLOC_LIMIT=1000000000 >> /home/deployer/.bashrc | |
echo export RUBY_HEAP_FREE_MIN=500000 >> /home/deployer/.bashrc | |
# Dont install rdoc and stuff for gems | |
sudo -u deployer touch /home/deployer/.gemrc | |
echo gem: --no-rdoc --no-ri >> /home/deployer/.gemrc | |
# Compile flags | |
echo "" >> /home/deployer/.bashrc | |
echo 'export CFLAGS="-march=native -O3 -pipe -fomit-frame-pointer"' >> /home/deployer/.bashrc | |
# Installing RBENV | |
su deployer -c "cd ~ && wget https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer && bash rbenv-installer" | |
echo 'export RBENV_ROOT="${HOME}/.rbenv"' >> /home/deployer/.bashrc | |
echo 'if [ -d "${RBENV_ROOT}" ]; then' >> /home/deployer/.bashrc | |
echo ' export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /home/deployer/.bashrc | |
echo ' eval "$(rbenv init -)"' >> /home/deployer/.bashrc | |
echo 'fi' >> /home/deployer/.bashrc | |
su deployer -c "git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build" | |
su deployer -c "cd ~ && ~/.rbenv/bin/rbenv install 2.0.0-p0" | |
su deployer -c "cd ~ && ~/.rbenv/bin/rbenv install 1.9.3-p392" | |
su deployer -c "cd ~ && ~/.rbenv/bin/rbenv global 1.9.3-p392" | |
su deployer -c "source ~/.bashrc" | |
su deployer -c "/home/deployer/.rbenv/shims/gem install bundler" | |
su deployer -c "cd ~ && ~/.rbenv/bin/rbenv rehash" | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment