Skip to content

Instantly share code, notes, and snippets.

@evilbunny2008
Forked from R0GGER/README.md
Last active October 1, 2025 09:42
Show Gist options
  • Save evilbunny2008/f105cd959b6477d89977217319dca2c8 to your computer and use it in GitHub Desktop.
Save evilbunny2008/f105cd959b6477d89977217319dca2c8 to your computer and use it in GitHub Desktop.
Rustdesk - install oneliner

RustDesk Installation Script

This script provides an easy way to install and uninstall RustDesk on Debian-based Linux systems (Ubuntu, Linux Mint, etc.).

Features

  • Automatic detection of the latest RustDesk version
  • Architecture detection (x86_64, aarch64, etc.)
  • Handles all dependencies
  • Supports both install and uninstall

Requirements

  • Debian-based Linux system
  • Root privileges (sudo)
  • Internet connection

Usage

Install

To install the latest version of RustDesk, run:

wget -q -O /tmp/rustdesk-update.sh https://gist.github.com/evilbunny2008/f105cd959b6477d89977217319dca2c8/raw/a86357335adcbdb0290be3345078ae769838453d/rustdesk-update.sh
chmod +x /tmp/rustdesk-update.sh
/tmp/rustdesk-update.sh
rm -f /tmp/rustdesk-update.sh

Uninstall

To remove RustDesk from your system, run:

wget -q -O /tmp/rustdesk-update.sh https://gist.github.com/evilbunny2008/f105cd959b6477d89977217319dca2c8/raw/a86357335adcbdb0290be3345078ae769838453d/rustdesk-update.sh
chmod +x /tmp/rustdesk-update.sh
/tmp/rustdesk-update.sh -a uninstall
rm -f /tmp/rustdesk-update.sh

What the script does

Install:

  1. Checks for root privileges
  2. Fetches the latest RustDesk version from GitHub
  3. Installs required dependencies
  4. Downloads and installs the RustDesk package
  5. Cleans up temporary files

Uninstall:

  1. Removes RustDesk package
  2. Removes any unused dependencies

Support

For RustDesk related issues, please visit the RustDesk GitHub repository.

Changes to this forked copy - Applied some minor tweaks

  • Credit for the original rustdesk.sh
  • Now checks to see if RustDesk is installed, so the script doesn't blindly try to unistall something not installed
  • Only install if the local version is older than the GitHub version, or isn't installed.
  • When run by a user account the script will install the rustdesk.desktop file to ~/.local/share/applications/ to force a menu refresh.
  • Not all systems have, or need, gnome-menus installed, removed from list of packages to be installed before installing RustDesk
#!/bin/bash
USERID=""
ACTION=""
if [ "$EUID" -ne 0 ]; then
USERID="$EUID"
fi
# Parse options
while getopts "u:a:" opt; do
case "$opt" in
u) USERID="$OPTARG" ;;
a) ACTION="$OPTARG" ;;
esac
done
if [ "$ACTION" != "" ]; then
if [ "${ACTION,,}" != "uninstall" ]; then
echo "Usage: $0 [-a uninstall] [-u <userid>]"
exit 0
else
ACTION="uninstall"
fi
fi
echo "EUID: $EUID"
echo "UserID: $USERID"
echo "Action: $ACTION"
# If not run by root, restart the script with sudo
if [ "$EUID" -gt 0 ]; then
echo "Requesting sudo privileges for userid=$USERID..."
CMD=""
[ "$ACTION" = "uninstall" ] && CMD="-a uninstall"
echo "Re-run the script: $0 $CMD -u $USERID"
exec sudo "$0" -u "$USERID" $CMD
exit $?
fi
echo "Check if script was passed a USERID or not"
USERID="${USERID:-0}"
if [ "$USERID" != "0" ]; then
GROUPID=$(id -g "$USERID")
HOME_DIR=$(getent passwd "$USERID" | cut -d: -f6)
SOURCE_FILE="/usr/share/applications/rustdesk.desktop"
TARGET_FILE="$HOME_DIR/.local/share/applications/rustdesk.desktop"
TARGET_DIR=$(dirname "$TARGET_FILE")
fi
echo "Check to see if RustDesk is installed, and if it is get it's version from dpkg"
INSTALLED=$(dpkg-query -W -f='${Version}' rustdesk 2>/dev/null || echo "none")
echo "Local Ver: $INSTALLED"
# Check for uninstall parameter
if [ "$ACTION" = "uninstall" ]; then
if [ "$INSTALLED" != "none" ]; then
echo "Uninstalling RustDesk..."
apt purge -y rustdesk
apt autoremove -y
# If run by a user, clean up the .desktop file
if [ "$USERID" != "0" ] && [ -d "$TARGET_DIR" ] && [ -f "$TARGET_FILE" ]; then
echo "Deleting $TARGET_FILE..."
rm "$TARGET_FILE"
fi
echo "RustDesk $INSTALLED has been successfully uninstalled from your system!"
else
echo "RustDesk isn't installed, so nothing to uninstall"
fi
exit 0
else
packages=(libxdo3 desktop-file-utils hicolor-icon-theme)
for pkg in "${packages[@]}"; do
if ! dpkg -s "$pkg" >/dev/null 2>&1; then
echo "Installing RustDesk dependency $pkg..."
apt install -y "$pkg"
fi
done
fi
# Get the current RustDesk version number from GitHub
ARCH=$(uname -m)
GITHUB_VERSION=$(wget -q -O - https://api.github.com/repos/rustdesk/rustdesk/releases/latest | grep -Po '"tag_name": "\K.*?(?=")' | tr -d '\n' || echo -n "1.4.2")
echo "GitHub Ver: $GITHUB_VERSION"
# Check the local version number against the GitHub version
if [ "$INSTALLED" = "none" ]; then
echo "RustDesk is not installed. Installing $GITHUB_VERSION..."
elif [ "$INSTALLED" = "$GITHUB_VERSION" ]; then
echo "Your system is already up to date..."
exit 0
else
NEWER=$(printf "%s\n%s" "$INSTALLED" "$GITHUB_VERSION" | sort -V | tail -n1)
if [ "$NEWER" != "$INSTALLED" ]; then
echo "An upgrade is available ($INSTALLED → $GITHUB_VERSION)..."
else
echo "Installed version ($INSTALLED) is newer than GitHub version ($GITHUB_VERSION), won't downgrade local version..."
exit 0
fi
fi
TMP_DEB="/tmp/rustdesk.deb"
URL="https://github.com/rustdesk/rustdesk/releases/download/${GITHUB_VERSION}/rustdesk-${GITHUB_VERSION}-${ARCH}.deb"
# Download RustDesk
echo "Downloading RustDesk..."
wget -q -O "$TMP_DEB" "$URL"
# Install RustDesk
echo "Installing RustDesk..."
dpkg -i "$TMP_DEB"
# Fix any potential dependency issues
apt -y -f install
# Clean up
rm -f "$TMP_DEB"
# If triggered by a user account copy rustdesk.desktop to local menu directory
if [ "$USERID" != "0" ]; then
echo "Copying rustdesk.desktop for userid=$USERID..."
if [ ! -d "$TARGET_DIR" ]; then
mkdir -p "$TARGET_DIR"
fi
cp "$SOURCE_FILE" "$TARGET_FILE"
chown "$USERID:$GROUPID" "$TARGET_FILE"
chmod +x "$TARGET_FILE"
else
echo "Skipping installation of a user rustdesk.desktop file since the script was started by root..."
fi
echo "RustDesk $GITHUB_VERSION has been successfully installed! You can now start RustDesk from your applications menu."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment