Skip to content

Instantly share code, notes, and snippets.

@harmon
Forked from evansd/postinstall.sh
Last active August 29, 2015 14:09
Show Gist options
  • Save harmon/e6a4fed80386711ec4c5 to your computer and use it in GitHub Desktop.
Save harmon/e6a4fed80386711ec4c5 to your computer and use it in GitHub Desktop.

Revisions

  1. harmon revised this gist Nov 17, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion postinstall.sh
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,6 @@ rm -rf rubygems-1.7.2*

    # Install Chef & Puppet
    /opt/ruby/bin/gem install chef --no-ri --no-rdoc
    /opt/ruby/bin/gem install puppet --no-ri --no-rdoc

    # Add /opt/ruby/bin to the global path as the last resort so
    # Ruby, RubyGems, and Chef/Puppet are visible
  2. harmon revised this gist Nov 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion postinstall.sh
    Original file line number Diff line number Diff line change
    @@ -78,7 +78,7 @@ rm /var/lib/dhcp3/*
    # Make sure Udev doesn't block our network
    # http://6.ptmc.org/?p=164
    echo "cleaning up udev rules"
    rm /etc/udev/rules.d/70-persistent-net.rules
    rm -rf /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
  3. @evansd evansd renamed this gist Jun 28, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @evansd evansd created this gist Jun 28, 2011.
    89 changes: 89 additions & 0 deletions gistfile1.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    # Apt-install various things necessary for Ruby, guest additions,
    # etc., and remove optional things to trim down the machine.
    apt-get -y update
    apt-get -y remove apparmor
    apt-get -y install linux-headers-$(uname -r) build-essential
    apt-get -y install zlib1g zlib1g-dev libxml2 libxml2-dev libxslt-dev libssl-dev openssl libreadline5-dev
    apt-get clean

    # Remove this file to avoid dhclient issues with networking
    rm -f /etc/udev/rules.d/70-persistent-net.rules

    # Setup sudo to allow no-password sudo for "admin". Additionally,
    # make "admin" an exempt group so that the PATH is inherited.
    cp /etc/sudoers /etc/sudoers.orig
    sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=admin' /etc/sudoers
    sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:ALL/g' /etc/sudoers

    # Install NFS client
    apt-get -y install nfs-common

    # Install Ruby from source in /opt so that users of Vagrant
    # can install their own Rubies using packages or however.
    # We must install the 1.8.x series since Puppet doesn't support
    # Ruby 1.9 yet.
    wget http://ftp.ruby-lang.org/pub/ruby/ruby-1.8.7-p334.tar.gz
    tar xvzf ruby-1.8.7-p334.tar.gz
    cd ruby-1.8.7-p334
    ./configure --prefix=/opt/ruby
    make
    make install
    cd ..
    rm -rf ruby-1.8.7-p334*

    # Install RubyGems 1.7.2
    wget http://production.cf.rubygems.org/rubygems/rubygems-1.7.2.tgz
    tar xzf rubygems-1.7.2.tgz
    cd rubygems-1.7.2
    /opt/ruby/bin/ruby setup.rb
    cd ..
    rm -rf rubygems-1.7.2*

    # Install Chef & Puppet
    /opt/ruby/bin/gem install chef --no-ri --no-rdoc
    /opt/ruby/bin/gem install puppet --no-ri --no-rdoc

    # Add /opt/ruby/bin to the global path as the last resort so
    # Ruby, RubyGems, and Chef/Puppet are visible
    echo 'PATH=$PATH:/opt/ruby/bin/'> /etc/profile.d/vagrantruby.sh

    # Install insecure Vagrant SSH keys
    mkdir /home/vagrant/.ssh
    chmod 700 /home/vagrant/.ssh
    cd /home/vagrant/.ssh
    wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O authorized_keys
    chown -R vagrant /home/vagrant/.ssh

    # Install VirtualBox guest additions
    VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
    cd /tmp
    wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
    mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
    sh /mnt/VBoxLinuxAdditions.run
    umount /mnt
    rm VBoxGuestAdditions_$VBOX_VERSION.iso

    # Remove items used for building, since they aren't needed anymore
    apt-get -y remove linux-headers-$(uname -r) build-essential
    apt-get -y autoremove

    # Zero free space to aid VM compression
    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
    # http://6.ptmc.org/?p=164
    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