#!/bin/bash echo "---------- $0 start ----------" # this script is run by the root user in the virtual machine set -e set -x who=$(whoami) echo "Initial setup of SITL-vagrant instance." if [ $who != 'root' ]; then echo "SORRY, MUST RUN THIS SCRIPT AS ROOT, GIVING UP" exit 1 fi VAGRANT_USER=ubuntu if [ -e /home/vagrant ]; then # prefer vagrant user VAGRANT_USER=vagrant fi echo USING VAGRANT_USER:$VAGRANT_USER cd /home/$VAGRANT_USER # artful rootfs is 2GB without resize: resize2fs /dev/sda1 apt-get update apt-get install -y python3-pip pip3 install flask apt-get install -y apache2 apt-get install -y libapache2-mod-wsgi-py3 python-dev CUSTOM_CONF="/etc/apache2/sites-available//CustomBuild.conf" #cp /vagrant/CustomBuild.conf "$CUSTOM_CONF" #perl -pe 's%/home/custom/CustomBuild%/vagrant%' -i "$CUSTOM_CONF" sudo -H -u $VAGRANT_USER mkdir -p /home/vagrant/base/builds # TODO: work out how to do custom certs here cat >"$CUSTOM_CONF" < # ServerName custom.ardupilot.org WSGIDaemonProcess app threads=5 WSGIScriptAlias / /vagrant/app.wsgi WSGIScriptAlias /generate /vagrant/app.wsgi Options FollowSymLinks AllowOverride None Require all granted Alias /builds /base/builds Options FollowSymLinks Indexes AllowOverride None Require all granted ErrorLog \${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog \${APACHE_LOG_DIR}/access.log combined EOF # add the arm tools into the path for Apache: cat >>/etc/apache2/envvars <>/etc/apache2/ports.conf < /proc/sys/kernel/yama/ptrace_scope # the 8888 here comes from Vagrantfile, it's a forwarded port echo "Check web address: http://127.0.0.1:8888/" # Now you can run # vagrant ssh -c "screen -d -R" echo "---------- $0 end ----------"