-
Notifications
You must be signed in to change notification settings - Fork 58
Add Rustdesk module #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+293
−0
Open
Add Rustdesk module #266
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
59c2932
Add Rustdesk module
eef8b83
Update README.md
1a53794
Update README.md
BenraouaneSoufiane 89bd112
Delete registry/benraouanesoufiane directory
BenraouaneSoufiane 3632017
Update README.md
BenraouaneSoufiane 66854ab
Merge branch 'coder:main' into main
BenraouaneSoufiane 03c06e6
Fix mentionned issues
2f593bb
Moving module to BenraouaneSoufiane & updating readme.md
1b285fb
Merge branch 'coder:main' into main
BenraouaneSoufiane b1210b7
Merge branch 'main' into main
DevelopmentCats 8d198a2
Delete rustdesk-1.1.9.deb
BenraouaneSoufiane e0521fc
Delete rustdesk-1.1.9.deb.1
BenraouaneSoufiane c7124c9
Delete rustdesk-1.4.0-x86_64.deb
BenraouaneSoufiane 79cc39e
Delete rustdesk-1.4.0-x86_64.deb.1
BenraouaneSoufiane d20b0f0
Delete rustdesk-1.4.0-x86_64.deb.2
BenraouaneSoufiane 832981c
Delete rustdesk-1.4.0-x86_64.deb.3
BenraouaneSoufiane 918f79b
Fix outlined issues
ba840b7
Merge branch 'coder:main' into main
BenraouaneSoufiane d917244
Delete RustDesk.toml
BenraouaneSoufiane 77a8e9a
Update registry/BenraouaneSoufiane/modules/rustdesk/README.md
BenraouaneSoufiane 01f93a3
Update registry/BenraouaneSoufiane/modules/rustdesk/README.md
BenraouaneSoufiane 3b11a27
Update registry/BenraouaneSoufiane/modules/rustdesk/main.tf
BenraouaneSoufiane 97330a6
Update registry/BenraouaneSoufiane/modules/rustdesk/run.sh
BenraouaneSoufiane b889cff
Update registry/BenraouaneSoufiane/modules/rustdesk/run.sh
BenraouaneSoufiane 15a734e
Merge branch 'coder:main' into main
BenraouaneSoufiane fb3ee63
Update README.md
BenraouaneSoufiane a8a2a75
Formatting files using fmt command
6ebd45b
Delete package-lock.json
BenraouaneSoufiane 1c97157
chore: run bun run fmt
DevelopmentCats 17ee696
chore: update avatar_url to avatar
DevelopmentCats 2349eba
chore: restructure and clean up README
DevelopmentCats 608a411
chore: bun run fmt
DevelopmentCats b20615d
chore: update examples
DevelopmentCats f5ca292
fix: change default version to latest unless specified instead of har...
DevelopmentCats 2c94a68
fix: use sudo instead of requiring root
DevelopmentCats 0797881
chore: bun run fmt
DevelopmentCats a777679
fix: add LOG_PATH
DevelopmentCats 6a386b2
fix: update README and run script to remove XFCE dependency and clari...
DevelopmentCats 97f6571
fix: add xkb-data and xkeyboard-config dependencies for proper instal...
DevelopmentCats 1726629
Update README.md
BenraouaneSoufiane f91ac76
Merge branch 'coder:main' into main
BenraouaneSoufiane aa4d104
Update run.sh
BenraouaneSoufiane 453766a
Merge branch 'coder:main' into main
BenraouaneSoufiane e7bf22b
chore: bun run fmt
DevelopmentCats 72240b9
Merge branch 'main' into main
DevelopmentCats 4d62fbd
Merge branch 'coder:main' into main
BenraouaneSoufiane 78aaf88
fix: update installation dependencies for RustDesk on apt, dnf, and yum
DevelopmentCats e86b305
fix: update installation dependencies for RustDesk to include correct...
DevelopmentCats 8484447
fix: improve logging and password generation in RustDesk setup script
DevelopmentCats 55eaf1f
Merge branch 'coder:main' into main
BenraouaneSoufiane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
.icons/rustdesk.svg
Binary file added
registry/BenraouaneSoufiane/.images/avatar.png
14 changes: 14 additions & 0 deletions
registry/BenraouaneSoufiane/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
display_name: "Benraouane Soufiane" | ||
bio: "Full stack developer creating awesome things." | ||
avatar: "./.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. |
82 changes: 82 additions & 0 deletions
registry/BenraouaneSoufiane/modules/rustdesk/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
display_name: RustDesk | ||
description: Run RustDesk in your workspace with virtual display | ||
icon: ../../../../.icons/rustdesk.svg | ||
verified: false | ||
tags: [rustdesk, rdp, vm] | ||
--- | ||
|
||
# RustDesk | ||
|
||
Launches RustDesk within your workspace with a virtual display to provide remote desktop access. The module outputs the RustDesk ID and password needed to connect from external RustDesk clients. | ||
|
||
```tf | ||
module "rustdesk" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/BenraouaneSoufiane/rustdesk/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
} | ||
``` | ||
|
||
## Features | ||
|
||
- Automatically sets up virtual display (Xvfb) | ||
- Downloads and configures RustDesk | ||
- Outputs RustDesk ID and password for easy connection | ||
- Provides external app link to RustDesk web client for browser-based access | ||
- Starts virtual display (Xvfb) with customizable resolution | ||
- Customizable screen resolution and RustDesk version | ||
|
||
## Requirements | ||
|
||
- Coder v2.5 or higher | ||
- Linux workspace with `apt`, `dnf`, or `yum` package manager | ||
|
||
## Examples | ||
|
||
### Custom configuration with specific version | ||
|
||
```tf | ||
module "rustdesk" { | ||
count = data.coder_workspace.me.start_count | ||
source = "registry.coder.com/BenraouaneSoufiane/rustdesk/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
rustdesk_password = "mycustompass" | ||
xvfb_resolution = "1920x1080x24" | ||
rustdesk_version = "1.4.1" | ||
} | ||
``` | ||
|
||
### Docker container configuration | ||
|
||
It requires coder' server to be run as root, when using with Docker, add the following to your `docker_container` resource: | ||
|
||
```tf | ||
resource "docker_container" "workspace" { | ||
|
||
# ... other configuration ... | ||
|
||
user = "root" | ||
privileged = true | ||
network_mode = "host" | ||
|
||
ports { | ||
internal = 21115 | ||
external = 21115 | ||
} | ||
ports { | ||
internal = 21116 | ||
external = 21116 | ||
} | ||
ports { | ||
internal = 21118 | ||
external = 21118 | ||
} | ||
ports { | ||
internal = 21119 | ||
external = 21119 | ||
} | ||
} | ||
``` |
75 changes: 75 additions & 0 deletions
registry/BenraouaneSoufiane/modules/rustdesk/main.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
coder = { | ||
source = "coder/coder" | ||
version = ">= 2.5" | ||
} | ||
} | ||
} | ||
|
||
variable "log_path" { | ||
type = string | ||
description = "The path to log rustdesk to." | ||
default = "/tmp/rustdesk.log" | ||
} | ||
|
||
variable "agent_id" { | ||
description = "Attach RustDesk setup to this agent" | ||
type = string | ||
} | ||
|
||
variable "order" { | ||
description = "Run order among scripts/apps" | ||
type = number | ||
default = 1 | ||
} | ||
|
||
# Optional knobs passed as env (you can expose these as variables too) | ||
variable "rustdesk_password" { | ||
description = "If empty, the script will generate one" | ||
type = string | ||
default = "" | ||
sensitive = true | ||
} | ||
|
||
variable "xvfb_resolution" { | ||
description = "Xvfb screen size/depth" | ||
type = string | ||
default = "1024x768x16" | ||
} | ||
|
||
variable "rustdesk_version" { | ||
description = "RustDesk version to install (use 'latest' for most recent release)" | ||
type = string | ||
default = "latest" | ||
} | ||
|
||
resource "coder_script" "rustdesk" { | ||
agent_id = var.agent_id | ||
display_name = "RustDesk" | ||
run_on_start = true | ||
|
||
# Prepend env as bash exports, then append the script file literally. | ||
script = <<-EOT | ||
# --- module-provided env knobs --- | ||
export RUSTDESK_PASSWORD="${var.rustdesk_password}" | ||
export XVFB_RESOLUTION="${var.xvfb_resolution}" | ||
export RUSTDESK_VERSION="${var.rustdesk_version}" | ||
# --------------------------------- | ||
|
||
${file("${path.module}/run.sh")} | ||
EOT | ||
} | ||
|
||
resource "coder_app" "rustdesk" { | ||
agent_id = var.agent_id | ||
slug = "rustdesk" | ||
display_name = "Rustdesk" | ||
url = "https://rustdesk.com/web" | ||
icon = "/icon/rustdesk.svg" | ||
order = var.order | ||
external = true | ||
} | ||
|
117 changes: 117 additions & 0 deletions
registry/BenraouaneSoufiane/modules/rustdesk/run.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#!/usr/bin/env bash | ||
|
||
BOLD='033円[0;1m' | ||
RESET='033円[0m' | ||
|
||
printf "${BOLD}🖥️ Installing RustDesk Remote Desktop\n${RESET}" | ||
|
||
# ---- configurable knobs (env overrides) ---- | ||
RUSTDESK_VERSION="${RUSTDESK_VERSION:-latest}" | ||
LOG_PATH="${LOG_PATH:-/tmp/rustdesk.log}" | ||
|
||
# ---- fetch latest version if needed ---- | ||
if [ "$RUSTDESK_VERSION" = "latest" ]; then | ||
printf "🔍 Fetching latest RustDesk version...\n" | ||
RUSTDESK_VERSION=$(curl -s https://api.github.com/repos/rustdesk/rustdesk/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/1円/' || echo "1.4.1") | ||
printf "📌 Fetched RustDesk version: ${RUSTDESK_VERSION}\n" | ||
else | ||
printf "📌 Using specified RustDesk version: ${RUSTDESK_VERSION}\n" | ||
fi | ||
XVFB_RESOLUTION="${XVFB_RESOLUTION:-1024x768x16}" | ||
RUSTDESK_PASSWORD="${RUSTDESK_PASSWORD:-}" | ||
|
||
# ---- detect package manager & arch ---- | ||
ARCH="$(uname -m)" | ||
case "$ARCH" in | ||
x86_64 | amd64) PKG_ARCH="x86_64" ;; | ||
aarch64 | arm64) PKG_ARCH="aarch64" ;; | ||
*) | ||
echo "❌ Unsupported arch: $ARCH" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
if command -v apt-get >/dev/null 2>&1; then | ||
PKG_SYS="deb" | ||
PKG_NAME="rustdesk-${RUSTDESK_VERSION}-${PKG_ARCH}.deb" | ||
INSTALL_DEPS='apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y wget libva2 libva-drm2 libva-x11-2 libgstreamer-plugins-base1.0-0 gstreamer1.0-pipewire xfce4 xfce4-goodies xvfb x11-xserver-utils dbus-x11 libegl1 libgl1 libglx0 libglu1-mesa mesa-utils libxrandr2 libxss1 libgtk-3-0t64 libgbm1 libdrm2 libxcomposite1 libxdamage1 libxfixes3' | ||
INSTALL_CMD="apt-get install -y ./${PKG_NAME}" | ||
CLEAN_CMD="rm -f \"${PKG_NAME}\"" | ||
elif command -v dnf >/dev/null 2>&1; then | ||
PKG_SYS="rpm" | ||
PKG_NAME="rustdesk-${RUSTDESK_VERSION}-${PKG_ARCH}.rpm" | ||
INSTALL_DEPS='dnf install -y wget libva libva-intel-driver gstreamer1-plugins-base pipewire xfce4-session xfce4-panel xorg-x11-server-Xvfb xorg-x11-xauth dbus-x11 mesa-libEGL mesa-libGL mesa-libGLU mesa-dri-drivers libXrandr libXScrnSaver gtk3 mesa-libgbm libdrm libXcomposite libXdamage libXfixes' | ||
INSTALL_CMD="dnf install -y ./${PKG_NAME}" | ||
CLEAN_CMD="rm -f \"${PKG_NAME}\"" | ||
elif command -v yum >/dev/null 2>&1; then | ||
PKG_SYS="rpm" | ||
PKG_NAME="rustdesk-${RUSTDESK_VERSION}-${PKG_ARCH}.rpm" | ||
INSTALL_DEPS='yum install -y wget libva libva-intel-driver gstreamer1-plugins-base pipewire xfce4-session xfce4-panel xorg-x11-server-Xvfb xorg-x11-xauth dbus-x11 mesa-libEGL mesa-libGL mesa-libGLU mesa-dri-drivers libXrandr libXScrnSaver gtk3 mesa-libgbm libdrm libXcomposite libXdamage libXfixes' | ||
INSTALL_CMD="yum install -y ./${PKG_NAME}" | ||
CLEAN_CMD="rm -f \"${PKG_NAME}\"" | ||
else | ||
echo "❌ Unsupported distro: need apt, dnf, or yum." | ||
exit 1 | ||
fi | ||
|
||
# ---- install rustdesk if missing ---- | ||
if ! command -v rustdesk >/dev/null 2>&1; then | ||
printf "📦 Installing dependencies...\n" | ||
sudo bash -c "$INSTALL_DEPS" 2>&1 | tee -a "${LOG_PATH}" | ||
|
||
printf "⬇️ Downloading RustDesk ${RUSTDESK_VERSION} (${PKG_SYS}, ${PKG_ARCH})...\n" | ||
URL="https://github.com/rustdesk/rustdesk/releases/download/${RUSTDESK_VERSION}/${PKG_NAME}" | ||
wget -q "$URL" 2>&1 | tee -a "${LOG_PATH}" | ||
|
||
printf "🔧 Installing RustDesk...\n" | ||
sudo bash -c "$INSTALL_CMD" 2>&1 | tee -a "${LOG_PATH}" | ||
|
||
printf "🧹 Cleaning up...\n" | ||
bash -c "$CLEAN_CMD" 2>&1 | tee -a "${LOG_PATH}" | ||
else | ||
printf "✅ RustDesk already installed\n" | ||
fi | ||
|
||
# ---- start virtual display ---- | ||
echo "Starting Xvfb with resolution ${XVFB_RESOLUTION}..." | ||
Xvfb :99 -screen 0 "${XVFB_RESOLUTION}" >>"${LOG_PATH}" 2>&1 & | ||
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 | ||
|
||
# ---- create (or accept) password and start rustdesk ---- | ||
if [[ -z "${RUSTDESK_PASSWORD}" ]]; then | ||
RUSTDESK_PASSWORD="$(tr -dc 'a-zA-Z0-9@' </dev/urandom | head -c 10)@97" | ||
fi | ||
|
||
echo "Starting XFCE desktop environment..." | ||
xfce4-session >>"${LOG_PATH}" 2>&1 & | ||
|
||
echo "Waiting for xfce4-session to initialize..." | ||
sleep 5 | ||
|
||
printf "🔐 Setting RustDesk password and starting service...\n" | ||
rustdesk >>"${LOG_PATH}" 2>&1 & | ||
sleep 2 | ||
|
||
rustdesk --password "${RUSTDESK_PASSWORD}" >>"${LOG_PATH}" 2>&1 & | ||
sleep 3 | ||
|
||
RID="$(rustdesk --get-id 2>/dev/null || echo 'ID_PENDING')" | ||
|
||
printf "🥳 RustDesk setup complete!\n\n" | ||
printf "${BOLD}📋 Connection Details:${RESET}\n" | ||
printf " RustDesk ID: ${RID}\n" | ||
printf " RustDesk Password: ${RUSTDESK_PASSWORD}\n" | ||
printf " Display: ${DISPLAY} (${XVFB_RESOLUTION})\n" | ||
printf "\n📝 Logs available at: ${LOG_PATH}\n\n" | ||
|
||
echo "Setup script completed successfully. All services running in background." | ||
exit 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.