#!/usr/bin/env bash

set -e
shutdown -h +60 "Timeout on VM creation"


if [ -e "/vagrant/build.sh" ]; then

    cp -f /vagrant/build.sh ~/build.sh
    echo """
wait""" >> ~/build.sh
    bash ~/build.sh
fi

if [ -e "/vagrant/build_as_vagrant.sh" ]; then
    cp -f /vagrant/build_as_vagrant.sh ~/build_as_vagrant.sh
    echo """
wait""" >> ~/build_as_vagrant.sh
    sudo -H -u vagrant -- bash ~/build_as_vagrant.sh
fi
