add kasmVNC

pull/24/head
Muhammad Atif Ali 2 years ago
parent 9b9dd76e1e
commit f68b31b28e

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

@ -1,7 +1,7 @@
--- ---
display_name: KasmVNC display_name: KasmVNC
description: A modern open source VNC server description: A modern open source VNC server
icon: ../.icons/kasmvnc.svg icon: ../.icons/kasm.png
maintainer_github: coder maintainer_github: coder
verified: true verified: true
tags: [helper, ide] tags: [helper, ide]
@ -13,4 +13,25 @@ Automatically install [KasmVNC](https://kasmweb.com/kasmvnc) in a workspace, and
## Examples ## Examples
TODO 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
}
```

@ -14,53 +14,32 @@ variable "agent_id" {
description = "The ID of a Coder agent." description = "The ID of a Coder agent."
} }
variable "extensions" {
type = list(string)
description = "A list of extensions to install."
default = []
}
variable "port" { variable "port" {
type = number type = number
description = "The port to run code-server on." description = "The port to run KasmVNC on."
default = 13337 default = 8443
} }
variable "settings" { variable "desktop_environment" {
type = map(string)
description = "A map of settings to apply to code-server."
default = {}
}
variable "folder" {
type = string type = string
description = "The folder to open in code-server." description = "The desktop environment to for KasmVNC (xfce, lxde, mate, etc)."
default = "" default = "lxde"
} }
variable "install_prefix" { variable "version" {
type = string type = string
description = "The prefix to install code-server to." description = "Version of KasmVNC to install."
default = "/tmp/code-server" default = "1.2.0"
} }
variable "log_path" { resource "coder_script" "kasm_vnc" {
type = string
description = "The path to log code-server to."
default = "/tmp/code-server.log"
}
resource "coder_script" "code-server" {
agent_id = var.agent_id agent_id = var.agent_id
display_name = "code-server" display_name = "KasmVNC"
icon = "/icon/code.svg" icon = "/icon/kasm.png"
script = templatefile("${path.module}/run.sh", { script = templatefile("${path.module}/run.sh", {
EXTENSIONS : join(",", var.extensions),
PORT : var.port, PORT : var.port,
LOG_PATH : var.log_path, DESKTOP_ENVIRONMENT : var.desktop_environment,
INSTALL_PREFIX : var.install_prefix, VERSION : var.version
// This is necessary otherwise the quotes are stripped!
SETTINGS : replace(jsonencode(var.settings), "\"", "\\\""),
}) })
run_on_start = true run_on_start = true
} }
@ -70,13 +49,7 @@ resource "coder_app" "kasm_vnc" {
slug = "kasm-vnc" slug = "kasm-vnc"
display_name = "kasmVNC" display_name = "kasmVNC"
url = "http://localhost:${var.port}" url = "http://localhost:${var.port}"
icon = "/icon/vnc.svg" icon = "/icon/kasm.png"
subdomain = false subdomain = false
share = "owner" share = "owner"
healthcheck {
url = "http://localhost:${var.port}/healthz"
interval = 5
threshold = 6
}
} }

@ -1,20 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Check if LXDE is installed # Check if desktop enivronment is installed
if ! dpkg -s lxde &>/dev/null; then if ! dpkg -s ${DESKTOP_ENVIRONMENT} &>/dev/null; then
sudo apt-get update sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y lxde DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ${DESKTOP_ENVIRONMENT}
else else
echo "LXDE is already installed." echo "${DESKTOP_ENVIRONMENT} is already installed."
fi fi
# Check if vncserver is installed # Check if vncserver is installed
if ! dpkg -s kasmvncserver &>/dev/null; then if ! dpkg -s kasmvncserver &>/dev/null; then
cd /tmp cd /tmp
wget https://github.com/kasmtech/KasmVNC/releases/download/v1.1.0/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_1.1.0_amd64.deb sudo apt install -y ./kasmvncserver_focal_${VERSION}_amd64.deb
printf "🥳 KasmVNC v${VERSION} has been successfully installed!\n\n"
else else
echo "VNC Server is already installed." echo "KasmVNC is already installed."
fi fi
sudo addgroup $USER ssl-cert sudo addgroup $USER ssl-cert
@ -23,6 +24,7 @@ sudo addgroup $USER ssl-cert
sudo bash -c 'cat > /etc/kasmvnc/kasmvnc.yaml <<EOF sudo bash -c 'cat > /etc/kasmvnc/kasmvnc.yaml <<EOF
network: network:
protocol: http protocol: http
websocekt_port: ${PORT}
ssl: ssl:
require_ssl: false require_ssl: false
udp: udp:
@ -35,4 +37,4 @@ EOF'
echo -e "password\npassword\n" | vncpasswd -wo -u $USER echo -e "password\npassword\n" | vncpasswd -wo -u $USER
# Start the server :) # Start the server :)
sudo su -u $USER bash -c 'vncserver -select-de "lxde" -disableBasicAuth' sudo su -u $USER bash -c 'vncserver -select-de "${DESKTOP_ENVIRONMENT}" -disableBasicAuth'

Loading…
Cancel
Save