From 7aac86cdba6a890431a072ab1001c9cb44502838 Mon Sep 17 00:00:00 2001 From: Jacob Woffenden Date: Wed, 7 Dec 2022 11:05:41 +0000 Subject: [PATCH 1/4] Added new option to configure zsh as default shell Added test scenario Bumped feature version --- src/common-utils/devcontainer-feature.json | 7 ++++++- src/common-utils/install.sh | 7 +++++++ test/common-utils/configure_zsh_as_default_shell.sh | 12 ++++++++++++ test/common-utils/scenarios.json | 10 ++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/common-utils/configure_zsh_as_default_shell.sh create mode 100644 test/common-utils/scenarios.json diff --git a/src/common-utils/devcontainer-feature.json b/src/common-utils/devcontainer-feature.json index 812e5e9e0..8034aa683 100644 --- a/src/common-utils/devcontainer-feature.json +++ b/src/common-utils/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "common-utils", - "version": "1.1.6", + "version": "1.2.6", "name": "Common Debian Utilities", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.", @@ -10,6 +10,11 @@ "default": true, "description": "Install ZSH?" }, + "configureZshAsDefaultShell": { + "type": "boolean", + "default": false, + "description": "Change default shell to ZSH?" + }, "installOhMyZsh": { "type": "boolean", "default": true, diff --git a/src/common-utils/install.sh b/src/common-utils/install.sh index 5530b96d9..eb0e62425 100755 --- a/src/common-utils/install.sh +++ b/src/common-utils/install.sh @@ -13,6 +13,7 @@ set -e rm -rf /var/lib/apt/lists/* INSTALL_ZSH="${INSTALLZSH:-"true"}" +CONFIGURE_ZSH_AS_DEFAULT_SHELL="${CONFIGUREZSHASDEFAULTSHELL:-"false"}" INSTALL_OH_MY_ZSH="${INSTALLOHMYZSH:-"true"}" UPGRADE_PACKAGES="${UPGRADEPACKAGES:-"true"}" USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}" @@ -378,6 +379,12 @@ if [ "${INSTALL_ZSH}" = "true" ]; then ZSH_ALREADY_INSTALLED="true" fi + # Change shell of determined user + if [[ "${CONFIGURE_ZSH_AS_DEFAULT_SHELL}" == "true" ]]; then + chsh --shell /bin/zsh ${USERNAME} + fi + + # 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" diff --git a/test/common-utils/configure_zsh_as_default_shell.sh b/test/common-utils/configure_zsh_as_default_shell.sh new file mode 100644 index 000000000..5edefa64e --- /dev/null +++ b/test/common-utils/configure_zsh_as_default_shell.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "default-shell-is-zsh" getent passwd vscode | awk -F: '{ print $7 }' | grep "/bin/zsh" + +# Report result +reportResults diff --git a/test/common-utils/scenarios.json b/test/common-utils/scenarios.json new file mode 100644 index 000000000..805480890 --- /dev/null +++ b/test/common-utils/scenarios.json @@ -0,0 +1,10 @@ +{ + "configure_zsh_as_default_shell": { + "image": "ubuntu:focal", + "features": { + "common-utils": { + "configureZshAsDefaultShell": true + } + } + } +} From 5f0a65fd96536071fc3e8226b7c0cea41de00d1e Mon Sep 17 00:00:00 2001 From: Jacob Woffenden Date: Fri, 9 Dec 2022 19:18:46 +0000 Subject: [PATCH 2/4] Update test/common-utils/scenarios.json Co-authored-by: Samruddhi Khandale --- test/common-utils/scenarios.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common-utils/scenarios.json b/test/common-utils/scenarios.json index 805480890..aa36fcb6e 100644 --- a/test/common-utils/scenarios.json +++ b/test/common-utils/scenarios.json @@ -1,6 +1,6 @@ { "configure_zsh_as_default_shell": { - "image": "ubuntu:focal", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "common-utils": { "configureZshAsDefaultShell": true From 55a5393ec6e41264d87acbf3f946aa85f334c96c Mon Sep 17 00:00:00 2001 From: Jacob Woffenden Date: Fri, 9 Dec 2022 19:18:55 +0000 Subject: [PATCH 3/4] Update src/common-utils/devcontainer-feature.json Co-authored-by: Samruddhi Khandale --- src/common-utils/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common-utils/devcontainer-feature.json b/src/common-utils/devcontainer-feature.json index 8034aa683..d2a97d6c9 100644 --- a/src/common-utils/devcontainer-feature.json +++ b/src/common-utils/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "common-utils", - "version": "1.2.6", + "version": "1.2.0", "name": "Common Debian Utilities", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.", From 5c179a171bcf8f2211b19a11e8185ceed17625b3 Mon Sep 17 00:00:00 2001 From: Jacob Woffenden Date: Fri, 9 Dec 2022 21:58:15 +0000 Subject: [PATCH 4/4] Update test/common-utils/configure_zsh_as_default_shell.sh Co-authored-by: Samruddhi Khandale --- test/common-utils/configure_zsh_as_default_shell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common-utils/configure_zsh_as_default_shell.sh b/test/common-utils/configure_zsh_as_default_shell.sh index 5edefa64e..e5cc89e51 100644 --- a/test/common-utils/configure_zsh_as_default_shell.sh +++ b/test/common-utils/configure_zsh_as_default_shell.sh @@ -6,7 +6,7 @@ set -e source dev-container-features-test-lib # Definition specific tests -check "default-shell-is-zsh" getent passwd vscode | awk -F: '{ print $7 }' | grep "/bin/zsh" +check "default-shell-is-zsh" bash -c "getent passwd $(whoami) | awk -F: '{ print $7 }' | grep '/bin/zsh'" # Report result reportResults