Easy install Script for Rustdesk
at master 113 lines 3.6 kB view raw
1#!/bin/bash 2 3# Get Username 4uname=$(whoami) # not used btw .. yet 5 6sudo systemctl stop gohttpserver.service 7sudo systemctl stop rustdesksignal.service 8sudo systemctl stop rustdeskrelay.service 9 10 11# identify OS 12if [ -f /etc/os-release ]; then 13 # freedesktop.org and systemd 14 . /etc/os-release 15 OS=$NAME 16 VER=$VERSION_ID 17 UPSTREAM_ID=${ID_LIKE,,} 18 # Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian' 19 if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then 20 UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" 21 fi 22 23elif type lsb_release >/dev/null 2>&1; then 24 # linuxbase.org 25 OS=$(lsb_release -si) 26 VER=$(lsb_release -sr) 27elif [ -f /etc/lsb-release ]; then 28 # For some versions of Debian/Ubuntu without lsb_release command 29 . /etc/lsb-release 30 OS=$DISTRIB_ID 31 VER=$DISTRIB_RELEASE 32elif [ -f /etc/debian_version ]; then 33 # Older Debian/Ubuntu/etc. 34 OS=Debian 35 VER=$(cat /etc/debian_version) 36elif [ -f /etc/SuSe-release ]; then 37 # Older SuSE/etc. 38 OS=SuSE 39 VER=$(cat /etc/SuSe-release) 40elif [ -f /etc/redhat-release ]; then 41 # Older Red Hat, CentOS, etc. 42 OS=RedHat 43 VER=$(cat /etc/redhat-release) 44else 45 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc. 46 OS=$(uname -s) 47 VER=$(uname -r) 48fi 49 50 51# output ebugging info if $DEBUG set 52if [ "$DEBUG" = "true" ]; then 53 echo "OS: $OS" 54 echo "VER: $VER" 55 echo "UPSTREAM_ID: $UPSTREAM_ID" 56 exit 0 57fi 58 59 60# Setup prereqs for server 61# common named prereqs 62PREREQ="curl wget unzip tar" 63PREREQDEB="dnsutils" 64PREREQRPM="bind-utils" 65 66echo "Installing prerequisites" 67if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then 68 sudo apt-get update 69 sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git 70elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then 71# opensuse 15.4 fails to run the relay service and hangs waiting for it 72# needs more work before it can be enabled 73# || [ "${UPSTREAM_ID}" = "suse" ] 74 sudo yum update -y 75 sudo yum install -y ${PREREQ} ${PREREQRPM} # git 76else 77 echo "Unsupported OS" 78 # here you could ask the user for permission to try and install anyway 79 # if they say yes, then do the install 80 # if they say no, exit the script 81 exit 1 82fi 83 84cd /opt/rustdesk/ 85 86#Download latest version of Rustdesk 87rm hbbs 88rm hbbs 89RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') 90wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip" 91unzip rustdesk-server-linux-x64.zip 92 93sudo systemctl start rustdesksignal.service 94sudo systemctl start rustdeskrelay.service 95 96while ! [[ $CHECK_RUSTDESK_READY ]]; do 97 CHECK_RUSTDESK_READY=$(sudo systemctl status rustdeskrelay.service | grep "Active: active (running)") 98 echo -ne "Rustdesk Relay not ready yet...${NC}\n" 99 sleep 3 100done 101 102rm rustdesk-server-linux-x64.zip 103 104cd /opt/gohttp 105GOHTTPLATEST=$(curl https://api.github.com/repos/codeskyblue/gohttpserver/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') 106wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz" 107tar -xf gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz 108 109rm gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz 110 111sudo systemctl start gohttpserver.service 112 113echo -e "Updates are complete"