#!/bin/bash

set -e

if [ ! -d ~/.wifichallengelab-docker ]; then
    mkdir -p ~/.wifichallengelab-docker
    cp -rd /usr/share/wifichallengelab-docker/* ~/.wifichallengelab-docker
    # for the moment vagrant is co-installable with the Debian version of
    # virtualbox.
    # The following code and the patch can be removed when
    # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1113791 is fixed
    # And we need to add virtualbox-guest-additions-iso in Depends
    cd ~/.wifichallengelab-docker
    apt-get download virtualbox-guest-additions-iso
    dpkg-deb --extract virtualbox-guest-additions-iso*.deb ~/.wifichallengelab-docker/vagrant
    cd .. 
    rm -rf ~/.wifichallengelab-docker/virtualbox*

fi

systemctl start libvirtd

echo ""
echo "In ~/.wifichallengelab-docker/vagrant, run 'vagrant up virtualbox_vm'"
echo "If this is the first time, it may be long"
echo ""
echo "then run 'vagrant ssh virtualbox_vm'"
