From c12a205ab8e195541acfe0cb654b4888e16ea05c Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Fri, 3 Jun 2022 10:46:25 -0400 Subject: Pass options via environment variables (#39) * up to docker-in-docker converted * first pass at the rest of the features (and bash linting and updated CLI * move shell linter to own file * rename feature.json -> devcontainer-feature.json * continue on error * continue on error in right spot * formatting * fix AZ_VERSION * update python * restore variable name * update linter actions, fix dind/dfd/desktop scripts, add test-scenaerios * add tree because I like tree * glob for shell linter * fix test-scenarios * shell linter * more shell helper --- src/java/devcontainer-feature.json | 34 ++++++++++++++++++++++++++++++++++ src/java/feature.json | 34 ---------------------------------- src/java/install.sh | 11 ++++++----- src/java/wrapper.sh | 2 +- 4 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 src/java/devcontainer-feature.json delete mode 100644 src/java/feature.json (limited to 'src/java') diff --git a/src/java/devcontainer-feature.json b/src/java/devcontainer-feature.json new file mode 100644 index 0000000..64d5d65 --- /dev/null +++ b/src/java/devcontainer-feature.json @@ -0,0 +1,34 @@ +{ + "id": "java", + "name": "Java (via SDKMAN!)", + "options": { + "version": { + "type": "string", + "proposals": [ + "lts", + "latest", + "none", + "17", + "11", + "8" + ], + "default": "lts", + "description": "Select or enter a Java version to install" + } + }, + "buildArg": "_VSC_INSTALL_JAVA", + "extensions": [ + "vscjava.vscode-java-pack" + ], + "containerEnv": { + "SDKMAN_DIR": "/usr/local/sdkman", + "PATH": "${SDKMAN_DIR}/bin:${SDKMAN_DIR}/candidates/java/current/bin:${PATH}" + }, + "settings": { + "java.import.gradle.java.home": "/usr/local/sdkman/candidates/java/current" + }, + "install": { + "app": "", + "file": "install.sh" + } +} \ No newline at end of file diff --git a/src/java/feature.json b/src/java/feature.json deleted file mode 100644 index 64d5d65..0000000 --- a/src/java/feature.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "id": "java", - "name": "Java (via SDKMAN!)", - "options": { - "version": { - "type": "string", - "proposals": [ - "lts", - "latest", - "none", - "17", - "11", - "8" - ], - "default": "lts", - "description": "Select or enter a Java version to install" - } - }, - "buildArg": "_VSC_INSTALL_JAVA", - "extensions": [ - "vscjava.vscode-java-pack" - ], - "containerEnv": { - "SDKMAN_DIR": "/usr/local/sdkman", - "PATH": "${SDKMAN_DIR}/bin:${SDKMAN_DIR}/candidates/java/current/bin:${PATH}" - }, - "settings": { - "java.import.gradle.java.home": "/usr/local/sdkman/candidates/java/current" - }, - "install": { - "app": "", - "file": "install.sh" - } -} \ No newline at end of file diff --git a/src/java/install.sh b/src/java/install.sh index f5880cd..7918568 100644 --- a/src/java/install.sh +++ b/src/java/install.sh @@ -9,10 +9,11 @@ # # Syntax: ./java-debian.sh [JDK version] [SDKMAN_DIR] [non-root user] [Add to rc files flag] -JAVA_VERSION=${1:-"lts"} -export SDKMAN_DIR=${2:-"/usr/local/sdkman"} -USERNAME=${3:-"automatic"} -UPDATE_RC=${4:-"true"} +JAVA_VERSION=${VERSION:-"lts"} + +export SDKMAN_DIR=${SDKMAN_DIR:-"/usr/local/sdkman"} +USERNAME=${USERNAME:-"automatic"} +UPDATE_RC=${UPDATE_RC:-"true"} set -e @@ -30,7 +31,7 @@ chmod +x /etc/profile.d/00-restore-env.sh if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then USERNAME="" POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") - for CURRENT_USER in ${POSSIBLE_USERS[@]}; do + for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do if id -u ${CURRENT_USER} > /dev/null 2>&1; then USERNAME=${CURRENT_USER} break diff --git a/src/java/wrapper.sh b/src/java/wrapper.sh index 4d2aef3..d7f05de 100644 --- a/src/java/wrapper.sh +++ b/src/java/wrapper.sh @@ -27,7 +27,7 @@ if [ "${is_jdk_8}" = "true" ]; then # Determine the appropriate non-root user username="" possible_users=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") - for current_user in ${possible_users[@]}; do + for current_user in "${POSSIBLE_USERS[@]}"; do if id -u ${current_user} > /dev/null 2>&1; then username=${current_user} break -- cgit v1.2.3