Skip to content

Commit

Permalink
update setup scripts for AWS DCV
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyZoss committed Jun 12, 2024
1 parent a4902f1 commit 036426e
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 47 deletions.
84 changes: 84 additions & 0 deletions gh_pages/_downloads/class-image-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#! /bin/bash

# Script to configure specific settings for ROS-I training VM/AWS images
# - this script also calls ros-industrial-training-setup.sh to set up common training packages/settings

# auto-detect if we're running in AWS. Set IS_AWS before calling this script to override (export IS_AWS=1; script.bash)
IS_AWS=${IS_AWS:-"$(expr "`hostname -d`" == "ec2.internal" )" }
if [ $IS_AWS == 1 ]; then echo "****** AWS Install detected ******"; fi

# disable prompts for kernel-reboot and service-restart during apt installs
sudo sed -i "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf
sudo sed -i "/^#\$nrconf{kernelhints} = -1;/s/^#//" /etc/needrestart/needrestart.conf

# call primary training setup script
CURRDIR=$(dirname "${BASH_SOURCE[0]}")
$CURRDIR/ros-industrial-training-setup.sh

# install ubuntu desktop packages and remove unused packages
sudo apt install -y ubuntu-desktop-minimal gnome-terminal gedit
sudo apt remove -y aisleriot cheese gnome-mahjongg gnome-mines gnome-sudoku libreoffice-* rhythmbox shotwell thunderbird transmission-gtk && sudo apt autoremove

# remove unused home directories
rm -rf ~/Documents ~/Music ~/Pictures ~/Public ~/Templates ~/Videos

# disable screen power-off timer
gsettings set org.gnome.desktop.session idle-delay 0

# define desktop shortcuts (and icons)
xdg-icon-resource install --novendor --context apps --size 256 ~/industrial_training/gh_pages/_downloads/web_shortcuts/ros-i.png
xdg-icon-resource install --novendor --context apps --size 128 ~/industrial_training/gh_pages/_downloads/web_shortcuts/rosorg.png
xdg-icon-resource install --novendor --context apps --size 128 ~/industrial_training/gh_pages/_downloads/web_shortcuts/ros2.png
sudo desktop-file-install ~/industrial_training/gh_pages/_downloads/web_shortcuts/ros-i.desktop
sudo desktop-file-install ~/industrial_training/gh_pages/_downloads/web_shortcuts/rosorg.desktop
sudo desktop-file-install ~/industrial_training/gh_pages/_downloads/web_shortcuts/ros2.desktop

# enable dock and set desired icons
gnome-extensions enable [email protected]
gsettings set org.gnome.shell favorite-apps "['firefox_firefox.desktop', 'ros-i.desktop', 'ros2.desktop', 'rosorg.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.gedit.desktop', 'QtProject-qtcreator-ros-latest.desktop']"

# set min/max/close button order to match MS Windows
gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close"

