From c6aa45908845770d1b5de2c3457cf12dd8a9d3eb Mon Sep 17 00:00:00 2001 From: eitsupi <50911393+eitsupi@users.noreply.github.com> Date: Sat, 2 Sep 2023 17:10:57 +0900 Subject: [PATCH] [rstudio-server] add a option to prevent reinstallation (#182) --- src/rstudio-server/devcontainer-feature.json | 5 ++++ src/rstudio-server/install.sh | 29 ++++++++++++-------- test/rstudio-server/daily.sh | 2 +- test/rstudio-server/scenarios.json | 13 +++++++-- test/rstudio-server/skip-install.sh | 12 ++++++++ 5 files changed, 46 insertions(+), 15 deletions(-) create mode 100755 test/rstudio-server/skip-install.sh diff --git a/src/rstudio-server/devcontainer-feature.json b/src/rstudio-server/devcontainer-feature.json index cb177ce..a900013 100644 --- a/src/rstudio-server/devcontainer-feature.json +++ b/src/rstudio-server/devcontainer-feature.json @@ -14,6 +14,11 @@ "default": "stable", "description": "Select version of the RStudio Server, if not stable." }, + "allowReinstall": { + "type": "boolean", + "default": true, + "description": "Reinstall in case RStudio Server is already installed." + }, "singleUser": { "type": "boolean", "default": true, diff --git a/src/rstudio-server/install.sh b/src/rstudio-server/install.sh index 2be5180..0eba236 100755 --- a/src/rstudio-server/install.sh +++ b/src/rstudio-server/install.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash RS_VERSION=${VERSION:-"stable"} +ALLOW_REINSTALL=${ALLOWREINSTALL:-"false"} SINGLE_USER=${SINGLEUSER:-"true"} RSTUDIO_DATA_DIR=${RSTUDIODATADIR:-"/usr/local/share/rocker-devcontainer-features/rstudio-server/data"} @@ -147,22 +148,26 @@ EOF export DEBIAN_FRONTEND=noninteractive -check_packages curl ca-certificates gdebi-core -check_r +if [ "${ALLOW_REINSTALL}" = "true" ] || [ ! -x "$(command -v rstudio-server)" ]; then + check_packages curl ca-certificates gdebi-core + check_r -# Soft version matching -# If RS_VERSION contains `daily` like `2023.09.0-daily+310`, the check will be skipped. -if [[ "${RS_VERSION}" != "stable" ]] && [[ "${RS_VERSION}" != "preview" ]] && [[ "${RS_VERSION}" != *"daily"* ]]; then - if [ ! -x "$(command -v git)" ]; then - check_packages git + # Soft version matching + # If RS_VERSION contains `daily` like `2023.09.0-daily+310`, the check will be skipped. + if [[ "${RS_VERSION}" != "stable" ]] && [[ "${RS_VERSION}" != "preview" ]] && [[ "${RS_VERSION}" != *"daily"* ]]; then + if [ ! -x "$(command -v git)" ]; then + check_packages git + fi + find_version_from_git_tags RS_VERSION "https://github.com/rstudio/rstudio" fi - find_version_from_git_tags RS_VERSION "https://github.com/rstudio/rstudio" -fi -# Install the RStudio Server -echo "Downloading RStudio Server..." + # Install the RStudio Server + echo "Downloading RStudio Server..." -install_rstudio "${RS_VERSION}" + install_rstudio "${RS_VERSION}" +else + echo "RStudio Server is already installed. Skip installation..." +fi if [ "${SINGLE_USER}" = "true" ]; then echo "Setting up RStudio Server for single user mode..." diff --git a/test/rstudio-server/daily.sh b/test/rstudio-server/daily.sh index 4b365e7..e5bb87f 100755 --- a/test/rstudio-server/daily.sh +++ b/test/rstudio-server/daily.sh @@ -6,7 +6,7 @@ set -e source dev-container-features-test-lib # Feature-specific tests -check "version" bash -c 'rstudio-server version' +check "version" bash -c 'rstudio-server version | grep daily' # Report result reportResults diff --git a/test/rstudio-server/scenarios.json b/test/rstudio-server/scenarios.json index 295e258..38010de 100644 --- a/test/rstudio-server/scenarios.json +++ b/test/rstudio-server/scenarios.json @@ -14,13 +14,22 @@ } }, "daily": { - "image": "rocker/r-ver", + "image": "rocker/rstudio", "features": { "rstudio-server": { "version": "daily" } } }, + "skip-install": { + "image": "rocker/rstudio", + "features": { + "rstudio-server": { + "version": "daily", + "allowReinstall": false + } + } + }, "version-daily-specific": { "image": "rocker/r-ver", "features": { @@ -37,7 +46,7 @@ "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { "packages": "jq" }, - "rstudio-server":{} + "rstudio-server": {} } } } diff --git a/test/rstudio-server/skip-install.sh b/test/rstudio-server/skip-install.sh new file mode 100755 index 0000000..9b2f8f2 --- /dev/null +++ b/test/rstudio-server/skip-install.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +# Feature-specific tests +check "version" bash -c "rstudio-server version | grep ${RSTUDIO_VERSION}" + +# Report result +reportResults