From 0b2fb9d03cb26cc22bba918df2c84d7a5099a05c Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Mon, 18 Nov 2024 09:59:51 -0800 Subject: [PATCH 1/5] Update install-conda-packages.sh --- scripts/install-conda-packages.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install-conda-packages.sh b/scripts/install-conda-packages.sh index c35b0f7..f64ec95 100644 --- a/scripts/install-conda-packages.sh +++ b/scripts/install-conda-packages.sh @@ -18,6 +18,8 @@ ENV_NAME="${2:-${CONDA_ENV}}" # Check if running as root and switch to NB_USER if needed if [[ $(id -u) -eq 0 ]]; then echo "Switching to ${NB_USER} to run install-conda-packages.sh" + # Be aware that the next line is resetting PATH to not include conda bins. If this becomes a problem, uncomment the following + # export PATH="$PATH" exec su "${NB_USER}" -c "/bin/bash $0 $ENV_FILE $ENV_NAME" fi From 1d4f9329b1608cde93e25660f35426c40d085a79 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Mon, 18 Nov 2024 10:00:43 -0800 Subject: [PATCH 2/5] Update install-pip-packages.sh --- scripts/install-pip-packages.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install-pip-packages.sh b/scripts/install-pip-packages.sh index 406da46..eff7a23 100644 --- a/scripts/install-pip-packages.sh +++ b/scripts/install-pip-packages.sh @@ -11,6 +11,8 @@ fi # Check if running as root and switch to NB_USER if needed if [[ $(id -u) -eq 0 ]]; then echo "Switching to ${NB_USER} to run install-pip-packages.sh" + # Be aware that the next line is resetting PATH to not include conda bins. If this becomes a problem, uncomment the following + # export PATH="$PATH" exec su "${NB_USER}" -c "/bin/bash $0 $1" # Pass along the filename argument fi From 780ac7b1355b7482b27a923bc967d5afa6c4cfbd Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Mon, 18 Nov 2024 10:02:30 -0800 Subject: [PATCH 3/5] Update setup-start.sh --- scripts/setup-start.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/setup-start.sh b/scripts/setup-start.sh index d8e9a2d..fdbc859 100644 --- a/scripts/setup-start.sh +++ b/scripts/setup-start.sh @@ -11,6 +11,8 @@ fi # Check if running as root and switch to NB_USER if needed if [[ $(id -u) -eq 0 ]]; then echo "Switching to ${NB_USER} to run setup-start.sh" + # Be aware that the next line is resetting PATH to not include conda bins. If this becomes a problem, uncomment the following + # export PATH="$PATH" exec su "${NB_USER}" -c "/bin/bash $0 $1" # Pass the script file as an argument fi From f5eb61b33390e667b817311e4cf23ea449f09c50 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Mon, 18 Nov 2024 10:06:06 -0800 Subject: [PATCH 4/5] Update setup-desktop.sh --- scripts/setup-desktop.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/setup-desktop.sh b/scripts/setup-desktop.sh index ea854c9..0df28bd 100644 --- a/scripts/setup-desktop.sh +++ b/scripts/setup-desktop.sh @@ -1,10 +1,18 @@ #!/bin/bash +# Required user: root # The default for XDG and xfce4 is for Desktop files to be in ~/Desktop but this leads to a variety of problems # First we are altering the user directiory which seems rude, second orphan desktop files might be in ~/Desktop so who knows # what the user Desktop experience with be, here the Desktop dir is set to /usr/share/Desktop so is part of the image. # users that want to customize Desktop can change /etc/xdg/user-dirs.dirs though py-rocket resets that each time the server is restarted. set -e +# Check if the script is run as root +if [[ $(id -u) -ne 0 ]]; then + echo " Error: This setup-desktop.sh must be run as root. Please use 'USER root' in your Dockerfile before running this script." + echo " Remember to switch back to the non-root user with 'USER ${NB_USER}' after running this script." + exit 1 +fi + # Copy in the Desktop files APPLICATIONS_DIR=/usr/share/applications/packages DESKTOP_DIR=/usr/share/Desktop From 815ff5e26eb71cfba61f66587bcdc93e47966d03 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Mon, 18 Nov 2024 10:12:39 -0800 Subject: [PATCH 5/5] Update install-desktop.sh --- scripts/install-desktop.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install-desktop.sh b/scripts/install-desktop.sh index 90f6625..6e3630b 100644 --- a/scripts/install-desktop.sh +++ b/scripts/install-desktop.sh @@ -1,12 +1,12 @@ #!/bin/bash # Required User: root -# Usage: RUN /pyrocket_scripts/setup-desktop.sh " +# Usage: RUN /pyrocket_scripts/install-desktop.sh " echo "Running setup-desktop.sh" # Check if the script is run as root if [[ $(id -u) -ne 0 ]]; then - echo " Error: This script must be run as root. Please use 'USER root' in your Dockerfile before running this script." + echo " Error: This install-desktop.sh must be run as root. Please use 'USER root' in your Dockerfile before running this script." echo " Remember to switch back to the non-root user with 'USER ${NB_USER}' after running this script." exit 1 fi @@ -14,7 +14,7 @@ fi # Check if a directory argument is provided if [ -z "$1" ]; then echo " Error: No directory provided. Please provide a directory path where the script can find .desktop, .png, and .xml files." - echo " Usage: RUN /pyrocket_scripts/setup-desktop.sh " + echo " Usage: RUN /pyrocket_scripts/install-desktop.sh " exit 1 fi @@ -40,7 +40,8 @@ find "${TARGET_DIR}" -type f \( -name "*.desktop" -o -name "*.png" -o -name "*.x if [ "$(ls -A "${REPO_DIR}/Desktop" 2>/dev/null)" ]; then echo " Successfully copied Desktop-related files to '${REPO_DIR}/Desktop'." else - echo " Warning: No .desktop, .png, or .xml files found in '${TARGET_DIR}'. Nothing was copied." + echo " Warning: No .desktop, .png, or .xml files found in '${TARGET_DIR}'. Skipping installation." + exit 0 # Exit without error if no files were found fi # Check if desktop.sh exists before executing @@ -48,9 +49,8 @@ if [ -f "${REPO_DIR}/scripts/setup-desktop.sh" ]; then echo " Running ${REPO_DIR}/scripts/setup-desktop.sh to move Desktop files to appropriate directories and register as applications." chmod +x "${REPO_DIR}/scripts/setup-desktop.sh" "${REPO_DIR}/scripts/setup-desktop.sh" + echo " Success! install-desktop.sh Desktop files installed." else - echo " Warning: ${REPO_DIR}/scripts/setup-desktop.sh not found. Skipping execution." + echo " Error: ${REPO_DIR}/scripts/setup-desktop.sh not found. This script is required for Desktop application installation." + exit 1 fi - -echo " Success! install-desktop.sh" -