update install_dir

pull/42/head
Muhammad Atif Ali 2 years ago
parent d93934a006
commit 7f3708f306
No known key found for this signature in database

@ -32,6 +32,12 @@ variable "log_path" {
default = "/tmp/vscode-web.log" default = "/tmp/vscode-web.log"
} }
variable "install_dir" {
type = string
description = "The directory to install VS Code"
default = "~/.vscodeweb"
}
variable "accept_license" { variable "accept_license" {
type = bool type = bool
description = "Accept the VS Code license. https://code.visualstudio.com/license" description = "Accept the VS Code license. https://code.visualstudio.com/license"
@ -56,6 +62,7 @@ resource "coder_script" "vscode-web" {
PORT : var.port, PORT : var.port,
LOG_PATH : var.log_path, LOG_PATH : var.log_path,
VERSION : var.custom_version, VERSION : var.custom_version,
INSTALL_DIR : var.install_dir,
}) })
run_on_start = true run_on_start = true
} }

@ -1,13 +1,14 @@
#!/usr/bin/env sh #!/usr/bin/env sh
BOLD='\033[0;1m' BOLD='\033[0;1m'
# check if VS Code is installed
if # Check if VS Code is installed
! command -v code & if [ ! -d "${INSTALL_DIR}" ]; then
>/dev/null printf "${BOLD}Installing VS Code!\n"
then # Download and extract VS Code tarball
printf "$${BOLD}Installing VS Code!\n" output=$(curl -L "https://update.code.visualstudio.com/latest/linux-x64/stable" -o /tmp/code.tar.gz &&
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) mkdir -p ${INSTALL_DIR} &&
tar -xzf /tmp/code.tar.gz -C ${INSTALL_DIR} --strip-components=1)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to install VS Code: $output" echo "Failed to install VS Code: $output"
exit 1 exit 1

Loading…
Cancel
Save