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

@ -0,0 +1,82 @@
terraform {
required_version = ">= 1.0"
required_providers {
coder = {
source = "coder/coder"
version = ">= 0.12"
}
}
}
variable "agent_id" {
type = string
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
}
variable "settings" {
type = map(string)
description = "A map of settings to apply to code-server."
default = {}
}
variable "folder" {
type = string
description = "The folder to open in code-server."
default = ""
}
variable "install_prefix" {
type = string
description = "The prefix to install code-server to."
default = "/tmp/code-server"
}
variable "log_path" {
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
display_name = "code-server"
icon = "/icon/code.svg"
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), "\"", "\\\""),
})
run_on_start = true
}
resource "coder_app" "kasm_vnc" {
agent_id = var.agent_id
slug = "kasm-vnc"
display_name = "kasmVNC"
url = "http://localhost:${var.port}"
icon = "/icon/vnc.svg"
subdomain = false
share = "owner"
healthcheck {
url = "http://localhost:${var.port}/healthz"
interval = 5
threshold = 6
}
}

@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Check if LXDE is installed
if ! dpkg -s lxde &>/dev/null; then
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y lxde
else
echo "LXDE 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
else
echo "VNC Server is already installed."
fi
sudo addgroup $USER ssl-cert
# Coder port-forwarding from dashboard only supports HTTP
sudo bash -c 'cat > /etc/kasmvnc/kasmvnc.yaml <<EOF
network:
protocol: http
ssl:
require_ssl: false
udp:
public_ip: 127.0.0.1
EOF'
# This password is not used since we start the server without auth.
# The server is protected via the Coder session token / tunnel
# and does not listen publicly on the VM
echo -e "password\npassword\n" | vncpasswd -wo -u $USER
# Start the server :)
sudo su -u $USER bash -c 'vncserver -select-de "lxde" -disableBasicAuth'
Loading…
Cancel
Save