fix: add install_version to code-server
This commit is contained in:
@@ -50,11 +50,18 @@ variable "log_path" {
|
|||||||
default = "/tmp/code-server.log"
|
default = "/tmp/code-server.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "install_version" {
|
||||||
|
type = string
|
||||||
|
description = "The version of code-server to install."
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
resource "coder_script" "code-server" {
|
resource "coder_script" "code-server" {
|
||||||
agent_id = var.agent_id
|
agent_id = var.agent_id
|
||||||
display_name = "code-server"
|
display_name = "code-server"
|
||||||
icon = "/icon/code.svg"
|
icon = "/icon/code.svg"
|
||||||
script = templatefile("${path.module}/run.sh", {
|
script = templatefile("${path.module}/run.sh", {
|
||||||
|
VERSION : var.install_version,
|
||||||
EXTENSIONS : join(",", var.extensions),
|
EXTENSIONS : join(",", var.extensions),
|
||||||
PORT : var.port,
|
PORT : var.port,
|
||||||
LOG_PATH : var.log_path,
|
LOG_PATH : var.log_path,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
EXTENSIONS=("${EXTENSIONS}")
|
EXTENSIONS=("${EXTENSIONS}")
|
||||||
BOLD='\033[0;1m'
|
BOLD='\033[0;1m'
|
||||||
@@ -6,7 +6,16 @@ CODE='\033[36;40;1m'
|
|||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
|
||||||
printf "$${BOLD}Installing code-server!\n"
|
printf "$${BOLD}Installing code-server!\n"
|
||||||
output=$(curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=${INSTALL_PREFIX})
|
|
||||||
|
ARGS=(
|
||||||
|
"--method=standalone"
|
||||||
|
"--prefix=${INSTALL_PREFIX}"
|
||||||
|
)
|
||||||
|
if [ -n "${VERSION}" ]; then
|
||||||
|
args+=("--version=${VERSION}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
output=$(curl -fsSL https://code-server.dev/install.sh | sh -s -- "$${ARGS[@]}")
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to install code-server: $output"
|
echo "Failed to install code-server: $output"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
3
test.ts
3
test.ts
@@ -32,6 +32,7 @@ export const runContainer = async (
|
|||||||
export const executeScriptInContainer = async (
|
export const executeScriptInContainer = async (
|
||||||
state: TerraformState,
|
state: TerraformState,
|
||||||
image: string,
|
image: string,
|
||||||
|
shell: string = "sh",
|
||||||
): Promise<{
|
): Promise<{
|
||||||
exitCode: number;
|
exitCode: number;
|
||||||
stdout: string[];
|
stdout: string[];
|
||||||
@@ -39,7 +40,7 @@ export const executeScriptInContainer = async (
|
|||||||
}> => {
|
}> => {
|
||||||
const instance = findResourceInstance(state, "coder_script");
|
const instance = findResourceInstance(state, "coder_script");
|
||||||
const id = await runContainer(image);
|
const id = await runContainer(image);
|
||||||
const resp = await execContainer(id, ["sh", "-c", instance.script]);
|
const resp = await execContainer(id, [shell, "-c", instance.script]);
|
||||||
const stdout = resp.stdout.trim().split("\n");
|
const stdout = resp.stdout.trim().split("\n");
|
||||||
const stderr = resp.stderr.trim().split("\n");
|
const stderr = resp.stderr.trim().split("\n");
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user