CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/vagrant/initvagrant.sh
Views: 1798
1
#!/usr/bin/env bash
2
echo "---------- $0 start ----------"
3
4
# this script is run by the root user in the virtual machine
5
6
set -e
7
set -x
8
9
who=$(whoami)
10
echo "Initial setup of SITL-vagrant instance."
11
if [ $who != 'root' ]; then
12
echo "SORRY, MUST RUN THIS SCRIPT AS ROOT, GIVING UP"
13
exit 1
14
fi
15
16
VAGRANT_USER=ubuntu
17
if [ -e /home/vagrant ]; then
18
# prefer vagrant user
19
VAGRANT_USER=vagrant
20
fi
21
echo USING VAGRANT_USER:$VAGRANT_USER
22
23
cd /home/$VAGRANT_USER
24
25
IS_BENTO=0
26
if [ -e /etc/update-motd.d/99-bento ]; then
27
IS_BENTO=1
28
fi
29
30
# artful rootfs is 2GB without resize. Do not resize if using Bento:
31
if [ ! $IS_BENTO ]; then
32
sudo resize2fs /dev/sda1
33
fi
34
35
echo "calling pre-reqs script..."
36
sudo -H -u $VAGRANT_USER /vagrant/Tools/environment_install/install-prereqs-ubuntu.sh -y
37
echo "...pre-reqs script done... initvagrant.sh continues."
38
39
# valgrind support:
40
apt-get install -y valgrind
41
42
# gdb support:
43
apt-get install -y gdb
44
45
sudo -u $VAGRANT_USER ln -fs /vagrant/Tools/vagrant/screenrc /home/$VAGRANT_USER/.screenrc
46
47
# enable permissive ptrace:
48
perl -pe 's/kernel.yama.ptrace_scope = ./kernel.yama.ptrace_scope = 0/' -i /etc/sysctl.d/10-ptrace.conf
49
echo 0 > /proc/sys/kernel/yama/ptrace_scope
50
51
RELEASE_CODENAME=$(lsb_release -c -s)
52
53
if [ ${RELEASE_CODENAME} != 'bionic' ]; then
54
# build JSB sim
55
apt-get install -y libtool automake autoconf libexpat1-dev cmake
56
# libtool-bin
57
sudo --login -u $VAGRANT_USER /vagrant/Tools/scripts/build-jsbsim.sh
58
fi
59
60
# adjust environment for every login shell:
61
DOT_PROFILE=/home/$VAGRANT_USER/.profile
62
echo "source /vagrant/Tools/vagrant/shellinit.sh" |
63
sudo -u $VAGRANT_USER dd conv=notrunc oflag=append of=$DOT_PROFILE
64
65
BASHRC="/home/$VAGRANT_USER/.bashrc"
66
# adjust environment for every login shell:
67
BASHRC_GIT="/vagrant/Tools/vagrant/bashrc_git"
68
echo "source $BASHRC_GIT" |
69
sudo -u $VAGRANT_USER dd conv=notrunc oflag=append of=$BASHRC
70
71
# link a half-way decent .mavinit.scr into place:
72
sudo --login -u $VAGRANT_USER ln -sf /vagrant/Tools/vagrant/mavinit.scr /home/$VAGRANT_USER/.mavinit.scr
73
74
# no multipath available, stop mutlipathd complaining about lack of data:
75
if [ ${RELEASE_CODENAME} == 'jammy' ]; then
76
cat >>/etc/multipath.conf <<EOF
77
blacklist { devnode "sda" }
78
blacklist { devnode "sdb" }
79
EOF
80
fi
81
82
83
#Plant a marker for sim_vehicle that we're inside a vagrant box
84
touch /ardupilot.vagrant
85
86
# Now you can run
87
# vagrant ssh -c "screen -d -R"
88
echo "---------- $0 end ----------"
89
90
91