# replace PS1 prompt var with "ROS Distro" prompt
sed -E -i 's/^(\s*)(PS1=.*\\033.*)$/\1#\2\n\1PS1=\'\''\\[\\e[01;32m\\]ROS$ROS_VERSION(\\[\\e[00;02;37m\\]${ROS_DISTRO:-\\[\\e[00;31m\\]NONE}\\[\\e[00;01;32m\\])\\[\\e[00m\\]:\\[\\e[01;34m\\]\\w\\[\\e[00m\\]\$ '\''/' ~/.bashrc

# disable terminal auto-sourcing
sed -E -i 's/^([^#].*source \/opt\/ros\/.*\/setup\..*)$/#\1/' ~/.bashrc

# configure NICE-DCV settings for AWS remote desktop
# - ref: https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing-linux-prereq.html
# - ref: https://docs.aws.amazon.com/dcv/latest/adminguide/manage-start.html
# - ref: https://docs.aws.amazon.com/dcv/latest/adminguide/managing-sessions-start.html
# - ref: https://docs.aws.amazon.com/dcv/latest/adminguide/security-authentication.html
if [ $IS_AWS == 1 ]; then
sudo sed -i "/^#WaylandEnable=false/s/^#//" /etc/gdm3/custom.conf
sudo systemctl restart gdm3
sudo apt install xserver-xorg-video-dummy
sudo cp $CURRDIR/dummy.xorg.conf /etc/X11/xorg.conf.d
sudo systemctl isolate multi-user.target
sudo systemctl isolate graphical.target
wget https://d1uj6qtbmh3dt5.cloudfront.net/NICE-GPG-KEY
gpg --import NICE-GPG-KEY
rm NICE-GPG-KEY
wget https://d1uj6qtbmh3dt5.cloudfront.net/nice-dcv-ubuntu2204-x86_64.tgz
tar -xvzf nice-dcv-ubuntu2204-x86_64.tgz && cd nice-dcv-*/
sudo apt install -y ./nice-dcv-server*.deb ./nice-dcv-web-viewer*.deb
cd .. && rm -rf nice-dcv-*
sudo systemctl enable dcvserver
sudo sed -i "/^#create-session = true/s/^#//" /etc/dcv/dcv.conf
sudo sed -i '/^#owner = ""/c\owner = "ubuntu"' /etc/dcv/dcv.conf
sudo sed -i '/^#authentication="none"/c\authentication="system"' /etc/dcv/dcv.conf
sudo systemctl stop dcvserver
sudo systemctl start dcvserver
fi

# Install Qt Creator with ROS plugin
# NOTE: no way (yet?) to do headless QT IFW install. Do this last, but will require user action
if [[ $DISPLAY && ! -d ~/QtCreator ]]; then
QTFILE=qtcreator-ros-bionic-latest-offline-installer.run
wget -q --no-check-certificate https://qtcreator-ros.datasys.swri.edu/downloads/installers/bionic/$QTFILE
chmod u+x $QTFILE
./$QTFILE
rm $QTFILE
fi
25 changes: 25 additions & 0 deletions gh_pages/_downloads/dummy.xorg.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Section "Device"
Identifier "DummyDevice"
Driver "dummy"
Option "UseEDID" "false"
VideoRam 512000
EndSection

Section "Monitor"
Identifier "DummyMonitor"
HorizSync 5.0 - 1000.0
VertRefresh 5.0 - 200.0
Option "ReducedBlanking"
EndSection

Section "Screen"
Identifier "DummyScreen"
Device "DummyDevice"
Monitor "DummyMonitor"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Virtual 1920 1080
EndSubSection
EndSection
48 changes: 1 addition & 47 deletions gh_pages/_downloads/ros-industrial-training-setup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#! /bin/bash

# auto-detect if we're running in AWS. Set IS_AWS before calling this script to override (export IS_AWS=1; script.bash)
IS_AWS=${IS_AWS:-"$(expr "`hostname -d`" == "ec2.internal" )" }

# we want services to restart automatically without interacting during all the installations
if [ $IS_AWS -eq 1 ]; then
sudo sed -i "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf
fi

sudo apt update -y
sudo apt upgrade -y
sudo apt install -y curl gcc make gnupg2 lsb-release git meld build-essential libfontconfig1 mesa-common-dev libglu1-mesa-dev
Expand All @@ -23,7 +15,7 @@ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-a

sudo apt update -y

# ROS2 install
# ROS2 install (humble)
sudo apt install -y ros-humble-desktop \
ros-humble-ros2-control ros-humble-ros2-controllers ros-humble-xacro ros-humble-joint-state-publisher-gui \
python3-colcon-common-extensions python3-argcomplete \
Expand All @@ -33,41 +25,3 @@ sudo apt install -y ros-humble-desktop \
# rosdep setup
sudo rosdep init
rosdep update

# Install Qt Creator with ROS plugin
# NOTE: no way (yet?) to do headless QT IFW install. Do this last, but will require user action
if [[ $DISPLAY && ! -d ~/QtCreator ]]; then
QTFILE=qtcreator-ros-bionic-latest-offline-installer.run
wget -q --no-check-certificate https://qtcreator-ros.datasys.swri.edu/downloads/installers/bionic/$QTFILE
chmod u+x $QTFILE
./$QTFILE
rm $QTFILE
fi

if [ $IS_AWS -eq 1 ]; then
# disable screen power-off timer
gsettings set org.gnome.desktop.session idle-delay 0

# setup firefox shortcuts
xdg-icon-resource install --novendor --context apps --size 256 ~/industrial_training/gh_pages/_downloads/web_shortcuts/ros-i.png
xdg-icon-resource install --novendor --context apps --size 128 ~/industrial_training/gh_pages/_downloads/web_shortcuts/rosorg.png
xdg-icon-resource install --novendor --context apps --size 128 ~/industrial_training/gh_pages/_downloads/web_shortcuts/ros2.png

sudo desktop-file-install ~/industrial_training/gh_pages/_downloads/web_shortcuts/ros-i.desktop
sudo desktop-file-install ~/industrial_training/gh_pages/_downloads/web_shortcuts/rosorg.desktop
sudo desktop-file-install ~/industrial_training/gh_pages/_downloads/web_shortcuts/ros2.desktop

sudo apt install -y gnome-terminal gedit
gnome-extensions enable [email protected]
gsettings set org.gnome.shell favorite-apps "['firefox.desktop', 'ros-i.desktop', 'ros2.desktop', 'rosorg.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.gedit.desktop', 'QtProject-qtcreator-ros-latest.desktop']"
gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close"

# replace PS1 prompt var with "ROS Distro" prompt
sed -E -i 's/^(\s*)(PS1=.*cloud9_prompt_user.*)$/\1#\2\n\1PS1=\'\''\\[\\e[01;32m\\]ROS$ROS_VERSION(\\[\\e[00;02;37m\\]${ROS_DISTRO:-\\[\\e[00;31m\\]NONE}\\[\\e[00;01;32m\\])\\[\\e[00m\\]:\\[\\e[01;34m\\]\\w\\[\\e[00m\\]\$ '\''/' ~/.bashrc

# disable terminal auto-sourcing
sed -E -i 's/^([^#].*source \/opt\/ros\/.*\/setup\..*)$/#\1/' ~/.bashrc

# enable bash auto-completion
echo "[[ -e /etc/profile.d/bash_completion.sh ]] && source /etc/profile.d/bash_completion.sh" >> ~/.bashrc
fi

0 comments on commit 036426e

Please sign in to comment.