date > /etc/vagrant_box_build_time # Update the box apt-get -y update apt-get -y install linux-headers-$(uname -r) build-essential apt-get -y install zlib1g-dev libssl-dev libreadline5-dev apt-get -y install curl unzip apt-get clean # Set up sudo cp /etc/sudoers /etc/sudoers.orig sed -i -e 's/%sudo ALL=(ALL) ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers # Install Ruby from packages apt-get -y install ruby ruby-dev libruby1.8 ri # Install Rubygems from source rg_ver=1.6.2 curl -o /tmp/rubygems-${rg_ver}.zip \ "http://production.cf.rubygems.org/rubygems/rubygems-${rg_ver}.zip" (cd /tmp && unzip rubygems-${rg_ver}.zip && \ cd rubygems-${rg_ver} && ruby setup.rb --no-format-executable) rm -rf /tmp/rubygems-${rg_ver} /tmp/rubygems-${rg_ver}.zip # Install Chef & Puppet gem install chef --no-ri --no-rdoc gem install puppet --no-ri --no-rdoc # Install vagrant keys mkdir -p /home/vagrant/.ssh chmod 700 /home/vagrant/.ssh cd /home/vagrant/.ssh curl -Lo /home/vagrant/.ssh/authorized_keys \ 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' chmod 0600 /home/vagrant/.ssh/authorized_keys chown -R vagrant:vagrant /home/vagrant/.ssh # Tweak sshd to prevent DNS resolution (speed up logins) echo 'UseDNS no' >> /etc/ssh/sshd_config # Customize the message of the day echo 'Welcome to your Vagrant-built virtual machine.' > /var/run/motd # The netboot installs the VirtualBox support (old) so we have to remove it /etc/init.d/virtualbox-ose-guest-utils stop rmmod vboxguest aptitude -y purge virtualbox-ose-guest-x11 virtualbox-ose-guest-dkms virtualbox-ose-guest-utils # Install the VirtualBox guest additions VBOX_VERSION=$(cat /home/vagrant/.vbox_version) curl -Lo /tmp/VBoxGuestAdditions_$VBOX_VERSION.iso \ "http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso" mount -o loop /tmp/VBoxGuestAdditions_$VBOX_VERSION.iso /mnt yes|sh /mnt/VBoxLinuxAdditions.run umount /mnt # Clean up apt-get -y remove linux-headers-$(uname -r) build-essential apt-get -y autoremove rm /tmp/VBoxGuestAdditions_$VBOX_VERSION.iso # Zero out the free space to save space in the final image: dd if=/dev/zero of=/EMPTY bs=1M rm -f /EMPTY # Removing leftover leases and persistent rules echo "cleaning up dhcp leases" rm /var/lib/dhcp3/* # Make sure Udev doesn't block our network echo "cleaning up udev rules" rm /etc/udev/rules.d/70-persistent-net.rules mkdir /etc/udev/rules.d/70-persistent-net.rules rm -rf /dev/.udev/ rm /lib/udev/rules.d/75-persistent-net-generator.rules echo "Adding a 2 sec delay to the interface up, to make the dhclient happy" echo "pre-up sleep 2" >> /etc/network/interfaces exit