#!/bin/sh -ex

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

# install cloud required packages
install ec2metadata

# copy mntbind inithook in everyboot
INITHOOKS=/usr/lib/inithooks
cp $INITHOOKS/firstboot.d/27ec2-mntbind-ephemeral $INITHOOKS/everyboot.d/

# disable confconsole init script
update-rc.d -f confconsole disable

# redirect inithook output (preseeded headless deployment)
sed -i '/REDIRECT_OUTPUT/ s/=.*/=true/g' /etc/default/inithooks

