diff --git a/vscode-web/main.tf b/vscode-web/main.tf index 3efe44d..ae2bceb 100644 --- a/vscode-web/main.tf +++ b/vscode-web/main.tf @@ -32,6 +32,12 @@ variable "log_path" { default = "/tmp/vscode-web.log" } +variable "install_dir" { + type = string + description = "The directory to install VS Code" + default = "~/.vscodeweb" +} + variable "accept_license" { type = bool description = "Accept the VS Code license. https://code.visualstudio.com/license" @@ -56,6 +62,7 @@ resource "coder_script" "vscode-web" { PORT : var.port, LOG_PATH : var.log_path, VERSION : var.custom_version, + INSTALL_DIR : var.install_dir, }) run_on_start = true } diff --git a/vscode-web/run.sh b/vscode-web/run.sh index 4343159..05a318d 100644 --- a/vscode-web/run.sh +++ b/vscode-web/run.sh @@ -1,13 +1,14 @@ #!/usr/bin/env sh BOLD='\033[0;1m' -# check if VS Code is installed -if - ! command -v code & - >/dev/null -then - printf "$${BOLD}Installing VS Code!\n" - output=$(curl -L "https://update.code.visualstudio.com/${VERSION}/linux-deb-x64/stable" -o /tmp/code.deb && sudo apt-get update && sudo apt-get install -y /tmp/code.deb) + +# Check if VS Code is installed +if [ ! -d "${INSTALL_DIR}" ]; then + printf "${BOLD}Installing VS Code!\n" + # Download and extract VS Code tarball + output=$(curl -L "https://update.code.visualstudio.com/latest/linux-x64/stable" -o /tmp/code.tar.gz && + mkdir -p ${INSTALL_DIR} && + tar -xzf /tmp/code.tar.gz -C ${INSTALL_DIR} --strip-components=1) if [ $? -ne 0 ]; then echo "Failed to install VS Code: $output" exit 1