#!/usr/bin/env bash
set -e
set -x
set -u
echo "Initial setup of SITL-vagrant instance."
/vagrant/Tools/environment_install/install-prereqs-ubuntu.sh -y
sudo apt-get install -y valgrind gdb
VAGRANT_USER=vagrant
PROFILE_TEXT="
source /vagrant/Tools/vagrant/shellinit.sh
# This allows the PX4NuttX build to proceed when the underlying fs is on windows
# It is only marginally less efficient on Linux
export PX4_WINTOOL=y
export PATH=\$PATH:\$HOME/jsbsim/build/src
export BUILDLOGS=/tmp/buildlogs
"
DOT_PROFILE=/home/$VAGRANT_USER/.profile
echo "$PROFILE_TEXT" | sudo -u $VAGRANT_USER dd conv=notrunc oflag=append of=$DOT_PROFILE
BASHRC_GIT="/vagrant/Tools/vagrant/bashrc_git"
echo "source $BASHRC_GIT" |
sudo -u $VAGRANT_USER dd conv=notrunc oflag=append of=$DOT_PROFILE
sudo -u $VAGRANT_USER ln -fs /vagrant/Tools/vagrant/screenrc /home/$VAGRANT_USER/.screenrc
sudo -u $VAGRANT_USER /vagrant/Tools/scripts/install-jsbsim.sh /home/$VAGRANT_USER
touch /ardupilot.vagrant