├── clientinstall.ps1 ├── LICENSE ├── uninstall.sh ├── windowsclientID.ps1 ├── Readme.md ├── linuxclientinstall.sh ├── WindowsAgentAIOInstall.ps1 ├── update.sh └── install.sh /clientinstall.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference= 'silentlycontinue' 2 | 3 | If (!(test-path "c:\temp")) { 4 | New-Item -ItemType Directory -Force -Path "c:\temp" 5 | } 6 | cd c:\temp 7 | 8 | If (!(test-path "C:\Program Files\Rustdesk\RustDesk.exe")) { 9 | cd c:\temp 10 | 11 | Invoke-WebRequest https://github.com/rustdesk/rustdesk/releases/download/1.1.9/rustdesk-1.1.9-windows_x64.zip -Outfile rustdesk.zip 12 | 13 | expand-archive rustdesk.zip 14 | cd rustdesk 15 | start .\rustdesk-1.1.9-putes.exe --silent-install 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 dinger1986 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Stopping and disabling RustDesk services..." 4 | 5 | # Stop and disable services 6 | sudo systemctl stop rustdesksignal.service 2>/dev/null 7 | sudo systemctl stop rustdeskrelay.service 2>/dev/null 8 | sudo systemctl stop gohttpserver.service 2>/dev/null 9 | 10 | sudo systemctl disable rustdesksignal.service 2>/dev/null 11 | sudo systemctl disable rustdeskrelay.service 2>/dev/null 12 | sudo systemctl disable gohttpserver.service 2>/dev/null 13 | 14 | # Remove service files 15 | sudo rm -f /etc/systemd/system/rustdesksignal.service 16 | sudo rm -f /etc/systemd/system/rustdeskrelay.service 17 | sudo rm -f /etc/systemd/system/gohttpserver.service 18 | 19 | # Reload systemd 20 | sudo systemctl daemon-reload 21 | 22 | echo "Removing RustDesk binaries and logs..." 23 | 24 | # Remove binaries and logs 25 | sudo rm -rf /opt/rustdesk 26 | sudo rm -rf /var/log/rustdesk 27 | 28 | # Remove gohttp server and logs (if used) 29 | sudo rm -rf /opt/gohttp 30 | sudo rm -rf /var/log/gohttp 31 | 32 | echo "RustDesk server and optional HTTP service have been removed." 33 | echo "Don't forget to clean up any firewall/NAT rules if needed." 34 | -------------------------------------------------------------------------------- /windowsclientID.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference= 'silentlycontinue' 2 | # Get RustDesk ID 3 | 4 | If (!("C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk.toml")) { 5 | $username = ((Get-WMIObject -ClassName Win32_ComputerSystem).Username).Split('\')[1] 6 | $rustid=(Get-content C:\Users\$username\AppData\Roaming\RustDesk\config\RustDesk.toml | Where-Object { $_.Contains("id") }) 7 | $rustid = $rustid.Split("'")[1] 8 | $rustpword = (Get-content C:\Users\$username\AppData\Roaming\RustDesk\config\RustDesk.toml | Where-Object { $_.Contains("password") }) 9 | $rustpword = $rustpword.Split("'")[1] 10 | Write-output "Config file found in user folder" 11 | Write-output "$rustid" 12 | Write-output "$rustpword" 13 | } 14 | else { 15 | $rustid=(Get-content C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk.toml | Where-Object { $_.Contains("id") }) 16 | $rustid = $rustid.Split("'")[1] 17 | $rustpword = (Get-content C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk.toml | Where-Object { $_.Contains("password") }) 18 | $rustpword = $rustpword.Split("'")[1] 19 | Write-output "Config file found in windows service folder" 20 | Write-output "$rustid" 21 | Write-output "$rustpword" 22 | } 23 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Rustdesk server Install Script 2 | Easy install Script for Rustdesk on linux, should work on any 64bit (32bit arm will install rustdesk server only) debian or centos based system supporting systemd.
3 | For Rustdesk visit https://rustdesk.com 4 | 5 | You can use Hetzner to test this with a $20 credit using this referal code https://hetzner.cloud/?ref=p6iUr7jEXmoB 6 | 7 | We provide professional hosting and support for RustDesk OSS and RustDesk Pro, please email hello@techahold.com if you need assistance. 8 | 9 | # How to Install the server 10 | Please setup your firewall on your server prior to running the script. 11 | 12 | Make sure you have got access via ssh or otherwise setup prior setting up the firewall, command for UFW is: 13 | ``` 14 | ufw allow proto tcp from YOURIP to any port 22 15 | ``` 16 | 17 | If you have UFW installed use the following commands (you only need port 8000 if you are using the preconfigured install files): 18 | ``` 19 | ufw allow 21115:21119/tcp 20 | ufw allow 8000/tcp 21 | ufw allow 21116/udp 22 | sudo ufw enable 23 | ``` 24 | 25 | Run the following commands: 26 | ``` 27 | wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/install.sh 28 | chmod +x install.sh 29 | ./install.sh 30 | ``` 31 | 32 | Choose your preferences from the options given in the script. 33 | 34 | ***Please Note:*** 35 | If you allow the script to create preconfigured install files (with your IP/DNS and key set) it will install gohttpserver using port 8000 for you to easily download the install scripts. 36 | 37 | # How to update the server 38 | 39 | Run the following commands: 40 | ``` 41 | wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/update.sh 42 | chmod +x update.sh 43 | ./update.sh 44 | ``` 45 | 46 | # Rustdesk windows powershell install script 47 | Generates a powershell script for install grabbing WAN IP and Key currently in /opt/rustdesk but will be moved to a web url for easy deployment. 48 | 49 | # Tips 50 | 51 | If you want to restart the services use the following commands: 52 | ``` 53 | sudo systemctl restart rustdesksignal 54 | sudo systemctl restart rustdeskrelay 55 | ``` 56 | -------------------------------------------------------------------------------- /linuxclientinstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Assign a random value to the password variable 4 | rustdesk_pw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1) 5 | 6 | # Get your config string from your Web portal and Fill Below 7 | rustdesk_cfg="secure-string" 8 | 9 | ################################### Please Do Not Edit Below This Line ######################################### 10 | 11 | # Check if the script is being run as root 12 | if [[ $EUID -ne 0 ]]; then 13 | echo "This script must be run as root." 14 | exit 1 15 | fi 16 | 17 | # Identify OS 18 | if [ -f /etc/os-release ]; then 19 | # freedesktop.org and systemd 20 | . /etc/os-release 21 | OS=$NAME 22 | VER=$VERSION_ID 23 | 24 | UPSTREAM_ID=${ID_LIKE,,} 25 | 26 | # Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian' 27 | if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then 28 | UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" 29 | fi 30 | 31 | elif type lsb_release >/dev/null 2>&1; then 32 | # linuxbase.org 33 | OS=$(lsb_release -si) 34 | VER=$(lsb_release -sr) 35 | elif [ -f /etc/lsb-release ]; then 36 | # For some versions of Debian/Ubuntu without lsb_release command 37 | . /etc/lsb-release 38 | OS=$DISTRIB_ID 39 | VER=$DISTRIB_RELEASE 40 | elif [ -f /etc/debian_version ]; then 41 | # Older Debian, Ubuntu, etc. 42 | OS=Debian 43 | VER=$(cat /etc/debian_version) 44 | elif [ -f /etc/SuSE-release ]; then 45 | # Older SuSE etc. 46 | OS=SuSE 47 | VER=$(cat /etc/SuSE-release) 48 | elif [ -f /etc/redhat-release ]; then 49 | # Older Red Hat, CentOS, etc. 50 | OS=RedHat 51 | VER=$(cat /etc/redhat-release) 52 | else 53 | # Fall back to uname, e.g. "Linux ", also works for BSD, etc. 54 | OS=$(uname -s) 55 | VER=$(uname -r) 56 | fi 57 | 58 | # Checks the latest version of RustDesk 59 | RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk/releases/latest -s | grep "tag_name" | awk -F'"' '{print $4}') 60 | 61 | # Install RustDesk 62 | 63 | echo "Installing RustDesk" 64 | if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then 65 | wget https://github.com/rustdesk/rustdesk/releases/download/${RDLATEST}/rustdesk-${RDLATEST}-x86_64.deb 66 | apt-get install -fy ./rustdesk-${RDLATEST}-x86_64.deb >/dev/null 67 | elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "$OS" = "Fedora Linux" ] || [ "${UPSTREAM_ID}" = "rhel" ]; then 68 | wget https://github.com/rustdesk/rustdesk/releases/download/${RDLATEST}/rustdesk-${RDLATEST}.x86_64.rpm 69 | yum localinstall ./rustdesk-${RDLATEST}.x86_64.rpm -y >/dev/null 70 | elif [ "${UPSTREAM_ID}" = "suse" ]; then 71 | wget https://github.com/rustdesk/rustdesk/releases/download/${RDLATEST}/rustdesk-${RDLATEST}.x86_64-suse.rpm 72 | zypper -n install --allow-unsigned-rpm ./rustdesk-${RDLATEST}.x86_64-suse.rpm >/dev/null 73 | else 74 | echo "Unsupported OS" 75 | # here you could ask the user for permission to try and install anyway 76 | # if they say yes, then do the install 77 | # if they say no, exit the script 78 | exit 1 79 | fi 80 | 81 | # Run the rustdesk command with --get-id and store the output in the rustdesk_id variable 82 | rustdesk_id=$(rustdesk --get-id) 83 | 84 | # Apply new password to RustDesk 85 | rustdesk --password $rustdesk_pw &> /dev/null 86 | 87 | rustdesk --config $rustdesk_cfg 88 | 89 | systemctl restart rustdesk 90 | 91 | echo "All done! Please double check the Network settings tab in RustDesk." 92 | echo "" 93 | echo "..............................................." 94 | # Check if the rustdesk_id is not empty 95 | if [ -n "$rustdesk_id" ]; then 96 | echo "RustDesk ID: $rustdesk_id" 97 | else 98 | echo "Failed to get RustDesk ID." 99 | fi 100 | 101 | # Echo the value of the password variable 102 | echo "Password: $rustdesk_pw" 103 | echo "..............................................." 104 | -------------------------------------------------------------------------------- /WindowsAgentAIOInstall.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference= 'silentlycontinue' 2 | 3 | # Assign the value random password to the password variable 4 | $rustdesk_pw=(-join ((65..90) + (97..122) | Get-Random -Count 12 | % {[char]$_})) 5 | 6 | # Get your config string from your Web portal and Fill Below 7 | $rustdesk_cfg="secure-string" 8 | 9 | ################################### Please Do Not Edit Below This Line ######################################### 10 | 11 | # Run as administrator and stays in the current directory 12 | if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { 13 | if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { 14 | Start-Process PowerShell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`""; 15 | Exit; 16 | } 17 | } 18 | 19 | # Checks for the latest version of RustDesk 20 | $url = 'https://www.github.com//rustdesk/rustdesk/releases/latest' 21 | $request = [System.Net.WebRequest]::Create($url) 22 | $response = $request.GetResponse() 23 | $realTagUrl = $response.ResponseUri.OriginalString 24 | $RDLATEST = $realTagUrl.split('/')[-1].Trim('v') 25 | echo "RustDesk $RDLATEST is the latest version." 26 | 27 | # Checks the version of RustDesk installed. 28 | $rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version) 29 | 30 | # Skips to inputting the configuration if the latest version of RustDesk is already installed. 31 | if($rdver -eq "$RDLATEST") { 32 | echo "RustDesk $rdver is already installed." 33 | cd $env:ProgramFiles\RustDesk 34 | echo "Inputting configuration now." 35 | .\rustdesk.exe --config $rustdesk_cfg 36 | .\rustdesk.exe --password $rustdesk_pw 37 | $rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id 38 | echo "All done! Please double check the Network settings tab in RustDesk." 39 | echo "" 40 | echo "..............................................." 41 | # Show the value of the ID Variable 42 | echo "RustDesk ID: $rustdesk_id" 43 | 44 | # Show the value of the Password Variable 45 | echo "Password: $rustdesk_pw" 46 | echo "..............................................." 47 | echo "" 48 | echo "Press Enter to open RustDesk." 49 | pause 50 | .\rustdesk.exe 51 | exit 52 | } 53 | 54 | if (!(Test-Path C:\Temp)) { 55 | New-Item -ItemType Directory -Force -Path C:\Temp > null 56 | } 57 | 58 | cd C:\Temp 59 | echo "Downloading RustDesk version $RDLATEST." 60 | powershell Invoke-WebRequest "https://github.com/rustdesk/rustdesk/releases/download/$RDLATEST/rustdesk-$RDLATEST-x86_64.exe" -Outfile "rustdesk.exe" 61 | echo "Installing RustDesk version $RDLATEST." 62 | Start-Process .\rustdesk.exe --silent-install 63 | Start-Sleep -Seconds 10 64 | 65 | $ServiceName = 'rustdesk' 66 | $arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue 67 | 68 | if ($arrService -eq $null) 69 | { 70 | echo "Installing service." 71 | cd $env:ProgramFiles\RustDesk 72 | Start-Process .\rustdesk.exe --install-service -wait -Verbose 73 | Start-Sleep -Seconds 20 74 | } 75 | 76 | while ($arrService.Status -ne 'Running') 77 | { 78 | Start-Service $ServiceName 79 | Start-Sleep -seconds 5 80 | $arrService.Refresh() 81 | } 82 | 83 | # Waits for installation to complete before proceeding. 84 | echo "Please wait a few seconds." 85 | Start-Sleep -Seconds 10 86 | 87 | cd $env:ProgramFiles\RustDesk 88 | echo "Inputting configuration now." 89 | .\rustdesk.exe --config $rustdesk_cfg 90 | .\rustdesk.exe --password $rustdesk_pw 91 | $rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id 92 | echo "All done! Please double check the Network settings tab in RustDesk." 93 | echo "" 94 | echo "..............................................." 95 | # Show the value of the ID Variable 96 | echo "RustDesk ID: $rustdesk_id" 97 | 98 | # Show the value of the Password Variable 99 | echo "Password: $rustdesk_pw" 100 | echo "..............................................." 101 | echo "" 102 | echo "Press Enter to open RustDesk." 103 | pause 104 | .\rustdesk.exe 105 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get Username 4 | uname=$(whoami) # not used btw .. yet 5 | 6 | # Get current release version 7 | RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server/releases/latest -s | grep "tag_name" | awk -F'"' '{print $4}') 8 | RDCURRENT=$(/opt/rustdesk/hbbr --version | sed -r 's/hbbr (.*)/\1/') 9 | 10 | if [ $RDLATEST == $RDCURRENT ]; then 11 | echo "Same version no need to update." 12 | exit 0 13 | fi 14 | 15 | sudo systemctl stop gohttpserver.service 16 | sudo systemctl stop rustdesksignal.service 17 | sudo systemctl stop rustdeskrelay.service 18 | 19 | ARCH=$(uname -m) 20 | 21 | # identify OS 22 | if [ -f /etc/os-release ]; then 23 | # freedesktop.org and systemd 24 | . /etc/os-release 25 | OS=$NAME 26 | VER=$VERSION_ID 27 | UPSTREAM_ID=${ID_LIKE,,} 28 | # Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian' 29 | if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then 30 | UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" 31 | fi 32 | 33 | elif type lsb_release >/dev/null 2>&1; then 34 | # linuxbase.org 35 | OS=$(lsb_release -si) 36 | VER=$(lsb_release -sr) 37 | elif [ -f /etc/lsb-release ]; then 38 | # For some versions of Debian/Ubuntu without lsb_release command 39 | . /etc/lsb-release 40 | OS=$DISTRIB_ID 41 | VER=$DISTRIB_RELEASE 42 | elif [ -f /etc/debian_version ]; then 43 | # Older Debian/Ubuntu/etc. 44 | OS=Debian 45 | VER=$(cat /etc/debian_version) 46 | elif [ -f /etc/SuSe-release ]; then 47 | # Older SuSE/etc. 48 | OS=SuSE 49 | VER=$(cat /etc/SuSe-release) 50 | elif [ -f /etc/redhat-release ]; then 51 | # Older Red Hat, CentOS, etc. 52 | OS=RedHat 53 | VER=$(cat /etc/redhat-release) 54 | else 55 | # Fall back to uname, e.g. "Linux ", also works for BSD, etc. 56 | OS=$(uname -s) 57 | VER=$(uname -r) 58 | fi 59 | 60 | 61 | # output ebugging info if $DEBUG set 62 | if [ "$DEBUG" = "true" ]; then 63 | echo "OS: $OS" 64 | echo "VER: $VER" 65 | echo "UPSTREAM_ID: $UPSTREAM_ID" 66 | exit 0 67 | fi 68 | 69 | 70 | # Setup prereqs for server 71 | # common named prereqs 72 | PREREQ="curl wget unzip tar" 73 | PREREQDEB="dnsutils" 74 | PREREQRPM="bind-utils" 75 | 76 | echo "Installing prerequisites" 77 | if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then 78 | sudo apt-get update 79 | sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git 80 | elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then 81 | # opensuse 15.4 fails to run the relay service and hangs waiting for it 82 | # needs more work before it can be enabled 83 | # || [ "${UPSTREAM_ID}" = "suse" ] 84 | sudo yum update -y 85 | sudo yum install -y ${PREREQ} ${PREREQRPM} # git 86 | elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then 87 | sudo pacman -Syu 88 | sudo pacman -S ${PREREQ} ${PREREQARCH} 89 | else 90 | echo "Unsupported OS" 91 | # here you could ask the user for permission to try and install anyway 92 | # if they say yes, then do the install 93 | # if they say no, exit the script 94 | exit 1 95 | fi 96 | 97 | 98 | if ! [ -e /opt/rustdesk ]; then 99 | echo "No directory /opt/rustdesk found. No update of rustdesk possible (used install.sh script ?) " 100 | exit 4 101 | else 102 | : 103 | fi 104 | 105 | cd /opt/rustdesk/ 106 | 107 | # remove any previous zip files 108 | rm *.zip 109 | 110 | echo "Upgrading Rustdesk Server" 111 | if [ "${ARCH}" = "x86_64" ] ; then 112 | wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-amd64.zip" 113 | unzip -j -o rustdesk-server-linux-amd64.zip "amd64/*" -d "/opt/rustdesk/" 114 | elif [ "${ARCH}" = "armv7l" ] ; then 115 | wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-armv7.zip" 116 | unzip -j -o rustdesk-server-linux-armv7.zip "armv7/*" -d "/opt/rustdesk/" 117 | elif [ "${ARCH}" = "aarch64" ] ; then 118 | wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8.zip" 119 | unzip -j -o rustdesk-server-linux-arm64v8.zip "arm64v8/*" -d "/opt/rustdesk/" 120 | fi 121 | 122 | sudo systemctl start rustdesksignal.service 123 | sudo systemctl start rustdeskrelay.service 124 | 125 | while ! [[ $CHECK_RUSTDESK_READY ]]; do 126 | CHECK_RUSTDESK_READY=$(sudo systemctl status rustdeskrelay.service | grep "Active: active (running)") 127 | echo -ne "Rustdesk Relay not ready yet...${NC}\n" 128 | sleep 3 129 | done 130 | 131 | # chk if gotthp exists 132 | 133 | if ! [ -e /opt/gohttp ]; then 134 | echo "No directory /opt/gohttp found. No update of gothhtp necessary." 135 | exit 4 136 | else 137 | : 138 | fi 139 | 140 | cd /opt/gohttp 141 | GOHTTPLATEST=$(curl https://api.github.com/repos/codeskyblue/gohttpserver/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') 142 | if [ "${ARCH}" = "x86_64" ] ; then 143 | wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz" 144 | tar -xf gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz 145 | elif [ "${ARCH}" = "aarch64" ] ; then 146 | wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_arm64.tar.gz" 147 | tar -xf gohttpserver_${GOHTTPLATEST}_linux_arm64.tar.gz 148 | elif [ "${ARCH}" = "armv7l" ] ; then 149 | echo "Go HTTP Server not supported on 32bit ARM devices" 150 | exit 1 151 | fi 152 | 153 | sudo systemctl start gohttpserver.service 154 | 155 | echo -e "Updates are complete" 156 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get user options 4 | while getopts i:-: option; do 5 | case "${option}" in 6 | -) 7 | case "${OPTARG}" in 8 | help) 9 | help="true";; 10 | resolveip) 11 | resolveip="true";; 12 | resolvedns) 13 | val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 )) 14 | resolvedns=${val};; 15 | install-http) 16 | http="true";; 17 | skip-http) 18 | http="false";; 19 | no-sudo) 20 | usesudo="false";; 21 | esac;; 22 | i) resolveip="true";; 23 | esac 24 | done 25 | 26 | function displayhelp() { 27 | if [[ ! -z $help ]]; then 28 | echo 'usage: install.sh --resolveip --resolvedns "fqdn"' 29 | echo "options:" 30 | echo "--resolveip Use IP for server name. Cannot use in combination with --resolvedns or -d" 31 | echo '--resolvedns "fqdn" Use FQDN for server name. Cannot use in combination with --resolveip or -i' 32 | echo "--install-http Install http server to host installation scripts. Cannot use in combination with --skip-http or -n" 33 | echo "--skip-http Skip installation of http server. Cannot use in combination with --install-http or -h" 34 | echo "--no-sudo Do not use sudo for commands. If sudo is not installed, it will be ignored automatically." 35 | exit 0 36 | fi 37 | } 38 | displayhelp 39 | 40 | # Default: use sudo unless --no-sudo is specified 41 | usesudo="${usesudo:-true}" 42 | 43 | # Check if sudo is available and wanted 44 | if [[ "$usesudo" == "true" ]]; then 45 | if command -v sudo &>/dev/null; then 46 | SUDO="sudo" 47 | echo "sudo detected and will be used." 48 | else 49 | echo "sudo not found. Switching to no-sudo mode." 50 | SUDO="" 51 | echo "Some installation steps may fail if run without root privileges." 52 | fi 53 | else 54 | SUDO="" 55 | echo "Running in no-sudo mode." 56 | echo "Some installation steps may fail if run without root privileges." 57 | fi 58 | 59 | # Get Username 60 | uname=$(whoami) 61 | gname=$(id -gn ${uname}) 62 | admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16) 63 | 64 | ARCH=$(uname -m) 65 | 66 | # identify OS 67 | if [ -f /etc/os-release ]; then 68 | # freedesktop.org and systemd 69 | . /etc/os-release 70 | OS=$NAME 71 | VER=$VERSION_ID 72 | 73 | UPSTREAM_ID=${ID_LIKE,,} 74 | 75 | # Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian' 76 | if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then 77 | UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" 78 | fi 79 | 80 | 81 | elif type lsb_release >/dev/null 2>&1; then 82 | # linuxbase.org 83 | OS=$(lsb_release -si) 84 | VER=$(lsb_release -sr) 85 | elif [ -f /etc/lsb-release ]; then 86 | # For some versions of Debian/Ubuntu without lsb_release command 87 | . /etc/lsb-release 88 | OS=$DISTRIB_ID 89 | VER=$DISTRIB_RELEASE 90 | elif [ -f /etc/debian_version ]; then 91 | # Older Debian/Ubuntu/etc. 92 | OS=Debian 93 | VER=$(cat /etc/debian_version) 94 | elif [ -f /etc/SuSe-release ]; then 95 | # Older SuSE/etc. 96 | OS=SuSE 97 | VER=$(cat /etc/SuSe-release) 98 | elif [ -f /etc/redhat-release ]; then 99 | # Older Red Hat, CentOS, etc. 100 | OS=RedHat 101 | VER=$(cat /etc/redhat-release) 102 | else 103 | # Fall back to uname, e.g. "Linux ", also works for BSD, etc. 104 | OS=$(uname -s) 105 | VER=$(uname -r) 106 | fi 107 | 108 | 109 | # output debugging info if $DEBUG set 110 | if [ "$DEBUG" = "true" ]; then 111 | echo "OS: $OS" 112 | echo "VER: $VER" 113 | echo "UPSTREAM_ID: $UPSTREAM_ID" 114 | exit 0 115 | fi 116 | 117 | # Setup prereqs for server 118 | # common named prereqs 119 | PREREQ="curl wget unzip tar" 120 | PREREQDEB="dnsutils" 121 | PREREQRPM="bind-utils" 122 | PREREQARCH="bind" 123 | 124 | echo "Installing prerequisites" 125 | if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then 126 | $SUDO apt-get update 127 | $SUDO apt-get install -y ${PREREQ} ${PREREQDEB} # git 128 | elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then 129 | # opensuse 15.4 fails to run the relay service and hangs waiting for it 130 | # needs more work before it can be enabled 131 | # || [ "${UPSTREAM_ID}" = "suse" ] 132 | $SUDO yum update -y 133 | $SUDO yum install -y ${PREREQ} ${PREREQRPM} # git 134 | elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then 135 | $SUDO pacman -Syu 136 | $SUDO pacman -S ${PREREQ} ${PREREQARCH} 137 | else 138 | echo "Unsupported OS" 139 | # give them the option to continue 140 | echo -n "Would you like to continue? Dependencies may not be satisfied... [y/n] " 141 | read continue_no_dependencies 142 | if [ $continue_no_dependencies == "y" ]; then 143 | echo "Continuing..." 144 | elif [ $continue_no_dependencies != "n" ]; then 145 | echo "Invalid answer, exiting." 146 | exit 1 147 | else 148 | exit 1 149 | fi 150 | fi 151 | 152 | # Choice for DNS or IP 153 | if [[ -z "$resolveip" && -z "$resolvedns" ]]; then 154 | PS3='Choose your preferred connection method: auto-resolve current WAN IP or enter your DNS/Domain:' 155 | WAN=("IP" "DNS/Domain") 156 | select WANOPT in "${WAN[@]}"; do 157 | case $WANOPT in 158 | "IP") 159 | wanip=$(dig @resolver4.opendns.com myip.opendns.com +short) 160 | break 161 | ;; 162 | 163 | "DNS/Domain") 164 | echo -ne "Enter your preferred domain/dns address ${NC}: " 165 | read wanip 166 | #check wanip is valid domain 167 | if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then 168 | echo -e "${RED}Invalid domain/dns address${NC}" 169 | exit 1 170 | fi 171 | break 172 | ;; 173 | *) echo "invalid option $REPLY";; 174 | esac 175 | done 176 | elif [[ ! -z "$resolveip" && ! -z "$resolvedns" ]]; then 177 | echo -e "\nERROR: You cannot use both --resolveip & --resolvedns options simultaneously" 178 | exit 1 179 | elif [[ ! -z "$resolveip" && -z "$resolvedns" ]]; then 180 | wanip=$(dig @resolver4.opendns.com myip.opendns.com +short) 181 | elif [[ -z "$resolveip" && ! -z "$resolvedns" ]]; then 182 | wanip="$resolvedns" 183 | if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then 184 | echo -e "${RED}Invalid domain/dns address${NC}" 185 | exit 1 186 | fi 187 | fi 188 | 189 | # Make Folder /opt/rustdesk/ 190 | if [ ! -d "/opt/rustdesk" ]; then 191 | echo "Creating /opt/rustdesk" 192 | $SUDO mkdir -p /opt/rustdesk/ 193 | fi 194 | $SUDO chown "${uname}" -R /opt/rustdesk 195 | cd /opt/rustdesk/ || exit 1 196 | 197 | 198 | #Download latest version of Rustdesk 199 | RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server/releases/latest -s | grep "tag_name" | awk -F'"' '{print $4}') 200 | 201 | echo "Installing Rustdesk Server" 202 | if [ "${ARCH}" = "x86_64" ] ; then 203 | wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-amd64.zip" 204 | unzip rustdesk-server-linux-amd64.zip 205 | mv amd64/* /opt/rustdesk/ 206 | elif [ "${ARCH}" = "armv7l" ] ; then 207 | wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-armv7.zip" 208 | unzip rustdesk-server-linux-armhf.zip 209 | mv armv7/* /opt/rustdesk/ 210 | elif [ "${ARCH}" = "aarch64" ] ; then 211 | wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8.zip" 212 | unzip rustdesk-server-linux-arm64v8.zip 213 | mv arm64v8/* /opt/rustdesk/ 214 | fi 215 | 216 | chmod +x /opt/rustdesk/hbbs 217 | chmod +x /opt/rustdesk/hbbr 218 | 219 | 220 | # Make Folder /var/log/rustdesk/ 221 | if [ ! -d "/var/log/rustdesk" ]; then 222 | echo "Creating /var/log/rustdesk" 223 | $SUDO mkdir -p /var/log/rustdesk/ 224 | fi 225 | $SUDO chown "${uname}" -R /var/log/rustdesk/ 226 | 227 | # Setup Systemd to launch hbbs 228 | rustdesksignal="$(cat << EOF 229 | [Unit] 230 | Description=Rustdesk Signal Server 231 | [Service] 232 | Type=simple 233 | LimitNOFILE=1000000 234 | ExecStart=/opt/rustdesk/hbbs 235 | WorkingDirectory=/opt/rustdesk/ 236 | User=${uname} 237 | Group=${gname} 238 | Restart=always 239 | StandardOutput=append:/var/log/rustdesk/signalserver.log 240 | StandardError=append:/var/log/rustdesk/signalserver.error 241 | # Restart service after 10 seconds if node service crashes 242 | RestartSec=10 243 | [Install] 244 | WantedBy=multi-user.target 245 | EOF 246 | )" 247 | echo "${rustdesksignal}" | $SUDO tee /etc/systemd/system/rustdesksignal.service > /dev/null 248 | $SUDO systemctl daemon-reload 249 | $SUDO systemctl enable rustdesksignal.service 250 | $SUDO systemctl start rustdesksignal.service 251 | 252 | # Setup Systemd to launch hbbr 253 | rustdeskrelay="$(cat << EOF 254 | [Unit] 255 | Description=Rustdesk Relay Server 256 | [Service] 257 | Type=simple 258 | LimitNOFILE=1000000 259 | ExecStart=/opt/rustdesk/hbbr 260 | WorkingDirectory=/opt/rustdesk/ 261 | User=${uname} 262 | Group=${gname} 263 | Restart=always 264 | StandardOutput=append:/var/log/rustdesk/relayserver.log 265 | StandardError=append:/var/log/rustdesk/relayserver.error 266 | # Restart service after 10 seconds if node service crashes 267 | RestartSec=10 268 | [Install] 269 | WantedBy=multi-user.target 270 | EOF 271 | )" 272 | echo "${rustdeskrelay}" | $SUDO tee /etc/systemd/system/rustdeskrelay.service > /dev/null 273 | $SUDO systemctl daemon-reload 274 | $SUDO systemctl enable rustdeskrelay.service 275 | $SUDO systemctl start rustdeskrelay.service 276 | 277 | while ! [[ $CHECK_RUSTDESK_READY ]]; do 278 | CHECK_RUSTDESK_READY=$($SUDO systemctl status rustdeskrelay.service | grep "Active: active (running)") 279 | echo -ne "Rustdesk Relay not ready yet...${NC}\n" 280 | sleep 3 281 | done 282 | 283 | pubname=$(find /opt/rustdesk -name "*.pub") 284 | key=$(cat "${pubname}") 285 | 286 | echo "Tidying up install" 287 | if [ "${ARCH}" = "x86_64" ] ; then 288 | rm rustdesk-server-linux-amd64.zip 289 | rm -rf amd64 290 | elif [ "${ARCH}" = "armv7l" ] ; then 291 | rm rustdesk-server-linux-armv7.zip 292 | rm -rf armv7 293 | elif [ "${ARCH}" = "aarch64" ] ; then 294 | rm rustdesk-server-linux-arm64v8.zip 295 | rm -rf arm64v8 296 | fi 297 | 298 | echo "Grabbing installers" 299 | string="{\"host\":\"${wanip}\",\"relay\":\"${wanip}\",\"key\":\"${key}\",\"api\":\"https://${wanip}\"}" 300 | string64=$(echo -n "$string" | base64 -w 0 | tr -d '=') 301 | string64rev=$(echo -n "$string64" | rev) 302 | 303 | echo "$string64rev" 304 | 305 | function setuphttp () { 306 | # Create windows install script 307 | wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1 308 | $SUDO sed -i "s|secure-string|${string64rev}|g" WindowsAgentAIOInstall.ps1 309 | 310 | # Create linux install script 311 | wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh 312 | $SUDO sed -i "s|secure-string|${string64rev}|g" linuxclientinstall.sh 313 | 314 | # Download and install gohttpserver 315 | # Make Folder /opt/gohttp/ 316 | if [ ! -d "/opt/gohttp" ]; then 317 | echo "Creating /opt/gohttp" 318 | $SUDO mkdir -p /opt/gohttp/ 319 | $SUDO mkdir -p /opt/gohttp/public 320 | fi 321 | $SUDO chown "${uname}" -R /opt/gohttp 322 | cd /opt/gohttp 323 | GOHTTPLATEST=$(curl https://api.github.com/repos/codeskyblue/gohttpserver/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') 324 | 325 | echo "Installing Go HTTP Server" 326 | if [ "${ARCH}" = "x86_64" ] ; then 327 | wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz" 328 | tar -xf gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz 329 | elif [ "${ARCH}" = "aarch64" ] ; then 330 | wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_arm64.tar.gz" 331 | tar -xf gohttpserver_${GOHTTPLATEST}_linux_arm64.tar.gz 332 | elif [ "${ARCH}" = "armv7l" ] ; then 333 | echo "Go HTTP Server not supported on 32bit ARM devices" 334 | echo -e "Your IP/DNS Address is ${wanip}" 335 | echo -e "Your public key is ${key}" 336 | exit 1 337 | fi 338 | 339 | # Copy Rustdesk install scripts to folder 340 | mv /opt/rustdesk/WindowsAgentAIOInstall.ps1 /opt/gohttp/public/ 341 | mv /opt/rustdesk/linuxclientinstall.sh /opt/gohttp/public/ 342 | 343 | # Make gohttp log folders 344 | if [ ! -d "/var/log/gohttp" ]; then 345 | echo "Creating /var/log/gohttp" 346 | $SUDO mkdir -p /var/log/gohttp/ 347 | fi 348 | $SUDO chown "${uname}" -R /var/log/gohttp/ 349 | 350 | echo "Tidying up Go HTTP Server Install" 351 | if [ "${ARCH}" = "x86_64" ] ; then 352 | rm gohttpserver_"${GOHTTPLATEST}"_linux_amd64.tar.gz 353 | elif [ "${ARCH}" = "armv7l" ] || [ "${ARCH}" = "aarch64" ]; then 354 | rm gohttpserver_"${GOHTTPLATEST}"_linux_arm64.tar.gz 355 | fi 356 | 357 | 358 | # Setup Systemd to launch Go HTTP Server 359 | gohttpserver="$(cat << EOF 360 | [Unit] 361 | Description=Go HTTP Server 362 | [Service] 363 | Type=simple 364 | LimitNOFILE=1000000 365 | ExecStart=/opt/gohttp/gohttpserver -r ./public --port 8000 --auth-type http --auth-http admin:${admintoken} 366 | WorkingDirectory=/opt/gohttp/ 367 | User=${uname} 368 | Group=${gname} 369 | Restart=always 370 | StandardOutput=append:/var/log/gohttp/gohttpserver.log 371 | StandardError=append:/var/log/gohttp/gohttpserver.error 372 | # Restart service after 10 seconds if node service crashes 373 | RestartSec=10 374 | [Install] 375 | WantedBy=multi-user.target 376 | EOF 377 | )" 378 | echo "${gohttpserver}" | $SUDO tee /etc/systemd/system/gohttpserver.service > /dev/null 379 | $SUDO systemctl daemon-reload 380 | $SUDO systemctl enable gohttpserver.service 381 | $SUDO systemctl start gohttpserver.service 382 | 383 | 384 | echo -e "Your IP/DNS Address is ${wanip}" 385 | echo -e "Your public key is ${key}" 386 | echo -e "Install Rustdesk on your machines and change your public key and IP/DNS name to the above" 387 | echo -e "You can access your install scripts for clients by going to http://${wanip}:8000" 388 | echo -e "Username is admin and password is ${admintoken}" 389 | if [[ -z "$http" ]]; then 390 | echo "Press any key to finish install" 391 | while [ true ] ; do 392 | read -t 3 -n 1 393 | if [ $? = 0 ] ; then 394 | exit ; 395 | else 396 | echo "waiting for the keypress" 397 | fi 398 | done 399 | break 400 | fi 401 | } 402 | 403 | # Choice for Extras installed 404 | if [[ -z "$http" ]]; then 405 | PS3='Please choose if you want to download configs and install HTTP server:' 406 | EXTRA=("Yes" "No") 407 | select EXTRAOPT in "${EXTRA[@]}"; do 408 | case $EXTRAOPT in 409 | "Yes") 410 | setuphttp 411 | break 412 | ;; 413 | "No") 414 | echo -e "Your IP/DNS Address is ${wanip}" 415 | echo -e "Your public key is ${key}" 416 | echo -e "Install Rustdesk on your machines and change your public key and IP/DNS name to the above" 417 | 418 | echo -e "You can get a free API with Addressbook etc via https://github.com/infiniteremote/installer" 419 | 420 | echo "Press any key to finish install" 421 | while [ true ] ; do 422 | read -t 3 -n 1 423 | if [ $? = 0 ] ; then 424 | exit ; 425 | else 426 | echo "waiting for the keypress" 427 | fi 428 | done 429 | break 430 | ;; 431 | *) echo "invalid option $REPLY";; 432 | esac 433 | done 434 | elif [ "$http" = "true" ]; then 435 | setuphttp 436 | elif [ "$http" = "false" ]; then 437 | echo -e "Your IP/DNS Address is ${wanip}" 438 | echo -e "Your public key is ${key}" 439 | echo -e "Install Rustdesk on your machines and change your public key and IP/DNS name to the above" 440 | fi 441 | --------------------------------------------------------------------------------