summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJack Pearkes <jackpearkes@gmail.com>2015-04-15 16:09:08 -0700
committerJack Pearkes <jackpearkes@gmail.com>2015-04-15 16:11:25 -0700
commiteac1d1a6d1c638602dc696d4101c11a3f80cbc1e (patch)
tree54f558caadcc82978cd398bc59857f033e296a66 /scripts
initial commit
Diffstat (limited to 'scripts')
-rw-r--r--scripts/base.sh24
-rw-r--r--scripts/cleanup.sh17
-rw-r--r--scripts/dep.sh9
-rw-r--r--scripts/vagrant.sh13
-rw-r--r--scripts/virtualbox.sh13
-rw-r--r--scripts/vmware.sh21
-rw-r--r--scripts/zerodisk.sh10
7 files changed, 107 insertions, 0 deletions
diff --git a/scripts/base.sh b/scripts/base.sh
new file mode 100644
index 0000000..d09645d
--- /dev/null
+++ b/scripts/base.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+perl -p -i -e 's#http://us.archive.ubuntu.com/ubuntu#http://mirror.rackspace.com/ubuntu#gi' /etc/apt/sources.list
+
+# Update the box
+apt-get -y update >/dev/null
+apt-get -y install facter linux-headers-$(uname -r) build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev curl unzip >/dev/null
+
+# Tweak sshd to prevent DNS resolution (speed up logins)
+echo 'UseDNS no' >> /etc/ssh/sshd_config
+
+# Remove 5s grub timeout to speed up booting
+cat <<EOF > /etc/default/grub
+# If you change this file, run 'update-grub' afterwards to update
+# /boot/grub/grub.cfg.
+
+GRUB_DEFAULT=0
+GRUB_TIMEOUT=0
+GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
+GRUB_CMDLINE_LINUX_DEFAULT="quiet"
+GRUB_CMDLINE_LINUX="debian-installer=en_US"
+EOF
+
+update-grub
diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh
new file mode 100644
index 0000000..ef0d3da
--- /dev/null
+++ b/scripts/cleanup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+chmod 440 /etc/sudoers.d/vagrant
+
+# Removing leftover leases and persistent rules
+echo "cleaning up dhcp leases"
+rm /var/lib/dhcp/*
+
+# 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
diff --git a/scripts/dep.sh b/scripts/dep.sh
new file mode 100644
index 0000000..b839353
--- /dev/null
+++ b/scripts/dep.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+#
+# Setup the the box. This runs as root
+
+apt-get -y update
+
+apt-get -y install curl
+
+# You can install anything you need here.
diff --git a/scripts/vagrant.sh b/scripts/vagrant.sh
new file mode 100644
index 0000000..7b2d1a0
--- /dev/null
+++ b/scripts/vagrant.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Vagrant specific
+date > /etc/vagrant_box_build_time
+
+# Installing vagrant keys
+mkdir -pm 700 /home/vagrant/.ssh
+wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys
+chmod 0600 /home/vagrant/.ssh/authorized_keys
+chown -R vagrant /home/vagrant/.ssh
+
+# Customize the message of the day
+echo 'Development Environment' > /etc/motd
diff --git a/scripts/virtualbox.sh b/scripts/virtualbox.sh
new file mode 100644
index 0000000..1404aa7
--- /dev/null
+++ b/scripts/virtualbox.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Bail if we are not running inside VirtualBox.
+if [[ `facter virtual` != "virtualbox" ]]; then
+ exit 0
+fi
+
+mkdir -p /mnt/virtualbox
+mount -o loop /home/vagrant/VBoxGuest*.iso /mnt/virtualbox
+sh /mnt/virtualbox/VBoxLinuxAdditions.run
+ln -s /opt/VBoxGuestAdditions-*/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
+umount /mnt/virtualbox
+rm -rf /home/vagrant/VBoxGuest*.iso
diff --git a/scripts/vmware.sh b/scripts/vmware.sh
new file mode 100644
index 0000000..b77ff2e
--- /dev/null
+++ b/scripts/vmware.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# Bail if we are not running inside VMWare.
+if [[ `facter virtual` != "vmware" ]]; then
+ exit 0
+fi
+
+# Install the VMWare Tools from a linux ISO.
+
+#wget http://192.168.0.185/linux.iso -P /tmp
+mkdir -p /mnt/vmware
+mount -o loop /home/vagrant/linux.iso /mnt/vmware
+
+cd /tmp
+tar xzf /mnt/vmware/VMwareTools-*.tar.gz
+
+umount /mnt/vmware
+rm -fr /home/vagrant/linux.iso
+
+/tmp/vmware-tools-distrib/vmware-install.pl -d
+rm -fr /tmp/vmware-tools-distrib
diff --git a/scripts/zerodisk.sh b/scripts/zerodisk.sh
new file mode 100644
index 0000000..35370d6
--- /dev/null
+++ b/scripts/zerodisk.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# Zero out the free space to save space in the final image:
+dd if=/dev/zero of=/EMPTY bs=1M
+rm -f /EMPTY
+
+# Sync to ensure that the delete completes before this moves on.
+sync
+sync
+sync