add wait for script

pull/250/head
Muhammad Atif Ali 1 year ago
parent a254fd3e89
commit 71a2e6c1ed

@ -26,12 +26,19 @@ variable "kasm_version" {
default = "1.3.1" default = "1.3.1"
} }
variable "wait_for_script" {
type = string
description = "The script to wait for before running the KasmVNC script."
default = ""
}
resource "coder_script" "kasm_vnc" { resource "coder_script" "kasm_vnc" {
agent_id = var.agent_id agent_id = var.agent_id
display_name = "KasmVNC" display_name = "KasmVNC"
icon = "/icon/kasmvnc.svg" icon = "/icon/kasmvnc.svg"
script = templatefile("${path.module}/run.sh", { script = templatefile("${path.module}/run.sh", {
PORT : var.port, PORT : var.port,
WAIT_FOR_SCRIPT : var.wait_for_script,
VERSION : var.kasm_version VERSION : var.kasm_version
}) })
run_on_start = true run_on_start = true

@ -1,5 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# check if there is a WAIT_FOR_SCRIPT env variable and if so, wait for it to be available
# Wait for the startup script to complete
if [ -n "$WAIT_FOR_SCRIPT" ]; then
# This assumes that the script will create a file called /tmp/.coder-${WAIT_FOR_SCRIPT}.done
while [ ! -f /tmp/.coder-${WAIT_FOR_SCRIPT}.done ]; do
sleep 1
done
fi
# Check if desktop environment is installed # Check if desktop environment is installed
if ! dpkg -s $PACKAGES &> /dev/null; then if ! dpkg -s $PACKAGES &> /dev/null; then
sudo apt-get update sudo apt-get update

Loading…
Cancel
Save