#!/bin/bash -ex
#

install()
{
    apt-get update
    DEBIAN_FRONTEND=noninteractive apt-get -y \
        -o DPkg::Options::=--force-confdef \
        -o DPkg::Options::=--force-confold \
        install $@
}

cleanup_apt()
    {
        rm -r /var/cache/apt/*
        mkdir /var/cache/apt/archives
        mkdir /var/cache/apt/archives/partial
    }

# Remove resolvconf to stop conflicts with upstart
# Install acpid to allow poweroff buttons on VMs/bare metal to work.
install resolvconf- acpid

# Get rid of the hostname so dhcp scripts set things up.
rm -f /etc/hostname

# Get rid of any dangling symlinks from resolver config
rm -f /etc/resolv.conf
rm -rf /etc/resolvconf

# Default Google nameservers - just in case
echo "nameserver 8.8.4.4" > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf

cleanup_apt
