-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from nmfs-opensci/eeholmes-patch-1
Update install-r-package.sh
- Loading branch information
Showing
9 changed files
with
202 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
#!/bin/bash | ||
/scripts/copy-files.sh | ||
|
||
echo "Checking for apt.txt..." | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
if test -f "apt.txt"; then | ||
package_list=$(grep -v '^\s*#' apt.txt | grep -v '^\s*$' | sed 's/\r//g; s/#.*//; s/^[[:space:]]*//; s/[[:space:]]*$//' | awk '{$1=$1};1') | ||
apt-get update --fix-missing > /dev/null | ||
apt-get install --yes --no-install-recommends $package_list | ||
apt-get autoremove --purge | ||
apt-get clean | ||
rm -rf /var/lib/apt/lists/* | ||
# Required User: root | ||
|
||
echo "Running install-apt-packages.sh" | ||
echo " Checking for ${REPO_DIR}/childimage/..." | ||
if [ -d "${REPO_DIR}/childimage/" ]; then | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
|
||
echo " Checking for apt.txt in ${REPO_DIR}/childimage/..." | ||
if test -f "apt.txt"; then | ||
# Check if the script is run as root | ||
if [[ $(id -u) -ne 0 ]]; then | ||
echo " Error: This script must be run as root." >&2 # Output error message to standard error | ||
exit 1 # Exit with a non-zero status to indicate failure | ||
fi | ||
|
||
echo " Running install-apt-packages.sh as root. Proceeding with installation..." | ||
|
||
package_list=$(grep -v '^\s*#' apt.txt | grep -v '^\s*$' | sed 's/\r//g; s/#.*//; s/^[[:space:]]*//; s/[[:space:]]*$//' | awk '{$1=$1};1') | ||
apt-get update --fix-missing > /dev/null | ||
apt-get install --yes --no-install-recommends $package_list | ||
apt-get autoremove --purge | ||
apt-get clean | ||
rm -rf /var/lib/apt/lists/* | ||
else | ||
echo " No apt.txt found. Skipping package installation." | ||
fi | ||
else | ||
echo " Directory ${REPO_DIR}/childimage/ does not exist. Skipping script." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
#!/bin/bash | ||
/scripts/copy-files.sh | ||
# Required User: NB_USER | ||
|
||
echo "Checking for conda-lock.yml or environment.yml..." | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
if test -f "conda-lock.yml"; then | ||
echo "Using conda-lock.yml" | ||
conda-lock install --name ${CONDA_ENV} | ||
pip install --no-deps jupyter-remote-desktop-proxy | ||
elif test -f "environment.yml"; then | ||
echo "Using environment.yml" | ||
mamba env update --name ${CONDA_ENV} -f environment.yml | ||
pip install --no-deps jupyter-remote-desktop-proxy | ||
fi | ||
mamba clean -yaf | ||
find ${CONDA_DIR} -follow -type f -name '*.a' -delete | ||
find ${CONDA_DIR} -follow -type f -name '*.js.map' -delete | ||
if ls ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static > /dev/null 2>&1; then | ||
find ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static -follow -type f -name '*.js' ! -name '*.min.js' -delete | ||
echo "Running install-conda-packages.sh" | ||
|
||
echo " Checking for ${REPO_DIR}/childimage/..." | ||
if [ -d "${REPO_DIR}/childimage/" ]; then | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
|
||
echo " Checking for conda-lock.yml or environment.yml in ${REPO_DIR}/childimage/..." | ||
if test -f "conda-lock.yml" || test -f "environment.yml"; then | ||
# Switch to NB_USER only if the relevant files exist | ||
if [[ $(id -u) -eq 0 ]]; then | ||
echo " Switching to ${NB_USER} to run install-conda-packages.sh" | ||
exec su "${NB_USER}" -c "/bin/bash $0" # Switches to NB_USER and reruns the script | ||
fi | ||
|
||
if test -f "conda-lock.yml"; then | ||
echo " Using conda-lock.yml" | ||
conda-lock install --name ${CONDA_ENV} | ||
pip install --no-deps jupyter-remote-desktop-proxy | ||
INSTALLATION_HAPPENED=true | ||
elif test -f "environment.yml"; then | ||
echo " Using environment.yml" | ||
mamba env update --name ${CONDA_ENV} -f environment.yml | ||
pip install --no-deps jupyter-remote-desktop-proxy | ||
INSTALLATION_HAPPENED=true | ||
fi | ||
|
||
# Only run cleanup if installation occurred | ||
if [ "$INSTALLATION_HAPPENED" = true ]; then | ||
mamba clean -yaf | ||
find ${CONDA_DIR} -follow -type f -name '*.a' -delete | ||
find ${CONDA_DIR} -follow -type f -name '*.js.map' -delete | ||
if ls ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static > /dev/null 2>&1; then | ||
find ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static -follow -type f -name '*.js' ! -name '*.min.js' -delete | ||
fi | ||
fi | ||
else | ||
echo " No conda-lock.yml or environment.yml found. Skipping installation." | ||
fi | ||
else | ||
echo " Directory ${REPO_DIR}/childimage/ does not exist. Skipping script." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
#!/bin/bash | ||
/scripts/copy-files.sh | ||
# Required User: NB_USER | ||
|
||
echo "Checking for pip requirements.txt..." | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
if test -f "requirements.txt"; then | ||
${NB_PYTHON_PREFIX}/bin/pip install --no-cache -r requirements.txt | ||
echo "Running install-pip-packages.sh" | ||
|
||
echo " Checking for ${REPO_DIR}/childimage/..." | ||
if [ -d "${REPO_DIR}/childimage/" ]; then | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
|
||
echo " Checking for requirements.txt in ${REPO_DIR}/childimage/..." | ||
if test -f "requirements.txt"; then | ||
# Switch to NB_USER only if requirements.txt exists | ||
if [[ $(id -u) -eq 0 ]]; then | ||
echo "Switching to ${NB_USER} to run install-pip-packages.sh" | ||
exec su "${NB_USER}" -c "/bin/bash $0" # Switches to NB_USER and reruns the script | ||
fi | ||
|
||
echo " Installing pip packages from requirements.txt as ${NB_USER}..." | ||
${NB_PYTHON_PREFIX}/bin/pip install --no-cache -r requirements.txt | ||
else | ||
echo " No requirements.txt found. Skipping pip installation." | ||
fi | ||
else | ||
echo " Directory ${REPO_DIR}/childimage/ does not exist. Skipping script." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
#!/bin/bash | ||
/scripts/copy-files.sh | ||
# Required User: NB_USER | ||
|
||
echo "Checking for install.R..." | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
if test -f "install.R"; then | ||
echo "Using install.R" | ||
Rscript install.R | ||
echo "Running install-r-packages.sh" | ||
|
||
echo " Checking for ${REPO_DIR}/childimage/..." | ||
if [ -d "${REPO_DIR}/childimage/" ]; then | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
|
||
echo " Checking for install.R in ${REPO_DIR}/childimage/..." | ||
if test -f "install.R"; then | ||
# Switch to NB_USER only if install.R exists | ||
if [[ $(id -u) -eq 0 ]]; then | ||
echo "Switching to ${NB_USER} to run install-r-packages.sh" | ||
exec su "${NB_USER}" -c "/bin/bash $0" # Switches to NB_USER and reruns the script | ||
fi | ||
|
||
echo " Using install.R to install R packages as ${NB_USER}..." | ||
Rscript install.R | ||
else | ||
echo " No install.R found. Skipping R package installation." | ||
fi | ||
else | ||
echo " Directory ${REPO_DIR}/childimage/ does not exist. Skipping script." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
#!/bin/bash | ||
/scripts/copy-files.sh | ||
|
||
echo "Checking for postBuild..." | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
if test -f "postBuild"; then | ||
chmod +x postBuild | ||
./postBuild | ||
rm -rf /tmp/* | ||
rm -rf ${HOME}/.cache ${HOME}/.npm ${HOME}/.yarn | ||
rm -rf ${NB_PYTHON_PREFIX}/share/jupyter/lab/staging | ||
find ${CONDA_DIR} -follow -type f -name '*.a' -delete | ||
find ${CONDA_DIR} -follow -type f -name '*.js.map' -delete | ||
|
||
echo "Running run-postbuild.sh" | ||
|
||
echo " Checking for ${REPO_DIR}/childimage/..." | ||
if [ -d "${REPO_DIR}/childimage/" ]; then | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
|
||
echo " Checking for postBuild..." | ||
if test -f "postBuild"; then | ||
# Check the user and output which user the script is running as | ||
if [[ $(id -u) -eq 0 ]]; then | ||
echo " Running run-postbuild.sh as root." | ||
else | ||
echo " Running run-postbuild.sh as ${NB_USER}." | ||
fi | ||
|
||
chmod +x postBuild | ||
./postBuild | ||
rm -rf /tmp/* | ||
rm -rf ${HOME}/.cache ${HOME}/.npm ${HOME}/.yarn | ||
rm -rf ${NB_PYTHON_PREFIX}/share/jupyter/lab/staging | ||
find ${CONDA_DIR} -follow -type f -name '*.a' -delete | ||
find ${CONDA_DIR} -follow -type f -name '*.js.map' -delete | ||
else | ||
echo " No postBuild file found. Skipping execution." | ||
fi | ||
else | ||
echo " Directory ${REPO_DIR}/childimage/ does not exist. Skipping script." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
#!/bin/bash | ||
# Ensure files are copied before proceeding | ||
/scripts/copy-files.sh | ||
|
||
echo "Checking for Desktop directory..." | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
if test -d Desktop; then | ||
mkdir -p "${REPO_DIR}/Desktop" | ||
cp -r Desktop/* "${REPO_DIR}/Desktop/" 2>/dev/null | ||
chmod +x "${REPO_DIR}/desktop.sh" | ||
"${REPO_DIR}/desktop.sh" | ||
# Required User: root | ||
|
||
echo "Running setup-desktop.sh" | ||
|
||
echo " Checking for ${REPO_DIR}/childimage/..." | ||
if [ -d "${REPO_DIR}/childimage/" ]; then | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
|
||
echo " Checking for Desktop directory..." | ||
if test -d "${REPO_DIR}/childimage/Desktop"; then | ||
# Check if the script is run as root | ||
if [[ $(id -u) -ne 0 ]]; then | ||
echo " Error: This script must be run as root." >&2 # Output error message to standard error | ||
exit 1 # Exit with a non-zero status to indicate failure | ||
fi | ||
|
||
echo " Running setup-desktop.sh as root. Proceeding with installation..." | ||
|
||
mkdir -p "${REPO_DIR}/Desktop" | ||
cp -r ${REPO_DIR}/childimage/Desktop/* "${REPO_DIR}/Desktop/" 2>/dev/null | ||
|
||
# Check if desktop.sh exists before executing | ||
if test -f "${REPO_DIR}/desktop.sh"; then | ||
echo " Running ${REPO_DIR}/desktop.sh." | ||
chmod +x "${REPO_DIR}/desktop.sh" | ||
"${REPO_DIR}/desktop.sh" | ||
else | ||
echo " Warning: desktop.sh not found. Skipping execution." | ||
fi | ||
else | ||
echo " No Desktop directory found in ${REPO_DIR}/childimage/. Skipping setup." | ||
fi | ||
else | ||
echo " Directory ${REPO_DIR}/childimage/ does not exist. Skipping script." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
#!/bin/bash | ||
/scripts/copy-files.sh | ||
# Required User: NB_USER | ||
|
||
echo "Checking for start..." | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
if test -f "start"; then | ||
chmod +x start | ||
echo "Running setup-start.sh" | ||
|
||
echo " Checking for ${REPO_DIR}/childimage/..." | ||
if [ -d "${REPO_DIR}/childimage/" ]; then | ||
cd "${REPO_DIR}/childimage/" || exit 1 | ||
|
||
echo " Checking for start in ${REPO_DIR}/childimage/..." | ||
if test -f "start"; then | ||
echo " start found in ${REPO_DIR}/childimage/." | ||
# Switch to NB_USER only if the start file exists | ||
if [[ $(id -u) -eq 0 ]]; then | ||
echo " Switching to ${NB_USER} to run setup-start.sh" | ||
exec su "${NB_USER}" -c "/bin/bash $0" # Switches to NB_USER and reruns the script | ||
fi | ||
chmod +x start | ||
else | ||
echo " No start file found in ${REPO_DIR}/childimage/. Skipping." | ||
fi | ||
else | ||
echo " Directory ${REPO_DIR}/childimage/ does not exist. Skipping." | ||
fi |