diff --git a/.icons/kasm.png b/.icons/kasm.png new file mode 100644 index 0000000..2da3cf1 Binary files /dev/null and b/.icons/kasm.png differ diff --git a/kasmvnc/README.md b/kasmvnc/README.md index 1803268..d07d894 100644 --- a/kasmvnc/README.md +++ b/kasmvnc/README.md @@ -1,7 +1,7 @@ --- display_name: KasmVNC description: A modern open source VNC server -icon: ../.icons/kasmvnc.svg +icon: ../.icons/kasm.png maintainer_github: coder verified: true tags: [helper, ide] @@ -13,4 +13,25 @@ Automatically install [KasmVNC](https://kasmweb.com/kasmvnc) in a workspace, and ## Examples -TODO \ No newline at end of file +1. Add latest version of KasmVNC with ['lxde'](https://www.lxde.org/) desktop environment: + + ```hcl + module "kasmvnc" { + source = "https://registry.coder.com/modules/kasmvnc" + agent_id = coder_agent.example.id + } + + ``` + +2. Add specific version '0.9.11' of KasmVNC with ['mate'](https://mate-desktop.org/) desktop environment and custom port: + + ```hcl + module "kasmvnc" { + source = "https://registry.coder.com/modules/kasmvnc" + agent_id = coder_agent.example.id + version = "1.0.0" + desktop_environment = "mate" + port = 6080 + } + + ``` diff --git a/kasmvnc/main.tf b/kasmvnc/main.tf index 65ea242..5702357 100644 --- a/kasmvnc/main.tf +++ b/kasmvnc/main.tf @@ -14,53 +14,32 @@ variable "agent_id" { description = "The ID of a Coder agent." } -variable "extensions" { - type = list(string) - description = "A list of extensions to install." - default = [] -} - variable "port" { type = number - description = "The port to run code-server on." - default = 13337 + description = "The port to run KasmVNC on." + default = 8443 } -variable "settings" { - type = map(string) - description = "A map of settings to apply to code-server." - default = {} -} - -variable "folder" { +variable "desktop_environment" { type = string - description = "The folder to open in code-server." - default = "" + description = "The desktop environment to for KasmVNC (xfce, lxde, mate, etc)." + default = "lxde" } -variable "install_prefix" { +variable "version" { type = string - description = "The prefix to install code-server to." - default = "/tmp/code-server" + description = "Version of KasmVNC to install." + default = "1.2.0" } -variable "log_path" { - type = string - description = "The path to log code-server to." - default = "/tmp/code-server.log" -} - -resource "coder_script" "code-server" { +resource "coder_script" "kasm_vnc" { agent_id = var.agent_id - display_name = "code-server" - icon = "/icon/code.svg" + display_name = "KasmVNC" + icon = "/icon/kasm.png" script = templatefile("${path.module}/run.sh", { - EXTENSIONS : join(",", var.extensions), PORT : var.port, - LOG_PATH : var.log_path, - INSTALL_PREFIX : var.install_prefix, - // This is necessary otherwise the quotes are stripped! - SETTINGS : replace(jsonencode(var.settings), "\"", "\\\""), + DESKTOP_ENVIRONMENT : var.desktop_environment, + VERSION : var.version }) run_on_start = true } @@ -70,13 +49,7 @@ resource "coder_app" "kasm_vnc" { slug = "kasm-vnc" display_name = "kasmVNC" url = "http://localhost:${var.port}" - icon = "/icon/vnc.svg" + icon = "/icon/kasm.png" subdomain = false share = "owner" - - healthcheck { - url = "http://localhost:${var.port}/healthz" - interval = 5 - threshold = 6 - } } diff --git a/kasmvnc/run.sh b/kasmvnc/run.sh index 49347f9..7a59580 100644 --- a/kasmvnc/run.sh +++ b/kasmvnc/run.sh @@ -1,20 +1,21 @@ #!/usr/bin/env bash -# Check if LXDE is installed -if ! dpkg -s lxde &>/dev/null; then +# Check if desktop enivronment is installed +if ! dpkg -s ${DESKTOP_ENVIRONMENT} &>/dev/null; then sudo apt-get update - DEBIAN_FRONTEND=noninteractive sudo apt-get install -y lxde + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ${DESKTOP_ENVIRONMENT} else - echo "LXDE is already installed." + echo "${DESKTOP_ENVIRONMENT} is already installed." fi # Check if vncserver is installed if ! dpkg -s kasmvncserver &>/dev/null; then cd /tmp - wget https://github.com/kasmtech/KasmVNC/releases/download/v1.1.0/kasmvncserver_focal_1.1.0_amd64.deb - sudo apt install -y ./kasmvncserver_focal_1.1.0_amd64.deb + wget https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_focal_${VERSION}_amd64.deb + sudo apt install -y ./kasmvncserver_focal_${VERSION}_amd64.deb + printf "🥳 KasmVNC v${VERSION} has been successfully installed!\n\n" else - echo "VNC Server is already installed." + echo "KasmVNC is already installed." fi sudo addgroup $USER ssl-cert @@ -23,6 +24,7 @@ sudo addgroup $USER ssl-cert sudo bash -c 'cat > /etc/kasmvnc/kasmvnc.yaml <