Skip to content

Instantly share code, notes, and snippets.

@mhorbul
Created March 29, 2011 22:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhorbul/893526 to your computer and use it in GitHub Desktop.
Save mhorbul/893526 to your computer and use it in GitHub Desktop.
postinstall.sh script for building CentOS 5.5 vagrant box with RVM
rpm -Uvh --force --nosignature --nodigest http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh --force --nosignature --nodigest http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
yum install -y curl ftp rsync sudo time wget which git-core
yum install -y gcc bzip2 make kernel-devel-`uname -r`
yum install -y gcc-c++ zlib-devel openssl-devel readline-devel
yum erase -y wireless-tools gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts
service vboxadd status 2>&1 >> /dev/null
if [ $? -eq 1 ]; then
mount -o ro -t iso9660 /dev/cdrom /mnt
sh /mnt/VBoxLinuxAdditions.run
umount /dev/cdrom
fi
groupadd admin
useradd -p vagrant vagrant
usermod -G admin vagrant
grep '%admin' /etc/sudoers
if [ $? -eq 1 ]; then
cat >>/etc/sudoers <<\EOF
%admin ALL=(ALL) NOPASSWD:ALL
EOF
fi
cat >> /home/vagrant/.bashrc <<\EOF
export PATH=$PATH:/usr/sbin:/sbin
EOF
cd /home/vagrant
mkdir -p .ssh
chmod 700 .ssh
curl -L http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub > .ssh/authorized_keys
chmod 400 .ssh/authorized_keys
chown vagrant -R .ssh
cd
# We are going to install chef via RVM running Ruby
#yum –enablerepo=elff-testing install chef
[[ -s '/usr/local/lib/rvm' ]] || bash <( curl -L https://github.com/wayneeseguin/rvm/raw/1.3.0/contrib/install-system-wide ) --version '1.3.0'
cat > /etc/profile.d/rvm.sh <<\EOF
[[ -s '/usr/local/lib/rvm' ]] && source '/usr/local/lib/rvm'
EOF
source '/usr/local/lib/rvm'
rvm use 1.9.2 --install --default
rvm default exec gem install chef --no-ri --no-rdoc
usermod -G admin,rvm vagrant
yum clean headers packages dbcache expire-cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment