2015-01-20 15:51:19 -04:00
|
|
|
#!/bin/bash
|
2018-03-01 20:22:53 -04:00
|
|
|
echo "---------- $0 start ----------"
|
2015-01-20 15:51:19 -04:00
|
|
|
|
2016-08-11 21:41:43 -03:00
|
|
|
# this script is run by the root user in the virtual machine
|
|
|
|
|
2015-03-22 17:37:15 -03:00
|
|
|
set -e
|
2016-08-11 21:41:43 -03:00
|
|
|
set -x
|
2015-01-20 15:51:19 -04:00
|
|
|
|
2018-03-01 20:22:53 -04:00
|
|
|
who=$(whoami)
|
2015-01-20 15:51:19 -04:00
|
|
|
echo "Initial setup of SITL-vagrant instance."
|
2018-03-01 20:22:53 -04:00
|
|
|
if [ $who != 'root' ]; then
|
|
|
|
echo "SORRY, MUST RUN THIS SCRIPT AS ROOT, GIVING UP"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-03-22 17:37:15 -03:00
|
|
|
|
2016-10-19 21:11:41 -03:00
|
|
|
VAGRANT_USER=ubuntu
|
2018-02-05 22:23:00 -04:00
|
|
|
if [ -e /home/vagrant ]; then
|
|
|
|
# prefer vagrant user
|
|
|
|
VAGRANT_USER=vagrant
|
|
|
|
fi
|
2018-03-01 20:22:53 -04:00
|
|
|
echo USING VAGRANT_USER:$VAGRANT_USER
|
|
|
|
|
|
|
|
cd /home/$VAGRANT_USER
|
|
|
|
|
2018-02-05 22:23:00 -04:00
|
|
|
|
|
|
|
# artful rootfs is 2GB without resize:
|
|
|
|
sudo resize2fs /dev/sda1
|
2016-10-19 21:11:41 -03:00
|
|
|
|
2018-03-01 20:22:53 -04:00
|
|
|
echo "calling pre-reqs script..."
|
2019-04-03 08:19:18 -03:00
|
|
|
sudo -H -u $VAGRANT_USER /vagrant/Tools/environment_install/install-prereqs-ubuntu.sh -y
|
2018-03-01 20:22:53 -04:00
|
|
|
echo "...pre-reqs script done... initvagrant.sh continues."
|
2018-02-05 22:23:00 -04:00
|
|
|
|
|
|
|
# valgrind support:
|
|
|
|
apt-get install -y valgrind
|
|
|
|
|
|
|
|
# gdb support:
|
|
|
|
apt-get install -y gdb
|
2015-01-20 15:51:19 -04:00
|
|
|
|
2016-10-19 21:11:41 -03:00
|
|
|
sudo -u $VAGRANT_USER ln -fs /vagrant/Tools/vagrant/screenrc /home/$VAGRANT_USER/.screenrc
|
2015-01-20 15:51:19 -04:00
|
|
|
|
2021-02-09 22:51:00 -04:00
|
|
|
# enable permissive ptrace:
|
|
|
|
perl -pe 's/kernel.yama.ptrace_scope = ./kernel.yama.ptrace_scope = 0/' -i /etc/sysctl.d/10-ptrace.conf
|
|
|
|
echo 0 > /proc/sys/kernel/yama/ptrace_scope
|
|
|
|
|
2023-10-13 23:16:45 -03:00
|
|
|
RELEASE_CODENAME=$(lsb_release -c -s)
|
|
|
|
|
2023-05-08 19:59:20 -03:00
|
|
|
if [ ${RELEASE_CODENAME} != 'bionic' ]; then
|
|
|
|
# build JSB sim
|
|
|
|
apt-get install -y libtool automake autoconf libexpat1-dev cmake
|
|
|
|
# libtool-bin
|
|
|
|
sudo --login -u $VAGRANT_USER /vagrant/Tools/scripts/build-jsbsim.sh
|
|
|
|
fi
|
2017-08-30 03:18:01 -03:00
|
|
|
|
2018-02-05 22:23:00 -04:00
|
|
|
# adjust environment for every login shell:
|
|
|
|
DOT_PROFILE=/home/$VAGRANT_USER/.profile
|
|
|
|
echo "source /vagrant/Tools/vagrant/shellinit.sh" |
|
|
|
|
sudo -u $VAGRANT_USER dd conv=notrunc oflag=append of=$DOT_PROFILE
|
2015-01-20 15:51:19 -04:00
|
|
|
|
2021-02-07 18:50:18 -04:00
|
|
|
BASHRC="/home/$VAGRANT_USER/.bashrc"
|
|
|
|
# adjust environment for every login shell:
|
|
|
|
BASHRC_GIT="/vagrant/Tools/vagrant/bashrc_git"
|
|
|
|
echo "source $BASHRC_GIT" |
|
|
|
|
sudo -u $VAGRANT_USER dd conv=notrunc oflag=append of=$BASHRC
|
|
|
|
|
2018-03-31 06:07:48 -03:00
|
|
|
# link a half-way decent .mavinit.scr into place:
|
2019-06-07 11:52:44 -03:00
|
|
|
sudo --login -u $VAGRANT_USER ln -sf /vagrant/Tools/vagrant/mavinit.scr /home/$VAGRANT_USER/.mavinit.scr
|
2018-03-31 06:07:48 -03:00
|
|
|
|
2022-05-01 00:18:44 -03:00
|
|
|
# no multipath available, stop mutlipathd complaining about lack of data:
|
|
|
|
if [ ${RELEASE_CODENAME} == 'jammy' ]; then
|
|
|
|
cat >>/etc/multipath.conf <<EOF
|
|
|
|
blacklist { devnode "sda" }
|
|
|
|
blacklist { devnode "sdb" }
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2016-12-24 14:28:13 -04:00
|
|
|
#Plant a marker for sim_vehicle that we're inside a vagrant box
|
|
|
|
touch /ardupilot.vagrant
|
|
|
|
|
2015-01-22 18:25:16 -04:00
|
|
|
# Now you can run
|
2015-03-18 15:42:29 -03:00
|
|
|
# vagrant ssh -c "screen -d -R"
|
2018-03-01 20:22:53 -04:00
|
|
|
echo "---------- $0 end ----------"
|
|
|
|
|