diff --git a/.icons/rustdesk.svg b/.icons/rustdesk.svg new file mode 100644 index 00000000..6c801233 --- /dev/null +++ b/.icons/rustdesk.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/RustDesk.toml b/RustDesk.toml new file mode 100644 index 00000000..172efd0c --- /dev/null +++ b/RustDesk.toml @@ -0,0 +1,2 @@ +[security] +password = "123456" diff --git a/registry/BenraouaneSoufiane/.images/avatar.png b/registry/BenraouaneSoufiane/.images/avatar.png new file mode 100644 index 00000000..297e89df Binary files /dev/null and b/registry/BenraouaneSoufiane/.images/avatar.png differ diff --git a/registry/BenraouaneSoufiane/README.md b/registry/BenraouaneSoufiane/README.md new file mode 100644 index 00000000..d16796f2 --- /dev/null +++ b/registry/BenraouaneSoufiane/README.md @@ -0,0 +1,14 @@ +--- +display_name: "Benraouane Soufiane" +bio: "Full stack developer creating awesome things." +avatar_url: "./.images/avatar.png" +github: "benraouanesoufiane" +linkedin: "https://www.linkedin.com/in/benraouane-soufiane" # Optional +website: "https://benraouanesoufiane.com" # Optional +support_email: "hello@benraouanesoufiane.com" # Optional +status: "community" +--- + +# Benraouane Soufiane + +Full stack developer creating awesome things. \ No newline at end of file diff --git a/registry/BenraouaneSoufiane/modules/rustdesk/README.md b/registry/BenraouaneSoufiane/modules/rustdesk/README.md new file mode 100644 index 00000000..83b2e5d3 --- /dev/null +++ b/registry/BenraouaneSoufiane/modules/rustdesk/README.md @@ -0,0 +1,68 @@ +--- +display_name: Rustdesk +description: Create desktop environmetn & run rustdesk in your workspace +icon: ../../../../.icons/rustdesk.svg +verified: false +tags: [rustdesk, rdp, vm] +--- + +# RustDesk Coder Module + +This is the basic Coder's rustdesk module that install minimal desktop environment (xfce) & launches the rustdesk within your workspace + +--- + +## Features + +- Installs RustDesk & launches it in GUI not with black screen +- Outputs the RustDesk ID and password +- Automatically launches RustDesk on workspace start +- Provides an external app link to the [RustDesk web client](https://rustdesk.com/web) + +--- + +## Usage + +### Prerequisites + +- Coder v2.5 or higher +- A workspace agent compatible with Linux and `apt` package manager +- Root scope (to install desktop environment, rustdesk & execute rustdesk --password "somepassword", because rustdesk cli does not provide a way to get the password else setup in advance, the command rustdesk --password "somepassword" only for root users) + + +--- + +### Quickstart + +1. Add the module to your [Coder Terraform workspace](https://registry.coder.com) +2. Include it in your `main.tf`: + +```hcl +module "rustdesk" { + source = "registry.coder.com/BenraouaneSoufiane/rustdesk/BenraouaneSoufiane" + agent_id = var.agent_id +} +``` +Also add this within resource "docker_container" "workspace": + +```hcl +privileged = true + user = "root" + network_mode = "host" + ports { + internal = 21115 + external = 21115 +} +ports { + internal = 21116 + external = 21116 +} +ports { + internal = 21118 + external = 21118 +} +ports { + internal = 21119 + external = 21119 +} +``` diff --git a/registry/BenraouaneSoufiane/modules/rustdesk/main.tf b/registry/BenraouaneSoufiane/modules/rustdesk/main.tf new file mode 100644 index 00000000..3db0ceb0 --- /dev/null +++ b/registry/BenraouaneSoufiane/modules/rustdesk/main.tf @@ -0,0 +1,61 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 2.5" + } + } +} + +locals { + # A built-in icon like "/icon/code.svg" or a full URL of icon + icon_url = "https://upload.wikimedia.org/wikipedia/commons/9/96/Rustdesk.svg" +} + +# Add required variables for your modules and remove any unneeded variables +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +variable "log_path" { + type = string + description = "The path to log rustdesk to." + default = "/tmp/rustdesk.log" +} + +variable "port" { + type = number + description = "The port to run rustdesk on." + default = 19999 +} + +variable "order" { + type = number + description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)." + default = null +} + +resource "coder_script" "rustdesk" { + count = 1 + agent_id = var.agent_id + display_name = "Rustdesk" + icon = local.icon_url + script = templatefile("${path.module}/run.sh", {}) + run_on_start = true + run_on_stop = false +} + +resource "coder_app" "rustdesk" { + count = 1 + agent_id = var.agent_id + slug = "rustdesk" + display_name = "Rustdesk" + url = "https://rustdesk.com/web" + icon = local.icon_url + order = var.order + external = true +} + diff --git a/registry/BenraouaneSoufiane/modules/rustdesk/run.sh b/registry/BenraouaneSoufiane/modules/rustdesk/run.sh new file mode 100644 index 00000000..520ccde2 --- /dev/null +++ b/registry/BenraouaneSoufiane/modules/rustdesk/run.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Check if RustDesk is installed +if ! command -v rustdesk &> /dev/null; then + echo "RustDesk is not installed. Installing..." + + # Download RustDesk manually + RUSTDESK_VERSION="1.4.0" + RUSTDESK_DEB="rustdesk-$RUSTDESK_VERSION-x86_64.deb" + + echo "Downloading RustDesk $RUSTDESK_VERSION..." + wget "https://github.com/rustdesk/rustdesk/releases/download/$RUSTDESK_VERSION/$RUSTDESK_DEB" + + # Check if download was successful + if [ $? -eq 0 ]; then + echo "Installing dependencies..." + sudo apt update + sudo apt install -y libva2 libva-drm2 libva-x11-2 libgstreamer-plugins-base1.0-0 gstreamer1.0-pipewire xfce4 xfce4-goodies xvfb x11-xserver-utils dbus-x11 + echo "Installing RustDesk..." + sudo dpkg -i $RUSTDESK_DEB + sudo apt-get install -f -y # To fix any dependencies + rm $RUSTDESK_DEB # Clean up + else + echo "Failed to download RustDesk. Please check your network connection." + exit 1 + fi +else + echo "RustDesk is already installed." +fi + +# Start perform other necessary actions perform other necessary actions +echo "Starting Rustdesk..." +# Start virtual display +Xvfb :99 -screen 0 1024x768x16 & +export DISPLAY=:99 + +# Wait for X to be ready +for i in {1..10}; do + if xdpyinfo -display :99 >/dev/null 2>&1; then + echo "X display is ready" + break + fi + sleep 1 +done + +# Start desktop environment +xfce4-session & +# Wait for xfce session to be ready (rudimentary check) +echo "Waiting for xfce4-session to initialize..." +sleep 5 # Adjust if needed + +rustdesk & +# Start RustDesk with password +generated=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 6 | head -n 1) +rustdesk --password "$generated" & + +sleep 5 + +rid=$(rustdesk --get-id) +echo "The ID is: $rid" +echo "The password is: $generated" diff --git a/rustdesk-1.1.9.deb b/rustdesk-1.1.9.deb new file mode 100644 index 00000000..b75c571d Binary files /dev/null and b/rustdesk-1.1.9.deb differ diff --git a/rustdesk-1.1.9.deb.1 b/rustdesk-1.1.9.deb.1 new file mode 100644 index 00000000..b75c571d Binary files /dev/null and b/rustdesk-1.1.9.deb.1 differ diff --git a/rustdesk-1.4.0-x86_64.deb b/rustdesk-1.4.0-x86_64.deb new file mode 100644 index 00000000..6be1582f Binary files /dev/null and b/rustdesk-1.4.0-x86_64.deb differ diff --git a/rustdesk-1.4.0-x86_64.deb.1 b/rustdesk-1.4.0-x86_64.deb.1 new file mode 100644 index 00000000..6be1582f Binary files /dev/null and b/rustdesk-1.4.0-x86_64.deb.1 differ diff --git a/rustdesk-1.4.0-x86_64.deb.2 b/rustdesk-1.4.0-x86_64.deb.2 new file mode 100644 index 00000000..6be1582f Binary files /dev/null and b/rustdesk-1.4.0-x86_64.deb.2 differ diff --git a/rustdesk-1.4.0-x86_64.deb.3 b/rustdesk-1.4.0-x86_64.deb.3 new file mode 100644 index 00000000..6be1582f Binary files /dev/null and b/rustdesk-1.4.0-x86_64.deb.3 differ