Update convertfromos.sh

This commit is contained in:
Mr-Update 2023-07-18 22:52:00 +02:00 committed by GitHub
parent accdbeb1cd
commit 3081d85284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,33 +1,32 @@
#!/bin/bash #!/bin/bash
# This script will do the following to install RustDesk Server Pro replacing RustDesk Server Opensource # This script will do the following to install RustDesk Server Pro replacing RustDesk Server Open Source
# 1. Disable and removes the old services # 1. Disable and removes the old services
# 2. Install some dependencies # 2. Install some dependencies
# 3. Setup ufw firewall if available # 3. Setup UFW firewall if available
# 4. Create a Folder /var/lib/rustdesk-server and copy the certs here # 4. Create a folder /var/lib/rustdesk-server and copy the certs here
# 5. Download and extract RustDesk Pro Services to the above folder # 5. Download and extract RustDesk Pro Services to the above folder
# 6. Create systemd services for hbbs and hbbr # 6. Create systemd services for hbbs and hbbr
# 7. If you chose Domain, it will install Nginx and certbot, allowing the API to be available on port 443 (https) and get an SSL certificate over port 80, this will autorenew. # 7. If you choose Domain, it will install Nginx and Certbot, allowing the API to be available on port 443 (https) and get an SSL certificate over port 80, it is automatically renewed
# Get Username # Get username
uname=$(whoami) uname=$(whoami)
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16) admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16)
sudo systemctl stop gohttpserver.service sudo systemctl stop gohttpserver.service
sudo systemctl stop rustdesksignal.service sudo systemctl stop rustdesksignal.service
sudo systemctl stop rustdeskrelay.service sudo systemctl stop rustdeskrelay.service
sudo systemctl disable gohttpserver.service
sudo systemctl disable rustdesksignal.service sudo systemctl disable rustdesksignal.service
sudo systemctl disable rustdeskrelay.service sudo systemctl disable rustdeskrelay.service
sudo systemctl disable gohttpserver.service
sudo rm /etc/systemd/system/gohttpserver.service sudo rm /etc/systemd/system/gohttpserver.service
sudo rm /etc/systemd/system/rustdeskrelay.service
sudo rm /etc/systemd/system/rustdesksignal.service sudo rm /etc/systemd/system/rustdesksignal.service
sudo rm /etc/systemd/system/rustdeskrelay.service
ARCH=$(uname -m) ARCH=$(uname -m)
# identify OS # Identify OS
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
# freedesktop.org and systemd # freedesktop.org and systemd
. /etc/os-release . /etc/os-release
@ -41,7 +40,6 @@ if [ -f /etc/os-release ]; then
UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)"
fi fi
elif type lsb_release >/dev/null 2>&1; then elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org # linuxbase.org
OS=$(lsb_release -si) OS=$(lsb_release -si)
@ -52,13 +50,13 @@ elif [ -f /etc/lsb-release ]; then
OS=$DISTRIB_ID OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc. # Older Debian, Ubuntu, etc.
OS=Debian OS=Debian
VER=$(cat /etc/debian_version) VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then elif [ -f /etc/SuSE-release ]; then
# Older SuSE/etc. # Older SuSE, etc.
OS=SuSE OS=SuSE
VER=$(cat /etc/SuSe-release) VER=$(cat /etc/SuSE-release)
elif [ -f /etc/redhat-release ]; then elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc. # Older Red Hat, CentOS, etc.
OS=RedHat OS=RedHat
@ -70,7 +68,7 @@ else
fi fi
# output ebugging info if $DEBUG set # Output debugging info if $DEBUG set
if [ "$DEBUG" = "true" ]; then if [ "$DEBUG" = "true" ]; then
echo "OS: $OS" echo "OS: $OS"
echo "VER: $VER" echo "VER: $VER"
@ -79,7 +77,7 @@ if [ "$DEBUG" = "true" ]; then
fi fi
# Setup prereqs for server # Setup prereqs for server
# common named prereqs # Common named prereqs
PREREQ="curl wget unzip tar" PREREQ="curl wget unzip tar"
PREREQDEB="dnsutils ufw" PREREQDEB="dnsutils ufw"
PREREQRPM="bind-utils" PREREQRPM="bind-utils"
@ -90,8 +88,8 @@ if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [
sudo apt-get update sudo apt-get update
sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
# opensuse 15.4 fails to run the relay service and hangs waiting for it # openSUSE 15.4 fails to run the relay service and hangs waiting for it
# needs more work before it can be enabled # Needs more work before it can be enabled
# || [ "${UPSTREAM_ID}" = "suse" ] # || [ "${UPSTREAM_ID}" = "suse" ]
sudo yum update -y sudo yum update -y
sudo yum install -y ${PREREQ} ${PREREQRPM} # git sudo yum install -y ${PREREQ} ${PREREQRPM} # git
@ -100,20 +98,19 @@ elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
sudo pacman -S ${PREREQ} ${PREREQARCH} sudo pacman -S ${PREREQ} ${PREREQARCH}
else else
echo "Unsupported OS" echo "Unsupported OS"
# here you could ask the user for permission to try and install anyway # Here you could ask the user for permission to try and install anyway
# if they say yes, then do the install # If they say yes, then do the install
# if they say no, exit the script # If they say no, exit the script
exit 1 exit 1
fi fi
# Setting up firewall # Setting up firewall
sudo ufw allow 21115:21119/tcp sudo ufw allow 21115:21119/tcp
sudo ufw allow 22/tcp sudo ufw allow 22/tcp
sudo ufw allow 21116/udp sudo ufw allow 21116/udp
sudo ufw enable sudo ufw enable
# Make Folder /var/lib/rustdesk-server/ # Make folder /var/lib/rustdesk-server/
if [ ! -d "/var/lib/rustdesk-server" ]; then if [ ! -d "/var/lib/rustdesk-server" ]; then
echo "Creating /var/lib/rustdesk-server" echo "Creating /var/lib/rustdesk-server"
sudo mkdir -p /var/lib/rustdesk-server/ sudo mkdir -p /var/lib/rustdesk-server/
@ -126,10 +123,10 @@ mv /opt/rustdesk/id_* /var/lib/rustdesk-server/
sudo rm -rf /opt/rustdesk sudo rm -rf /opt/rustdesk
#Download latest version of Rustdesk # Download latest version of RustDesk
RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server-pro/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server-pro/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }')
echo "Installing Rustdesk Server" echo "Installing RustDesk Server"
if [ "${ARCH}" = "x86_64" ] ; then if [ "${ARCH}" = "x86_64" ] ; then
wget https://github.com/rustdesk/rustdesk-server-pro/releases/download/1.1.8/rustdesk-server-linux-amd64.zip wget https://github.com/rustdesk/rustdesk-server-pro/releases/download/1.1.8/rustdesk-server-linux-amd64.zip
unzip rustdesk-server-linux-amd64.zip unzip rustdesk-server-linux-amd64.zip
@ -160,7 +157,7 @@ sudo chmod +x /usr/bin/hbbs
sudo chmod +x /usr/bin/hbbr sudo chmod +x /usr/bin/hbbr
# Make Folder /var/log/rustdesk-server/ # Make folder /var/log/rustdesk-server/
if [ ! -d "/var/log/rustdesk-server" ]; then if [ ! -d "/var/log/rustdesk-server" ]; then
echo "Creating /var/log/rustdesk-server" echo "Creating /var/log/rustdesk-server"
sudo mkdir -p /var/log/rustdesk-server/ sudo mkdir -p /var/log/rustdesk-server/
@ -168,10 +165,10 @@ fi
sudo chown "${uname}" -R /var/log/rustdesk-server/ sudo chown "${uname}" -R /var/log/rustdesk-server/
sudo rm -rf /var/log/rustdesk/ sudo rm -rf /var/log/rustdesk/
# Setup Systemd to launch hbbs # Setup systemd to launch hbbs
rustdeskhbbs="$(cat << EOF rustdeskhbbs="$(cat << EOF
[Unit] [Unit]
Description=Rustdesk Signal Server Description=RustDesk Signal Server
[Service] [Service]
Type=simple Type=simple
LimitNOFILE=1000000 LimitNOFILE=1000000
@ -193,10 +190,10 @@ sudo systemctl daemon-reload
sudo systemctl enable rustdesk-hbbs.service sudo systemctl enable rustdesk-hbbs.service
sudo systemctl start rustdesk-hbbs.service sudo systemctl start rustdesk-hbbs.service
# Setup Systemd to launch hbbr # Setup systemd to launch hbbr
rustdeskhbbr="$(cat << EOF rustdeskhbbr="$(cat << EOF
[Unit] [Unit]
Description=Rustdesk Relay Server Description=RustDesk Relay Server
[Service] [Service]
Type=simple Type=simple
LimitNOFILE=1000000 LimitNOFILE=1000000
@ -220,7 +217,7 @@ sudo systemctl start rustdesk-hbbr.service
while ! [[ $CHECK_RUSTDESK_READY ]]; do while ! [[ $CHECK_RUSTDESK_READY ]]; do
CHECK_RUSTDESK_READY=$(sudo systemctl status rustdesk-hbbr.service | grep "Active: active (running)") CHECK_RUSTDESK_READY=$(sudo systemctl status rustdesk-hbbr.service | grep "Active: active (running)")
echo -ne "Rustdesk Relay not ready yet...${NC}\n" echo -ne "RustDesk Relay not ready yet...${NC}\n"
sleep 3 sleep 3
done done
@ -253,11 +250,11 @@ break
;; ;;
"DNS/Domain") "DNS/Domain")
echo -ne "Enter your preferred domain/dns address ${NC}: " echo -ne "Enter your preferred domain/DNS address ${NC}: "
read wanip read wanip
#check wanip is valid domain # Check wanip is valid domain
if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then
echo -e "${RED}Invalid domain/dns address${NC}" echo -e "${RED}Invalid domain/DNS address${NC}"
exit 1 exit 1
fi fi
sudo apt -y install nginx sudo apt -y install nginx
@ -289,7 +286,7 @@ sudo certbot --nginx -d ${wanip}
break break
;; ;;
*) echo "invalid option $REPLY";; *) echo "Invalid option $REPLY";;
esac esac
done done