From 5e1e9a857217767da932d24d0e5f74867cb152b7 Mon Sep 17 00:00:00 2001 From: Mark Phippard Date: Tue, 10 Oct 2023 16:20:42 -0400 Subject: [PATCH] Update postCreateCommand --- src/devtool/devcontainer-feature.json | 4 ++-- src/devtool/install.sh | 27 +++++++++++++++++++++++++++ test/devtool/test.sh | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/devtool/devcontainer-feature.json b/src/devtool/devcontainer-feature.json index 2408a9e..5079c0c 100644 --- a/src/devtool/devcontainer-feature.json +++ b/src/devtool/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "DevTool", "id": "devtool", - "version": "1.0.0", + "version": "1.0.1", "description": "Install DevTool", "installsAfter": [ "ghcr.io/devcontainers/features/common-utils" @@ -13,5 +13,5 @@ ] } }, - "postCreateCommand": "curl -sL https://aka.ms/InstallToolLinux.sh | sh -s DevTool" + "postCreateCommand": "/usr/local/share/install-devtool.sh" } diff --git a/src/devtool/install.sh b/src/devtool/install.sh index a6838b0..8aff975 100644 --- a/src/devtool/install.sh +++ b/src/devtool/install.sh @@ -37,4 +37,31 @@ else check_packages curl ca-certificates xdg-utils fi +# --- Generate a 'install-devtool.sh' script to be executed by the 'postCreateCommand' lifecycle hook +DEVTOOL_SCRIPT_PATH="/usr/local/share/install-devtool.sh" + +tee "$DEVTOOL_SCRIPT_PATH" > /dev/null \ +<< EOF +#!/bin/bash +set -e +EOF + +tee -a "$DEVTOOL_SCRIPT_PATH" > /dev/null \ +<< 'EOF' + +echo "Installing DevTool..." +# Wait up to 3 minutes for the ado-auth-helper to be installed +for i in {1..180}; do + if [ -f ${HOME}/ado-auth-helper ]; then + break + fi + sleep 1 +done + +cd /tmp +curl -sL https://aka.ms/InstallToolLinux.sh | sh -s DevTool +EOF + +chmod 755 "$DEVTOOL_SCRIPT_PATH" + exit 0 \ No newline at end of file diff --git a/test/devtool/test.sh b/test/devtool/test.sh index b57d762..efb8802 100644 --- a/test/devtool/test.sh +++ b/test/devtool/test.sh @@ -6,7 +6,7 @@ set -e source dev-container-features-test-lib # Feature-specific tests -check "dev" dev --version +check "devtool" cat /usr/local/share/install-devtool.sh # Report results