Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 3b8b563

Browse files
authored
Merge branch 'main' into main
2 parents 3d18984 + 7992d9d commit 3b8b563

File tree

10 files changed

+322
-14
lines changed

10 files changed

+322
-14
lines changed

filebrowser/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A file browser for your workspace.
1414
```tf
1515
module "filebrowser" {
1616
source = "registry.coder.com/modules/filebrowser/coder"
17-
version = "1.0.19"
17+
version = "1.0.22"
1818
agent_id = coder_agent.example.id
1919
}
2020
```
@@ -28,7 +28,7 @@ module "filebrowser" {
2828
```tf
2929
module "filebrowser" {
3030
source = "registry.coder.com/modules/filebrowser/coder"
31-
version = "1.0.19"
31+
version = "1.0.22"
3232
agent_id = coder_agent.example.id
3333
folder = "/home/coder/project"
3434
}
@@ -39,7 +39,7 @@ module "filebrowser" {
3939
```tf
4040
module "filebrowser" {
4141
source = "registry.coder.com/modules/filebrowser/coder"
42-
version = "1.0.19"
42+
version = "1.0.22"
4343
agent_id = coder_agent.example.id
4444
database_path = ".config/filebrowser.db"
4545
}

filebrowser/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if [ "${DB_PATH}" != "filebrowser.db" ]; then
1818
fi
1919

2020
# set baseurl to be able to run if sudomain=false; if subdomain=true the SERVER_BASE_PATH value will be ""
21-
filebrowser config set --baseurl "${SERVER_BASE_PATH}" > ${LOG_PATH} 2>&1
21+
filebrowser config set --baseurl "${SERVER_BASE_PATH}"$${DB_FLAG} > ${LOG_PATH} 2>&1
2222

2323
printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n"
2424

jetbrains-gateway/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This module adds a JetBrains Gateway Button to open any workspace with a single
1414
```tf
1515
module "jetbrains_gateway" {
1616
source = "registry.coder.com/modules/jetbrains-gateway/coder"
17-
version = "1.0.20"
17+
version = "1.0.21"
1818
agent_id = coder_agent.example.id
1919
agent_name = "example"
2020
folder = "/home/coder/example"
@@ -32,7 +32,7 @@ module "jetbrains_gateway" {
3232
```tf
3333
module "jetbrains_gateway" {
3434
source = "registry.coder.com/modules/jetbrains-gateway/coder"
35-
version = "1.0.20"
35+
version = "1.0.21"
3636
agent_id = coder_agent.example.id
3737
agent_name = "example"
3838
folder = "/home/coder/example"
@@ -46,7 +46,7 @@ module "jetbrains_gateway" {
4646
```tf
4747
module "jetbrains_gateway" {
4848
source = "registry.coder.com/modules/jetbrains-gateway/coder"
49-
version = "1.0.20"
49+
version = "1.0.21"
5050
agent_id = coder_agent.example.id
5151
agent_name = "example"
5252
folder = "/home/coder/example"
@@ -61,7 +61,7 @@ module "jetbrains_gateway" {
6161
```tf
6262
module "jetbrains_gateway" {
6363
source = "registry.coder.com/modules/jetbrains-gateway/coder"
64-
version = "1.0.20"
64+
version = "1.0.21"
6565
agent_id = coder_agent.example.id
6666
agent_name = "example"
6767
folder = "/home/coder/example"

jetbrains-gateway/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ variable "agent_id" {
1818
description = "The ID of a Coder agent."
1919
}
2020

21+
variable "slug" {
22+
type = string
23+
description = "The slug for the coder_app. Allows resuing the module with the same template."
24+
default = "gateway"
25+
}
26+
2127
variable "agent_name" {
2228
type = string
2329
description = "Agent name."
@@ -247,7 +253,7 @@ data "coder_workspace_owner" "me" {}
247253

248254
resource "coder_app" "gateway" {
249255
agent_id = var.agent_id
250-
slug = "gateway"
256+
slug = var.slug
251257
display_name = local.display_name
252258
icon = local.icon
253259
external = true

kasmvnc/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
display_name: KasmVNC
3+
description: A modern open source VNC server
4+
icon: ../.icons/kasmvnc.svg
5+
maintainer_github: coder
6+
verified: true
7+
tags: [helper, vnc, desktop]
8+
---
9+
10+
# KasmVNC
11+
12+
Automatically install [KasmVNC](https://kasmweb.com/kasmvnc) in a workspace, and create an app to access it via the dashboard.
13+
14+
```tf
15+
module "kasmvnc" {
16+
source = "registry.coder.com/modules/kasmvnc/coder"
17+
version = "1.0.22"
18+
agent_id = coder_agent.example.id
19+
desktop_environment = "xfce"
20+
}
21+
```
22+
23+
> **Note:** This module only works on workspaces with a pre-installed desktop environment. As an example base image you can use `codercom/enterprise-desktop` image.

kasmvnc/main.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { describe, expect, it } from "bun:test";
2+
import {
3+
runTerraformApply,
4+
runTerraformInit,
5+
testRequiredVariables,
6+
} from "../test";
7+
8+
const allowedDesktopEnvs = ["xfce", "kde", "gnome", "lxde", "lxqt"] as const;
9+
type AllowedDesktopEnv = (typeof allowedDesktopEnvs)[number];
10+
11+
type TestVariables = Readonly<{
12+
agent_id: string;
13+
desktop_environment: AllowedDesktopEnv;
14+
port?: string;
15+
kasm_version?: string;
16+
}>;
17+
18+
describe("Kasm VNC", async () => {
19+
await runTerraformInit(import.meta.dir);
20+
testRequiredVariables<TestVariables>(import.meta.dir, {
21+
agent_id: "foo",
22+
desktop_environment: "gnome",
23+
});
24+
25+
it("Successfully installs for all expected Kasm desktop versions", async () => {
26+
for (const v of allowedDesktopEnvs) {
27+
const applyWithEnv = () => {
28+
runTerraformApply<TestVariables>(import.meta.dir, {
29+
agent_id: "foo",
30+
desktop_environment: v,
31+
});
32+
};
33+
34+
expect(applyWithEnv).not.toThrow();
35+
}
36+
});
37+
});

kasmvnc/main.tf

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
coder = {
6+
source = "coder/coder"
7+
version = ">= 0.12"
8+
}
9+
}
10+
}
11+
12+
variable "agent_id" {
13+
type = string
14+
description = "The ID of a Coder agent."
15+
}
16+
17+
variable "port" {
18+
type = number
19+
description = "The port to run KasmVNC on."
20+
default = 6800
21+
}
22+
23+
variable "kasm_version" {
24+
type = string
25+
description = "Version of KasmVNC to install."
26+
default = "1.3.2"
27+
}
28+
29+
variable "desktop_environment" {
30+
type = string
31+
description = "Specifies the desktop environment of the workspace. This should be pre-installed on the workspace."
32+
validation {
33+
condition = contains(["xfce", "kde", "gnome", "lxde", "lxqt"], var.desktop_environment)
34+
error_message = "Invalid desktop environment. Please specify a valid desktop environment."
35+
}
36+
}
37+
38+
resource "coder_script" "kasm_vnc" {
39+
agent_id = var.agent_id
40+
display_name = "KasmVNC"
41+
icon = "/icon/kasmvnc.svg"
42+
script = templatefile("${path.module}/run.sh", {
43+
PORT : var.port,
44+
DESKTOP_ENVIRONMENT : var.desktop_environment,
45+
VERSION : var.kasm_version
46+
})
47+
run_on_start = true
48+
}
49+
50+
resource "coder_app" "kasm_vnc" {
51+
agent_id = var.agent_id
52+
slug = "kasm-vnc"
53+
display_name = "kasmVNC"
54+
url = "http://localhost:${var.port}"
55+
icon = "/icon/kasmvnc.svg"
56+
subdomain = true
57+
share = "owner"
58+
healthcheck {
59+
url = "http://localhost:${var.port}/app"
60+
interval = 5
61+
threshold = 5
62+
}
63+
}

kasmvnc/run.sh

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#!/usr/bin/env bash
2+
3+
#!/bin/bash
4+
5+
# Function to check if vncserver is already installed
6+
check_installed() {
7+
if command -v vncserver &> /dev/null; then
8+
echo "vncserver is already installed."
9+
return 0 # Don't exit, just indicate it's installed
10+
else
11+
return 1 # Indicates not installed
12+
fi
13+
}
14+
15+
# Function to download a file using wget, curl, or busybox as a fallback
16+
download_file() {
17+
local url=$1
18+
local output=$2
19+
if command -v wget &> /dev/null; then
20+
wget $url -O $output
21+
elif command -v curl &> /dev/null; then
22+
curl -fsSL $url -o $output
23+
elif command -v busybox &> /dev/null; then
24+
busybox wget -O $output $url
25+
else
26+
echo "Neither wget, curl, nor busybox is installed. Please install one of them to proceed."
27+
exit 1
28+
fi
29+
}
30+
31+
# Function to install kasmvncserver for debian-based distros
32+
install_deb() {
33+
local url=$1
34+
download_file $url /tmp/kasmvncserver.deb
35+
sudo apt-get update
36+
DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes -qq --no-install-recommends --no-install-suggests /tmp/kasmvncserver.deb
37+
sudo adduser $USER ssl-cert
38+
rm /tmp/kasmvncserver.deb
39+
}
40+
41+
# Function to install kasmvncserver for Oracle 8
42+
install_rpm_oracle8() {
43+
local url=$1
44+
download_file $url /tmp/kasmvncserver.rpm
45+
sudo dnf config-manager --set-enabled ol8_codeready_builder
46+
sudo dnf install oracle-epel-release-el8 -y
47+
sudo dnf localinstall /tmp/kasmvncserver.rpm -y
48+
sudo usermod -aG kasmvnc-cert $USER
49+
rm /tmp/kasmvncserver.rpm
50+
}
51+
52+
# Function to install kasmvncserver for CentOS 7
53+
install_rpm_centos7() {
54+
local url=$1
55+
download_file $url /tmp/kasmvncserver.rpm
56+
sudo yum install epel-release -y
57+
sudo yum install /tmp/kasmvncserver.rpm -y
58+
sudo usermod -aG kasmvnc-cert $USER
59+
rm /tmp/kasmvncserver.rpm
60+
}
61+
62+
# Function to install kasmvncserver for rpm-based distros
63+
install_rpm() {
64+
local url=$1
65+
download_file $url /tmp/kasmvncserver.rpm
66+
sudo rpm -i /tmp/kasmvncserver.rpm
67+
rm /tmp/kasmvncserver.rpm
68+
}
69+
70+
# Function to install kasmvncserver for Alpine Linux
71+
install_alpine() {
72+
local url=$1
73+
download_file $url /tmp/kasmvncserver.tgz
74+
tar -xzf /tmp/kasmvncserver.tgz -C /usr/local/bin/
75+
rm /tmp/kasmvncserver.tgz
76+
}
77+
78+
# Detect system information
79+
distro=$(grep "^ID=" /etc/os-release | awk -F= '{print $2}')
80+
version=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
81+
arch=$(uname -m)
82+
83+
echo "Detected Distribution: $distro"
84+
echo "Detected Version: $version"
85+
echo "Detected Architecture: $arch"
86+
87+
# Map arch to package arch
88+
if [[ "$arch" == "x86_64" ]]; then
89+
if [[ "$distro" == "ubuntu" || "$distro" == "debian" || "$distro" == "kali" ]]; then
90+
arch="amd64"
91+
else
92+
arch="x86_64"
93+
fi
94+
elif [[ "$arch" == "aarch64" || "$arch" == "arm64" ]]; then
95+
if [[ "$distro" == "ubuntu" || "$distro" == "debian" || "$distro" == "kali" ]]; then
96+
arch="arm64"
97+
else
98+
arch="aarch64"
99+
fi
100+
else
101+
echo "Unsupported architecture: $arch"
102+
exit 1
103+
fi
104+
105+
# Check if vncserver is installed, and install if not
106+
if ! check_installed; then
107+
echo "Installing KASM version: ${VERSION}"
108+
case $distro in
109+
ubuntu | debian | kali)
110+
case $version in
111+
"20.04")
112+
install_deb "https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_focal_${VERSION}_$${arch}.deb"
113+
;;
114+
"22.04")
115+
install_deb "https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_jammy_${VERSION}_$${arch}.deb"
116+
;;
117+
"24.04")
118+
install_deb "https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_noble_${VERSION}_$${arch}.deb"
119+
;;
120+
*)
121+
echo "Unsupported Ubuntu/Debian/Kali version: $${version}"
122+
exit 1
123+
;;
124+
esac
125+
;;
126+
oracle)
127+
if [[ "$version" == "8" ]]; then
128+
install_rpm_oracle8 "https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_oracle_8_${VERSION}_$${arch}.rpm"
129+
else
130+
echo "Unsupported Oracle version: $${version}"
131+
exit 1
132+
fi
133+
;;
134+
centos)
135+
if [[ "$version" == "7" ]]; then
136+
install_rpm_centos7 "https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_centos_core_${VERSION}_$${arch}.rpm"
137+
else
138+
install_rpm "https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_centos_core_${VERSION}_$${arch}.rpm"
139+
fi
140+
;;
141+
alpine)
142+
if [[ "$version" == "3.17" || "$version" == "3.18" || "$version" == "3.19" || "$version" == "3.20" ]]; then
143+
install_alpine "https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvnc.alpine_$${version}_$${arch}.tgz"
144+
else
145+
echo "Unsupported Alpine version: $${version}"
146+
exit 1
147+
fi
148+
;;
149+
fedora | opensuse)
150+
install_rpm "https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_$${distro}_$${version}_${VERSION}_$${arch}.rpm"
151+
;;
152+
*)
153+
echo "Unsupported distribution: $${distro}"
154+
exit 1
155+
;;
156+
esac
157+
else
158+
echo "vncserver already installed. Skipping installation."
159+
fi
160+
161+
# Coder port-forwarding from dashboard only supports HTTP
162+
sudo bash -c "cat > /etc/kasmvnc/kasmvnc.yaml <<EOF
163+
network:
164+
protocol: http
165+
websocket_port: ${PORT}
166+
ssl:
167+
require_ssl: false
168+
udp:
169+
public_ip: 127.0.0.1
170+
EOF"
171+
172+
# This password is not used since we start the server without auth.
173+
# The server is protected via the Coder session token / tunnel
174+
# and does not listen publicly
175+
echo -e "password\npassword\n" | vncpasswd -wo -u $USER
176+
177+
# Start the server
178+
printf "🚀 Starting KasmVNC server...\n"
179+
sudo -u $USER bash -c "vncserver -select-de ${DESKTOP_ENVIRONMENT} -disableBasicAuth" > /tmp/kasmvncserver.log 2>&1 &

0 commit comments

Comments
 (0)