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/common/devcontainer-feature.json | 63 ++++++++++++++++++++++++++++++++++++ src/common/feature.json | 52 ----------------------------- src/common/install.sh | 22 ++++++------- 3 files changed, 74 insertions(+), 63 deletions(-) create mode 100644 src/common/devcontainer-feature.json delete mode 100644 src/common/feature.json (limited to 'src/common') diff --git a/src/common/devcontainer-feature.json b/src/common/devcontainer-feature.json new file mode 100644 index 0000000..318d0cf --- /dev/null +++ b/src/common/devcontainer-feature.json @@ -0,0 +1,63 @@ +{ + "id": "common", + "name": "common", + "description": "common", + "options": { + "install_Zsh": { + "type": "boolean", + "default": true, + "description": "Install ZSH?" + }, + "install_Oh_My_Zsh": { + "type": "boolean", + "default": true, + "description": "Install Oh My Zsh!?" + }, + "upgrade_packages": { + "type": "boolean", + "default": true, + "description": "Upgrade OS packages?" + }, + "username": { + "type": "string", + "proposals": [ + "vscode", + "codespace", + "none", + "automatic" + ], + "default": "automatic", + "description": "Enter name of non-root user to configure or none to skip" + }, + "user_uid": { + "type": "string", + "proposals": [ + "1000", + "automatic" + ], + "default": "automatic", + "description": "Enter uid for non-root user" + }, + "user_gid": { + "type": "string", + "proposals": [ + "1000", + "automatic" + ], + "default": "automatic", + "description": "Enter gid for non-root user" + }, + "add_non_free_packages": { + "type": "boolean", + "default": false, + "description": "Add packages from non-free Debian repository?" + } + }, + "extensions": [ + "ms-dotnettools.csharp" + ], + "install": { + "app": "", + "file": "install.sh" + } +} \ No newline at end of file diff --git a/src/common/feature.json b/src/common/feature.json deleted file mode 100644 index d6b94f2..0000000 --- a/src/common/feature.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "id": "common", - "name": "common", - "description": "common", - "options": { - "installZsh": { - "type": "boolean", - "default": true, - "description": "Install ZSH?" - }, - "installOhMyZsh": { - "type": "boolean", - "default": true, - "description": "Install Oh My Zsh!?" - }, - "upgradePackages": { - "type":"boolean", - "default": true, - "description": "Upgrade OS packages?" - }, - "username": { - "type":"string", - "proposals": ["vscode", "codespace", "none", "automatic"], - "default": "automatic", - "description": "Enter name of non-root user to configure or none to skip" - }, - "uid": { - "type":"string", - "proposals": ["1000", "automatic"], - "default": "automatic", - "description": "Enter uid for non-root user" - }, - "gid": { - "type": "string", - "proposals": ["1000", "automatic"], - "default": "automatic", - "description": "Enter gid for non-root user" - }, - "nonFreePackages": { - "type":"boolean", - "default": true, - "description": "Add packages from non-free Debian repository?" - } - }, - "extensions": [ - "ms-dotnettools.csharp" - ], - "install": { - "app": "", - "file": "install.sh" - } -} \ No newline at end of file diff --git a/src/common/install.sh b/src/common/install.sh index 77c64db..ab8adb0 100644 --- a/src/common/install.sh +++ b/src/common/install.sh @@ -6,18 +6,17 @@ # # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md # Maintainer: The VS Code and Codespaces Teams -# -# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] [Add non-free packages] set -e -INSTALL_ZSH=${1:-"true"} -USERNAME=${2:-"automatic"} -USER_UID=${3:-"automatic"} -USER_GID=${4:-"automatic"} -UPGRADE_PACKAGES=${5:-"true"} -INSTALL_OH_MYS=${6:-"true"} -ADD_NON_FREE_PACKAGES=${7:-"false"} +INSTALL_ZSH=${INSTALL_ZSH:-"true"} +INSTALL_OH_MY_ZSH=${INSTALL_OH_MY_ZSH:-"true"} +UPGRADE_PACKAGES=${UPGRADE_PACKAGES:-"true"} +USERNAME=${USERNAME:-"automatic"} +USER_UID=${USER_UID:-"automatic"} +USER_GID=${USER_GID:-"automatic"} +ADD_NON_FREE_PACKAGES=${ADD_NON_FREE_PACKAGES:-"false"} + SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)" MARKER_FILE="/usr/local/etc/vscode-dev-containers/common" @@ -35,7 +34,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 @@ -85,6 +84,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then net-tools \ psmisc \ curl \ + tree \ wget \ rsync \ ca-certificates \ @@ -376,7 +376,7 @@ if [ "${INSTALL_ZSH}" = "true" ]; then # Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme. # See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script. oh_my_install_dir="${user_rc_path}/.oh-my-zsh" - if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then + if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MY_ZSH}" = "true" ]; then template_path="${oh_my_install_dir}/templates/zshrc.zsh-template" user_rc_file="${user_rc_path}/.zshrc" umask g-w,o-w -- cgit v1.2.3