From 55e06f6f1b09845c2679929683f5b03b9375f1d6 Mon Sep 17 00:00:00 2001 From: Alexey Rogachevskiy Date: Tue, 25 Feb 2020 22:44:49 +0300 Subject: [PATCH] provision: Put everything in a single shell script --- ros_ide_vm.json | 21 ++------------ scripts/installSoftware.sh | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 scripts/installSoftware.sh diff --git a/ros_ide_vm.json b/ros_ide_vm.json index 80a601d..0046668 100644 --- a/ros_ide_vm.json +++ b/ros_ide_vm.json @@ -29,22 +29,7 @@ }], "provisioners": [{ "type": "shell", - "script": "scripts/installGuestAdditions.sh", - "execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S sh '{{.Path}}'" - }, - { - "type": "shell", - "script": "scripts/installRos.sh", - "execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S sh '{{.Path}}'" - }, - { - "type": "shell", - "script": "scripts/installVsCode.sh", - "execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S sh '{{.Path}}'" - }, - { - "type": "shell", - "script": "scripts/installRosUser.sh" - } -] + "script": "scripts/installSoftware.sh", + "execute_command": "PASSWORD='{{user `password`}}' bash '{{.Path}}'" + }] } \ No newline at end of file diff --git a/scripts/installSoftware.sh b/scripts/installSoftware.sh new file mode 100644 index 0000000..8e7c9a0 --- /dev/null +++ b/scripts/installSoftware.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +echo "--- Current environment:" +/usr/bin/env + +echo "--- Installing open-vm-tools" + +echo "${PASSWORD}" | sudo -E -S sh -c 'apt update; apt install -y open-vm-tools' + +echo "--- Installing ROS desktop packages" + +echo "${PASSWORD}" | sudo -E -S sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' +echo "${PASSWORD}" | sudo -E -S sh -c 'apt-key adv --keyserver "hkp://keyserver.ubuntu.com:80" --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' +echo "${PASSWORD}" | sudo -E -S sh -c 'apt update; apt install -y python-rosinstall-generator python-wstool build-essential ros-melodic-desktop' + +echo "${PASSWORD}" | sudo -E -S sh -c 'rosdep init' +rosdep update + +echo "--- Downloading PX4 and installing its dependencies" +git clone -b v1.10.0-clever https://github.com/CopterExpress/Firmware ${HOME}/Firmware +echo "${PASSWORD}" | sudo -E -S sh -c '${HOME}/Firmware/Tools/setup/ubuntu.sh' +echo "${PASSWORD}" | sudo -E -S sh -c 'echo "2" | update-alternatives --config java' + +echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc + +echo "--- Installing Visual Studio Code" + +echo "${PASSWORD}" | sudo -E -S sh -c 'apt update; apt install -y curl' +curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > ${HOME}/packages.microsoft.gpg +echo "${PASSWORD}" | sudo -E -S sh -c 'install -o root -g root -m 644 ${HOME}/packages.microsoft.gpg /usr/share/keyrings' +rm ${HOME}/packages.microsoft.gpg +echo "${PASSWORD}" | sudo -E -S sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list' +echo "${PASSWORD}" | sudo -E -S sh -c 'apt install -y apt-transport-https; apt update; apt install -y code' +code --install-extension ms-python.python +code --install-extension DavidAnson.vscode-markdownlint +code --install-extension ms-vscode.cmake-tools +code --install-extension ms-vscode.cpptools +code --install-extension streetsidesoftware.code-spell-checker +code --install-extension eamodio.gitlens + +echo "--- Cloning and installing Clever packages" +mkdir -p ${HOME}/catkin_ws/src +git clone -b v0.19 https://github.com/CopterExpress/clever ${HOME}/catkin_ws/src/clever +git clone https://github.com/CopterExpress/ros_led ${HOME}/catkin_ws/src/ros_led +echo "${PASSWORD}" | sudo -E -S sh -c 'rosdep install --from-paths ${HOME}/catkin_ws/src --ignore-src --rosdistro melodic' +curl https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh -o ${HOME}/install_geographiclib_datasets.sh +chmod a+x ${HOME}/install_geographiclib_datasets.sh +echo "${PASSWORD}" | sudo -E -S sh -c '${HOME}/install_geographiclib_datasets.sh' +source /opt/ros/melodic/setup.bash +cd ${HOME}/catkin_ws && catkin_make + +echo "--- Installing QGroundControl" +echo "${PASSWORD}" | sudo -E -S sh -c "usermod -a -G dialout $USER" +echo "${PASSWORD}" | sudo -E -S sh -c 'apt remove -y modemmanager; apt install -y gstreamer1.0-plugins-bad gstreamer1.0-libav' +curl https://s3-us-west-2.amazonaws.com/qgroundcontrol/latest/QGroundControl.AppImage -o ${HOME}/QGroundControl.AppImage +chmod a+x ${HOME}/QGroundControl.AppImage + +echo "--- Cleaning up" +echo "${PASSWORD}" | sudo -E -S sh -c 'apt-get -y autoremove; apt-get -y autoclean; apt-get -y clean; fstrim -v /'