Compare commits
149 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29daee0608 | ||
|
|
7deca136ed | ||
|
|
88d6186186 | ||
|
|
c840209d2d | ||
|
|
c87d313027 | ||
|
|
fc76bec06b | ||
|
|
14e66ba91e | ||
|
|
c45bf07cff | ||
|
|
9408e3628f | ||
|
|
34522ae7ba | ||
|
|
d86b4bd7cd | ||
|
|
afe85342c9 | ||
|
|
a03b9c88cb | ||
|
|
aa8a1be443 | ||
|
|
f520f41890 | ||
|
|
66e8be4176 | ||
|
|
b5801a9bfa | ||
|
|
834c723ee2 | ||
|
|
81f97d46e8 | ||
|
|
5e45d44635 | ||
|
|
8bc783c20c | ||
|
|
3f86b8aa1f | ||
|
|
add84d65a0 | ||
|
|
b3f3b6f3f3 | ||
|
|
b8d1618080 | ||
|
|
a55613494d | ||
|
|
afefb34850 | ||
|
|
b223b25d4d | ||
|
|
c0f5c1b6ba | ||
|
|
242f37d7b7 | ||
|
|
3aa88d0c12 | ||
|
|
e7b24d86eb | ||
|
|
a36ac3ba13 | ||
|
|
53a6765771 | ||
|
|
240404a35f | ||
|
|
6cf5b6f7ae | ||
|
|
cc30226afd | ||
|
|
c397a07425 | ||
|
|
8d07bc0c11 | ||
|
|
11420ebaf6 | ||
|
|
1053198d41 | ||
|
|
381558aedd | ||
|
|
af077524cc | ||
|
|
bf6ab0af5f | ||
|
|
a59e309333 | ||
|
|
2ceee1ca3d | ||
|
|
e802c03a47 | ||
|
|
6da8204aab | ||
|
|
7366541dce | ||
|
|
077e892e6d | ||
|
|
6ed4d38160 | ||
|
|
14b7019d21 | ||
|
|
19623b0011 | ||
|
|
0f95c5d8b4 | ||
|
|
5929f8260e | ||
|
|
d992357a91 | ||
|
|
386e548d5c | ||
|
|
aecb8f28b3 | ||
|
|
f03fc83c4f | ||
|
|
57862cb63f | ||
|
|
dcd7f828c0 | ||
|
|
ec79b3e832 | ||
|
|
bed5384ea4 | ||
|
|
d12bc5f966 | ||
|
|
04369b60db | ||
|
|
eaceefd8bb | ||
|
|
3f039cb502 | ||
|
|
efa485173f | ||
|
|
23d9d936ad | ||
|
|
50dcbccef9 | ||
|
|
b57eb8854d | ||
|
|
c2fa493407 | ||
|
|
37a2d95def | ||
|
|
5fd03c308a | ||
|
|
026a74e337 | ||
|
|
3e760dc243 | ||
|
|
f8229c238b | ||
|
|
3daa02e45f | ||
|
|
e474af4b6c | ||
|
|
89b6a3df0a | ||
|
|
101faddb97 | ||
|
|
c7da348133 | ||
|
|
d7f477c190 | ||
|
|
80a378c75b | ||
|
|
f145a954c4 | ||
|
|
eba52bc614 | ||
|
|
7d0d4e8238 | ||
|
|
07b387f185 | ||
|
|
3d0472bb91 | ||
|
|
d00e5fa8d7 | ||
|
|
7c4a90f5df | ||
|
|
88906b6fae | ||
|
|
e0a5c7a8ae | ||
|
|
5495265cb1 | ||
|
|
aebf0eff5d | ||
|
|
7aeb318587 | ||
|
|
659f2252fa | ||
|
|
f1a4a25f56 | ||
|
|
dcbd9ab61f | ||
|
|
97a4c12fa1 | ||
|
|
4a70bb3540 | ||
|
|
f60fcb61e6 | ||
|
|
d3abe106c9 | ||
|
|
30a9f19e82 | ||
|
|
9134020d8e | ||
|
|
cb43f6f667 | ||
|
|
95f403f9e2 | ||
|
|
d48584cf3b | ||
|
|
38d91fbeeb | ||
|
|
bdbe6e4bd0 | ||
|
|
be3fab3a52 | ||
|
|
7ae3739716 | ||
|
|
707854675e | ||
|
|
d8f29f5aeb | ||
|
|
aabf85921e | ||
|
|
d7ad8d2f70 | ||
|
|
be6b1e66a1 | ||
|
|
abfd7c9ab1 | ||
|
|
a55e515e04 | ||
|
|
74ecae9fb3 | ||
|
|
2e0edd77ef | ||
|
|
7e178c4738 | ||
|
|
2ade8b409d | ||
|
|
9ca9a54d10 | ||
|
|
72304f95bb | ||
|
|
cde1a2e77a | ||
|
|
b4ab33f25d | ||
|
|
50781866b9 | ||
|
|
75b8f67d83 | ||
|
|
cce8bbbbee | ||
|
|
a70cd79e36 | ||
|
|
1c46003561 | ||
|
|
2e0fe1ffd5 | ||
|
|
145c9a8e2f | ||
|
|
b6241ab778 | ||
|
|
f17b99e6cc | ||
|
|
2b4889f61c | ||
|
|
53c97910c3 | ||
|
|
e7c54cc7fc | ||
|
|
82736dbfc6 | ||
|
|
1826725246 | ||
|
|
d8a3b7340c | ||
|
|
ab88536f56 | ||
|
|
c6c6cc2949 | ||
|
|
1cea6ac412 | ||
|
|
6a7e38788a | ||
|
|
e382b55c07 | ||
|
|
11ef6f1c53 | ||
|
|
90e75caf15 |
31
.github/workflows/reviewdog.yml
vendored
Normal file
31
.github/workflows/reviewdog.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
|
||||||
|
name: 'reviewdog'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
name: Shellcheck testing
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: shellcheck
|
||||||
|
uses: reviewdog/action-shellcheck@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.github_token }}
|
||||||
|
reporter: github-pr-review
|
||||||
|
path: "." # Optional.
|
||||||
|
pattern: "*.sh" # Optional.
|
||||||
|
exclude: "./.git/*" # Optional.
|
||||||
|
misspell:
|
||||||
|
name: Check spelling
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: spelling or typos
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: misspell
|
||||||
|
uses: reviewdog/action-misspell@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.github_token }}
|
||||||
|
locale: "US"
|
||||||
52
README.md
52
README.md
@@ -1,4 +1,52 @@
|
|||||||
# rustdesk-server-pro
|
# RustDesk Server PRO
|
||||||
Some scripts for RustDesk Server Pro are hosted here.
|
Here we have a small collection of [some scripts](https://rustdesk.com/docs/en/self-host/rustdesk-server-pro/installscript/) for RustDesk Server Pro.
|
||||||
|
|
||||||
> If you are looking for the open source version please go to [RustDesk Server](https://github.com/rustdesk/rustdesk-server)
|
> If you are looking for the open source version please go to [RustDesk Server](https://github.com/rustdesk/rustdesk-server)
|
||||||
|
|
||||||
|
# Contributing to this repo
|
||||||
|
|
||||||
|
You are very welcome to add your PR to improve the current scripts. Some pointers:
|
||||||
|
|
||||||
|
### The lib file
|
||||||
|
|
||||||
|
The lib.sh is used to avoid duplicate code. Here we collect everything that occurs more than once in the varoius scripts. That could be both `functions()` and `$variables`.
|
||||||
|
|
||||||
|
### Indentation
|
||||||
|
|
||||||
|
We always use four (4) spaces, not one (1) tab. Please see below for examples.
|
||||||
|
|
||||||
|
### IF arguments and functions
|
||||||
|
|
||||||
|
The current style is to use it like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
if something
|
||||||
|
then
|
||||||
|
do something
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
Not like:
|
||||||
|
```
|
||||||
|
if something; then
|
||||||
|
do something
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
Same applies for functions:
|
||||||
|
|
||||||
|
```
|
||||||
|
examplefuntion() {
|
||||||
|
if something
|
||||||
|
then
|
||||||
|
do something
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Variables
|
||||||
|
|
||||||
|
Variables are always written in CAPITAL LETTERS.
|
||||||
|
|
||||||
|
```
|
||||||
|
EXAMPLEVARIABLE=true
|
||||||
|
```
|
||||||
|
|||||||
157
backup.sh
Normal file
157
backup.sh
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=2034,2059,2164
|
||||||
|
true
|
||||||
|
|
||||||
|
usern=$(whoami)
|
||||||
|
path=$(pwd)
|
||||||
|
echo "$path"
|
||||||
|
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
|
||||||
|
# Identify OS
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
# freedesktop.org and systemd
|
||||||
|
. /etc/os-release
|
||||||
|
OS=$NAME
|
||||||
|
VER=$VERSION_ID
|
||||||
|
UPSTREAM_ID=${ID_LIKE,,}
|
||||||
|
|
||||||
|
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
|
||||||
|
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then
|
||||||
|
UPSTREAM_ID="$(echo "${ID_LIKE,,}" | sed s/\"//g | cut -d' ' -f1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif type lsb_release >/dev/null 2>&1; then
|
||||||
|
# linuxbase.org
|
||||||
|
OS=$(lsb_release -si)
|
||||||
|
VER=$(lsb_release -sr)
|
||||||
|
elif [ -f /etc/lsb-release ]; then
|
||||||
|
# For some versions of Debian/Ubuntu without lsb_release command
|
||||||
|
. /etc/lsb-release
|
||||||
|
OS=$DISTRIB_ID
|
||||||
|
VER=$DISTRIB_RELEASE
|
||||||
|
elif [ -f /etc/debian_version ]; then
|
||||||
|
# Older Debian, Ubuntu, etc.
|
||||||
|
OS=Debian
|
||||||
|
VER=$(cat /etc/debian_version)
|
||||||
|
elif [ -f /etc/SuSE-release ]; then
|
||||||
|
# Older SuSE, etc.
|
||||||
|
OS=SuSE
|
||||||
|
VER=$(cat /etc/SuSE-release)
|
||||||
|
elif [ -f /etc/redhat-release ]; then
|
||||||
|
# Older Red Hat, CentOS, etc.
|
||||||
|
OS=RedHat
|
||||||
|
VER=$(cat /etc/redhat-release)
|
||||||
|
else
|
||||||
|
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
||||||
|
OS=$(uname -s)
|
||||||
|
VER=$(uname -r)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Output debugging info if $DEBUG set
|
||||||
|
if [ "$DEBUG" = "true" ]; then
|
||||||
|
echo "OS: $OS"
|
||||||
|
echo "VER: $VER"
|
||||||
|
echo "UPSTREAM_ID: $UPSTREAM_ID"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup prereqs for server
|
||||||
|
# Common named prereqs
|
||||||
|
PREREQ="tar"
|
||||||
|
PREREQDEB="sqlite3"
|
||||||
|
PREREQRPM="sqlite"
|
||||||
|
PREREQARCH="sqlite"
|
||||||
|
|
||||||
|
echo "Installing prerequisites"
|
||||||
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git
|
||||||
|
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
|
||||||
|
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
||||||
|
# Needs more work before it can be enabled
|
||||||
|
# || [ "${UPSTREAM_ID}" = "suse" ]
|
||||||
|
sudo yum update -y
|
||||||
|
sudo dnf install -y epel-release
|
||||||
|
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
|
||||||
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
||||||
|
sudo pacman -Syu
|
||||||
|
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
||||||
|
else
|
||||||
|
echo "Unsupported OS"
|
||||||
|
# Here you could ask the user for permission to try and install anyway
|
||||||
|
# If they say yes, then do the install
|
||||||
|
# If they say no, exit the script
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $* == *--schedule* ]]; then
|
||||||
|
(
|
||||||
|
crontab -l 2>/dev/null
|
||||||
|
echo "0 0 * * * $path/backup.sh --auto"
|
||||||
|
) | crontab -
|
||||||
|
|
||||||
|
if [ ! -d /opt/rustdesk-server-backups ]; then
|
||||||
|
sudo mkdir /opt/rustdesk-server-backups
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d /opt/rustdesk-server-backups/daily ]; then
|
||||||
|
sudo mkdir /opt/rustdesk-server-backups/daily
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d /opt/rustdesk-server-backups/weekly ]; then
|
||||||
|
sudo mkdir /opt/rustdesk-server-backups/weekly
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d /opt/rustdesk-server-backups/monthly ]; then
|
||||||
|
sudo mkdir /opt/rustdesk-server-backups/monthly
|
||||||
|
fi
|
||||||
|
sudo chown "${usern}":"${usern}" -R /opt/rustdesk-server-backups
|
||||||
|
|
||||||
|
printf >&2 "Backups setup to run at midnight and rotate."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d /opt/rustdesk-server-backups ]; then
|
||||||
|
sudo mkdir /opt/rustdesk-server-backups
|
||||||
|
sudo chown "${usern}":"${usern}" /opt/rustdesk-server-backups
|
||||||
|
fi
|
||||||
|
|
||||||
|
dt_now=$(date '+%Y_%m_%d__%H_%M_%S')
|
||||||
|
tmp_dir=$(mktemp -d -t rustdesk-XXXXXXXXXXXXXXXXXXXXX)
|
||||||
|
sysd="/etc/systemd/system"
|
||||||
|
|
||||||
|
cp -rf /var/lib/rustdesk-server/ "${tmp_dir}"/
|
||||||
|
sqlite3 /var/lib/rustdesk-server/db.sqlite3 .dump > "${tmp_dir}"/db_backup_file.sql
|
||||||
|
|
||||||
|
if [[ $* == *--auto* ]]; then
|
||||||
|
|
||||||
|
month_day=$(date +"%d")
|
||||||
|
week_day=$(date +"%u")
|
||||||
|
|
||||||
|
if [ "$month_day" -eq 10 ]; then
|
||||||
|
tar -cf /opt/rustdesk-server-backups/monthly/rustdesk-backup-"${dt_now}".tar -C "${tmp_dir}" .
|
||||||
|
else
|
||||||
|
if [ "$week_day" -eq 5 ]; then
|
||||||
|
tar -cf /opt/rustdesk-server-backups/weekly/rustdesk-backup-"${dt_now}".tar -C "${tmp_dir}" .
|
||||||
|
else
|
||||||
|
tar -cf /opt/rustdesk-server-backups/daily/rustdesk-backup-"${dt_now}".tar -C "${tmp_dir}" .
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "${tmp_dir}"
|
||||||
|
|
||||||
|
find /opt/rustdesk-server-backups/daily/ -type f -mtime +14 -name '*.tar' -execdir rm -- '{}' \;
|
||||||
|
find /opt/rustdesk-server-backups/weekly/ -type f -mtime +60 -name '*.tar' -execdir rm -- '{}' \;
|
||||||
|
find /opt/rustdesk-server-backups/monthly/ -type f -mtime +380 -name '*.tar' -execdir rm -- '{}' \;
|
||||||
|
echo -ne "Backup Completed"
|
||||||
|
exit
|
||||||
|
|
||||||
|
else
|
||||||
|
tar -cf /opt/rustdesk-server-backups/rustdesk-backup-"${dt_now}".tar -C "${tmp_dir}" .
|
||||||
|
rm -rf "${tmp_dir}"
|
||||||
|
echo -ne "Backup saved to /opt/rustdesk-server-backups/rustdesk-backup-${dt_now}.tar"
|
||||||
|
fi
|
||||||
379
convertfromos.sh
379
convertfromos.sh
@@ -9,286 +9,119 @@
|
|||||||
# 6. Create systemd services for hbbs and hbbr
|
# 6. Create systemd services for hbbs and hbbr
|
||||||
# 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
|
# 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
|
##################################################################################################################
|
||||||
uname=$(whoami)
|
|
||||||
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16)
|
|
||||||
|
|
||||||
|
# Install curl and whiptail if needed
|
||||||
|
if [ ! -x "$(command -v curl)" ] || [ ! -x "$(command -v whiptail)" ]
|
||||||
|
then
|
||||||
|
# We need curl to fetch the lib
|
||||||
|
# There are the package managers for different OS:
|
||||||
|
# osInfo[/etc/redhat-release]=yum
|
||||||
|
# osInfo[/etc/arch-release]=pacman
|
||||||
|
# osInfo[/etc/gentoo-release]=emerge
|
||||||
|
# osInfo[/etc/SuSE-release]=zypp
|
||||||
|
# osInfo[/etc/debian_version]=apt-get
|
||||||
|
# osInfo[/etc/alpine-release]=apk
|
||||||
|
NEEDED_DEPS=(curl whiptail)
|
||||||
|
echo "Installing these packages:" "${NEEDED_DEPS[@]}"
|
||||||
|
if [ -x "$(command -v apt-get)" ]
|
||||||
|
then
|
||||||
|
sudo apt-get install "${NEEDED_DEPS[@]}" -y
|
||||||
|
elif [ -x "$(command -v apk)" ]
|
||||||
|
then
|
||||||
|
sudo apk add --no-cache "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v dnf)" ]
|
||||||
|
then
|
||||||
|
sudo dnf install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v zypper)" ]
|
||||||
|
then
|
||||||
|
sudo zypper install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v pacman)" ]
|
||||||
|
then
|
||||||
|
sudo pacman -S install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v yum)" ]
|
||||||
|
then
|
||||||
|
sudo yum install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v emerge)" ]
|
||||||
|
then
|
||||||
|
sudo emerge -av "${NEEDED_DEPS[@]}"
|
||||||
|
else
|
||||||
|
echo "FAILED TO INSTALL! Package manager not found. You must manually install:" "${NEEDED_DEPS[@]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We need to source directly from the Github repo to be able to use the functions here
|
||||||
|
# shellcheck disable=2034,2059,2164
|
||||||
|
true
|
||||||
|
SCRIPT_NAME="Install script"
|
||||||
|
export SCRIPT_NAME
|
||||||
|
# shellcheck source=lib.sh
|
||||||
|
source <(curl -sL https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/lib.sh)
|
||||||
|
# see https://github.com/koalaman/shellcheck/wiki/Directive
|
||||||
|
unset SCRIPT_NAME
|
||||||
|
|
||||||
|
##################################################################################################################
|
||||||
|
|
||||||
|
# Check if root
|
||||||
|
root_check
|
||||||
|
|
||||||
|
# Output debugging info if $DEBUG set
|
||||||
|
if [ "$DEBUG" = "true" ]
|
||||||
|
then
|
||||||
|
identify_os
|
||||||
|
print_text_in_color "$ICyan" "OS: $OS"
|
||||||
|
print_text_in_color "$ICyan" "VER: $VER"
|
||||||
|
print_text_in_color "$ICyan" "UPSTREAM_ID: $UPSTREAM_ID"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Stop all old services
|
||||||
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 gohttpserver.service
|
||||||
sudo systemctl disable rustdesksignal.service
|
sudo systemctl disable rustdesksignal.service
|
||||||
sudo systemctl disable rustdeskrelay.service
|
sudo systemctl disable rustdeskrelay.service
|
||||||
sudo rm /etc/systemd/system/gohttpserver.service
|
sudo rm -f /etc/systemd/system/gohttpserver.service
|
||||||
sudo rm /etc/systemd/system/rustdesksignal.service
|
sudo rm -f /etc/systemd/system/rustdesksignal.service
|
||||||
sudo rm /etc/systemd/system/rustdeskrelay.service
|
sudo rm -f /etc/systemd/system/rustdeskrelay.service
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
# Install Rustdesk again
|
||||||
|
# It won't install RustDesk again since there's a check in the install script which checks for the installation folder, but services and everything else will be created
|
||||||
|
# Would it be possible to move L93-98 after the installation?
|
||||||
# Identify OS
|
if ! curl -fSLO --retry 3 https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/install.sh
|
||||||
if [ -f /etc/os-release ]; then
|
then
|
||||||
# freedesktop.org and systemd
|
msg_box "Sorry, we couldn't fetch the install script, please try again.
|
||||||
. /etc/os-release
|
Your old installation still lives in /opt/rustdesk"
|
||||||
OS=$NAME
|
exit
|
||||||
VER=$VERSION_ID
|
else
|
||||||
|
if sudo bash -x install.sh
|
||||||
UPSTREAM_ID=${ID_LIKE,,}
|
then
|
||||||
|
rm -f install.sh
|
||||||
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
|
# Migration tasks
|
||||||
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then
|
if [ -d /opt/rustdesk ]
|
||||||
UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)"
|
then
|
||||||
|
# First remove the keys generated by the installation script
|
||||||
|
rm -f "$RUSTDESK_INSTALL_DIR"/id_*
|
||||||
|
# Then copy over the old keys to the new install dir
|
||||||
|
if cp -f /opt/rustdesk/id_* "$RUSTDESK_INSTALL_DIR/"
|
||||||
|
then
|
||||||
|
# Make sure to really protect the old keys by checking that the new service actually restarts with 0 status before removing the old keys.
|
||||||
|
if systemctl restart rustdesk-hbbr.service && systemctl restart rustdesk-hbbs.service
|
||||||
|
then
|
||||||
|
rm -rf /opt/rustdesk
|
||||||
|
else
|
||||||
|
msg_box "Sorry, couldn't restart the new services. Please send your output to https://github.com/rustdesk/rustdesk-server-pro in a new issue."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
msg_box "Sorry, but it seems that something went wrong with copying your old keys to the new install dir. Please try again"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
msg_box "Conversion from OS seems to have been OK!"
|
||||||
|
else
|
||||||
|
msg_box "Sorry, but something seems to have gone wrong, please report this to:
|
||||||
|
https://github.com/rustdesk/rustdesk-server-pro/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif type lsb_release >/dev/null 2>&1; then
|
|
||||||
# linuxbase.org
|
|
||||||
OS=$(lsb_release -si)
|
|
||||||
VER=$(lsb_release -sr)
|
|
||||||
elif [ -f /etc/lsb-release ]; then
|
|
||||||
# For some versions of Debian/Ubuntu without lsb_release command
|
|
||||||
. /etc/lsb-release
|
|
||||||
OS=$DISTRIB_ID
|
|
||||||
VER=$DISTRIB_RELEASE
|
|
||||||
elif [ -f /etc/debian_version ]; then
|
|
||||||
# Older Debian, Ubuntu, etc.
|
|
||||||
OS=Debian
|
|
||||||
VER=$(cat /etc/debian_version)
|
|
||||||
elif [ -f /etc/SuSE-release ]; then
|
|
||||||
# Older SuSE, etc.
|
|
||||||
OS=SuSE
|
|
||||||
VER=$(cat /etc/SuSE-release)
|
|
||||||
elif [ -f /etc/redhat-release ]; then
|
|
||||||
# Older Red Hat, CentOS, etc.
|
|
||||||
OS=RedHat
|
|
||||||
VER=$(cat /etc/redhat-release)
|
|
||||||
else
|
|
||||||
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
|
||||||
OS=$(uname -s)
|
|
||||||
VER=$(uname -r)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Output debugging info if $DEBUG set
|
|
||||||
if [ "$DEBUG" = "true" ]; then
|
|
||||||
echo "OS: $OS"
|
|
||||||
echo "VER: $VER"
|
|
||||||
echo "UPSTREAM_ID: $UPSTREAM_ID"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Setup prereqs for server
|
|
||||||
# Common named prereqs
|
|
||||||
PREREQ="curl wget unzip tar"
|
|
||||||
PREREQDEB="dnsutils ufw"
|
|
||||||
PREREQRPM="bind-utils"
|
|
||||||
PREREQARCH="bind"
|
|
||||||
|
|
||||||
echo "Installing prerequisites"
|
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git
|
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
|
|
||||||
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
|
||||||
# Needs more work before it can be enabled
|
|
||||||
# || [ "${UPSTREAM_ID}" = "suse" ]
|
|
||||||
sudo yum update -y
|
|
||||||
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
|
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
|
||||||
sudo pacman -Syu
|
|
||||||
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
|
||||||
else
|
|
||||||
echo "Unsupported OS"
|
|
||||||
# Here you could ask the user for permission to try and install anyway
|
|
||||||
# If they say yes, then do the install
|
|
||||||
# If they say no, exit the script
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Setting up firewall
|
|
||||||
sudo ufw allow 21115:21119/tcp
|
|
||||||
sudo ufw allow 22/tcp
|
|
||||||
sudo ufw allow 21116/udp
|
|
||||||
sudo ufw enable
|
|
||||||
|
|
||||||
# Make folder /var/lib/rustdesk-server/
|
|
||||||
if [ ! -d "/var/lib/rustdesk-server" ]; then
|
|
||||||
echo "Creating /var/lib/rustdesk-server"
|
|
||||||
sudo mkdir -p /var/lib/rustdesk-server/
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo chown "${uname}" -R /var/lib/rustdesk-server
|
|
||||||
cd /var/lib/rustdesk-server/ || exit 1
|
|
||||||
|
|
||||||
mv /opt/rustdesk/id_* /var/lib/rustdesk-server/
|
|
||||||
|
|
||||||
sudo rm -rf /opt/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) }')
|
|
||||||
|
|
||||||
echo "Installing RustDesk Server"
|
|
||||||
if [ "${ARCH}" = "x86_64" ] ; then
|
|
||||||
wget https://github.com/rustdesk/rustdesk-server-pro/releases/download/1.1.8/rustdesk-server-linux-amd64.zip
|
|
||||||
unzip rustdesk-server-linux-amd64.zip
|
|
||||||
mv amd64/static /var/lib/rustdesk-server/
|
|
||||||
sudo mv amd64/hbbr /usr/bin/
|
|
||||||
sudo mv amd64/hbbs /usr/bin/
|
|
||||||
rm -rf amd64/
|
|
||||||
rm -rf rustdesk-server-linux-amd64.zip
|
|
||||||
elif [ "${ARCH}" = "armv7l" ] ; then
|
|
||||||
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-armv7.zip"
|
|
||||||
unzip rustdesk-server-linux-armv7.zip
|
|
||||||
mv armv7/static /var/lib/rustdesk-server/
|
|
||||||
sudo mv armv7/hbbr /usr/bin/
|
|
||||||
sudo mv armv7/hbbs /usr/bin/
|
|
||||||
rm -rf armv7/
|
|
||||||
rm -rf rustdesk-server-linux-armv7.zip
|
|
||||||
elif [ "${ARCH}" = "aarch64" ] ; then
|
|
||||||
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8.zip"
|
|
||||||
unzip rustdesk-server-linux-arm64v8.zip
|
|
||||||
mv arm64v8/static /var/lib/rustdesk-server/
|
|
||||||
sudo mv arm64v8/hbbr /usr/bin/
|
|
||||||
sudo mv arm64v8/hbbs /usr/bin/
|
|
||||||
rm -rf arm64v8/
|
|
||||||
rm -rf rustdesk-server-linux-arm64v8.zip
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo chmod +x /usr/bin/hbbs
|
|
||||||
sudo chmod +x /usr/bin/hbbr
|
|
||||||
|
|
||||||
|
|
||||||
# Make folder /var/log/rustdesk-server/
|
|
||||||
if [ ! -d "/var/log/rustdesk-server" ]; then
|
|
||||||
echo "Creating /var/log/rustdesk-server"
|
|
||||||
sudo mkdir -p /var/log/rustdesk-server/
|
|
||||||
fi
|
|
||||||
sudo chown "${uname}" -R /var/log/rustdesk-server/
|
|
||||||
sudo rm -rf /var/log/rustdesk/
|
|
||||||
|
|
||||||
# Setup systemd to launch hbbs
|
|
||||||
rustdeskhbbs="$(cat << EOF
|
|
||||||
[Unit]
|
|
||||||
Description=RustDesk Signal Server
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
LimitNOFILE=1000000
|
|
||||||
ExecStart=/usr/bin/hbbs
|
|
||||||
WorkingDirectory=/var/lib/rustdesk-server/
|
|
||||||
User=${uname}
|
|
||||||
Group=${uname}
|
|
||||||
Restart=always
|
|
||||||
StandardOutput=append:/var/log/rustdesk-server/hbbs.log
|
|
||||||
StandardError=append:/var/log/rustdesk-server/hbbs.error
|
|
||||||
# Restart service after 10 seconds if node service crashes
|
|
||||||
RestartSec=10
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
)"
|
|
||||||
echo "${rustdeskhbbs}" | sudo tee /etc/systemd/system/rustdesk-hbbs.service > /dev/null
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable rustdesk-hbbs.service
|
|
||||||
sudo systemctl start rustdesk-hbbs.service
|
|
||||||
|
|
||||||
# Setup systemd to launch hbbr
|
|
||||||
rustdeskhbbr="$(cat << EOF
|
|
||||||
[Unit]
|
|
||||||
Description=RustDesk Relay Server
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
LimitNOFILE=1000000
|
|
||||||
ExecStart=/usr/bin/hbbr
|
|
||||||
WorkingDirectory=/var/lib/rustdesk-server/
|
|
||||||
User=${uname}
|
|
||||||
Group=${uname}
|
|
||||||
Restart=always
|
|
||||||
StandardOutput=append:/var/log/rustdesk-server/hbbr.log
|
|
||||||
StandardError=append:/var/log/rustdesk-server/hbbr.error
|
|
||||||
# Restart service after 10 seconds if node service crashes
|
|
||||||
RestartSec=10
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
)"
|
|
||||||
echo "${rustdeskhbbr}" | sudo tee /etc/systemd/system/rustdesk-hbbr.service > /dev/null
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable rustdesk-hbbr.service
|
|
||||||
sudo systemctl start rustdesk-hbbr.service
|
|
||||||
|
|
||||||
while ! [[ $CHECK_RUSTDESK_READY ]]; do
|
|
||||||
CHECK_RUSTDESK_READY=$(sudo systemctl status rustdesk-hbbr.service | grep "Active: active (running)")
|
|
||||||
echo -ne "RustDesk Relay not ready yet...${NC}\n"
|
|
||||||
sleep 3
|
|
||||||
done
|
|
||||||
|
|
||||||
pubname=$(find /var/lib/rustdesk-server/ -name "*.pub")
|
|
||||||
key=$(cat "${pubname}")
|
|
||||||
|
|
||||||
echo "Tidying up install"
|
|
||||||
if [ "${ARCH}" = "x86_64" ] ; then
|
|
||||||
rm rustdesk-server-linux-amd64.zip
|
|
||||||
rm -rf amd64
|
|
||||||
elif [ "${ARCH}" = "armv7l" ] ; then
|
|
||||||
rm rustdesk-server-linux-armv7.zip
|
|
||||||
rm -rf armv7
|
|
||||||
elif [ "${ARCH}" = "aarch64" ] ; then
|
|
||||||
rm rustdesk-server-linux-arm64v8.zip
|
|
||||||
rm -rf arm64v8
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Choice for DNS or IP
|
|
||||||
PS3='Choose your preferred option, IP or DNS/Domain:'
|
|
||||||
WAN=("IP" "DNS/Domain")
|
|
||||||
select WANOPT in "${WAN[@]}"; do
|
|
||||||
case $WANOPT in
|
|
||||||
"IP")
|
|
||||||
wanip=$(dig @resolver4.opendns.com myip.opendns.com +short)
|
|
||||||
sudo ufw allow 21114/tcp
|
|
||||||
|
|
||||||
sudo ufw enable && ufw reload
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
|
|
||||||
"DNS/Domain")
|
|
||||||
echo -ne "Enter your preferred domain/DNS address ${NC}: "
|
|
||||||
read wanip
|
|
||||||
# Check wanip is valid domain
|
|
||||||
if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then
|
|
||||||
echo -e "${RED}Invalid domain/DNS address${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sudo apt -y install nginx
|
|
||||||
sudo apt -y install python3-certbot-nginx
|
|
||||||
|
|
||||||
rustdesknginx="$(
|
|
||||||
cat <<EOF
|
|
||||||
server {
|
|
||||||
server_name ${wanip};
|
|
||||||
location / {
|
|
||||||
proxy_pass http://127.0.0.1:21114/;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
)"
|
|
||||||
echo "${rustdesknginx}" | sudo tee /etc/nginx/sites-available/rustdesk.conf >/dev/null
|
|
||||||
|
|
||||||
sudo rm /etc/nginx/sites-available/default
|
|
||||||
sudo rm /etc/nginx/sites-enabled/default
|
|
||||||
|
|
||||||
sudo ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
|
|
||||||
|
|
||||||
sudo ufw allow 80/tcp
|
|
||||||
sudo ufw allow 443/tcp
|
|
||||||
|
|
||||||
sudo ufw enable && ufw reload
|
|
||||||
|
|
||||||
sudo certbot --nginx -d ${wanip}
|
|
||||||
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*) echo "Invalid option $REPLY";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
echo -e "Your IP/DNS Address is ${wanip}"
|
|
||||||
echo -e "Your public key is ${key}"
|
|
||||||
|
|||||||
602
install.sh
602
install.sh
@@ -3,276 +3,472 @@
|
|||||||
# This script will do the following to install RustDesk Server Pro
|
# This script will do the following to install RustDesk Server Pro
|
||||||
# 1. Install some dependencies
|
# 1. Install some dependencies
|
||||||
# 2. Setup UFW firewall if available
|
# 2. Setup UFW firewall if available
|
||||||
# 3. Create 2 folders /var/lib/rustdesk-server and /var/log/rustdesk-server
|
# 3. Create 2 folders /var/lib/rustdesk-server and /var/log/rustdesk-server ("$RUSTDESK_INSTALL_DIR" and "$RUSTDESK_LOG_DIR")
|
||||||
# 4. Download and extract RustDesk Pro Services to the above folder
|
# 4. Download and extract RustDesk Pro Services to the above folder
|
||||||
# 5. Create systemd services for hbbs and hbbr
|
# 5. Create systemd services for hbbs and hbbr
|
||||||
# 6. 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
|
# 6. 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
|
# Please note; even if the script is run as root, you will still be able to choose a non-root user during setup.
|
||||||
uname=$(whoami)
|
|
||||||
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16)
|
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
##################################################################################################################
|
||||||
|
|
||||||
|
# Install curl and whiptail if needed
|
||||||
# Identify OS
|
if [ ! -x "$(command -v curl)" ] || [ ! -x "$(command -v whiptail)" ]
|
||||||
if [ -f /etc/os-release ]; then
|
then
|
||||||
# freedesktop.org and systemd
|
# We need curl to fetch the lib
|
||||||
. /etc/os-release
|
# There are the package managers for different OS:
|
||||||
OS=$NAME
|
# osInfo[/etc/redhat-release]=yum
|
||||||
VER=$VERSION_ID
|
# osInfo[/etc/arch-release]=pacman
|
||||||
UPSTREAM_ID=${ID_LIKE,,}
|
# osInfo[/etc/gentoo-release]=emerge
|
||||||
|
# osInfo[/etc/SuSE-release]=zypp
|
||||||
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
|
# osInfo[/etc/debian_version]=apt-get
|
||||||
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then
|
# osInfo[/etc/alpine-release]=apk
|
||||||
UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)"
|
NEEDED_DEPS=(curl whiptail)
|
||||||
|
echo "Installing these packages:" "${NEEDED_DEPS[@]}"
|
||||||
|
if [ -x "$(command -v apt-get)" ]
|
||||||
|
then
|
||||||
|
sudo apt-get install "${NEEDED_DEPS[@]}" -y
|
||||||
|
elif [ -x "$(command -v apk)" ]
|
||||||
|
then
|
||||||
|
sudo apk add --no-cache "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v dnf)" ]
|
||||||
|
then
|
||||||
|
sudo dnf install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v zypper)" ]
|
||||||
|
then
|
||||||
|
sudo zypper install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v pacman)" ]
|
||||||
|
then
|
||||||
|
sudo pacman -S install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v yum)" ]
|
||||||
|
then
|
||||||
|
sudo yum install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v emerge)" ]
|
||||||
|
then
|
||||||
|
sudo emerge -av "${NEEDED_DEPS[@]}"
|
||||||
|
else
|
||||||
|
echo "FAILED TO INSTALL! Package manager not found. You must manually install:" "${NEEDED_DEPS[@]}"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif type lsb_release >/dev/null 2>&1; then
|
|
||||||
# linuxbase.org
|
|
||||||
OS=$(lsb_release -si)
|
|
||||||
VER=$(lsb_release -sr)
|
|
||||||
elif [ -f /etc/lsb-release ]; then
|
|
||||||
# For some versions of Debian/Ubuntu without lsb_release command
|
|
||||||
. /etc/lsb-release
|
|
||||||
OS=$DISTRIB_ID
|
|
||||||
VER=$DISTRIB_RELEASE
|
|
||||||
elif [ -f /etc/debian_version ]; then
|
|
||||||
# Older Debian, Ubuntu, etc.
|
|
||||||
OS=Debian
|
|
||||||
VER=$(cat /etc/debian_version)
|
|
||||||
elif [ -f /etc/SuSE-release ]; then
|
|
||||||
# Older SuSE, etc.
|
|
||||||
OS=SuSE
|
|
||||||
VER=$(cat /etc/SuSE-release)
|
|
||||||
elif [ -f /etc/redhat-release ]; then
|
|
||||||
# Older Red Hat, CentOS, etc.
|
|
||||||
OS=RedHat
|
|
||||||
VER=$(cat /etc/redhat-release)
|
|
||||||
else
|
|
||||||
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
|
||||||
OS=$(uname -s)
|
|
||||||
VER=$(uname -r)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# We need to source directly from the Github repo to be able to use the functions here
|
||||||
|
# shellcheck disable=2034,2059,2164
|
||||||
|
true
|
||||||
|
SCRIPT_NAME="Install script"
|
||||||
|
export SCRIPT_NAME
|
||||||
|
# shellcheck source=lib.sh
|
||||||
|
source <(curl -sL https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/lib.sh)
|
||||||
|
# see https://github.com/koalaman/shellcheck/wiki/Directive
|
||||||
|
unset SCRIPT_NAME
|
||||||
|
|
||||||
|
##################################################################################################################
|
||||||
|
|
||||||
|
# Check if root
|
||||||
|
root_check
|
||||||
|
|
||||||
# Output debugging info if $DEBUG set
|
# Output debugging info if $DEBUG set
|
||||||
if [ "$DEBUG" = "true" ]; then
|
if [ "$DEBUG" = "true" ]
|
||||||
echo "OS: $OS"
|
then
|
||||||
echo "VER: $VER"
|
identify_os
|
||||||
echo "UPSTREAM_ID: $UPSTREAM_ID"
|
print_text_in_color "$ICyan" "OS: $OS"
|
||||||
|
print_text_in_color "$ICyan" "VER: $VER"
|
||||||
|
print_text_in_color "$ICyan" "UPSTREAM_ID: $UPSTREAM_ID"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setup prereqs for server
|
# We need the WAN IP
|
||||||
# Common named prereqs
|
get_wanip4
|
||||||
PREREQ="curl wget unzip tar"
|
|
||||||
PREREQDEB="dnsutils ufw"
|
|
||||||
PREREQRPM="bind-utils"
|
|
||||||
PREREQARCH="bind"
|
|
||||||
|
|
||||||
echo "Installing prerequisites"
|
# Automatic restart of services while installing
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
# Restart mode: (l)ist only, (i)nteractive or (a)utomatically.
|
||||||
sudo apt-get update
|
if [ ! -f /etc/needrestart/needrestart.conf ]
|
||||||
sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git
|
then
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
|
install_linux_package needrestart
|
||||||
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
if ! grep -rq "{restart} = 'a'" /etc/needrestart/needrestart.conf
|
||||||
# Needs more work before it can be enabled
|
then
|
||||||
# || [ "${UPSTREAM_ID}" = "suse" ]
|
# Restart mode: (l)ist only, (i)nteractive or (a)utomatically.
|
||||||
sudo yum update -y
|
sed -i "s|#\$nrconf{restart} =.*|\$nrconf{restart} = 'a'\;|g" /etc/needrestart/needrestart.conf
|
||||||
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
|
fi
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
fi
|
||||||
sudo pacman -Syu
|
|
||||||
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
# Select user for installation
|
||||||
else
|
msg_box "Rustdesk can be installed as an unprivileged user, but we need root for everything else.
|
||||||
echo "Unsupported OS"
|
Running with an unprivileged user enhances security, and is recommended."
|
||||||
# Here you could ask the user for permission to try and install anyway
|
|
||||||
# If they say yes, then do the install
|
if yesno_box_yes "Do you want to use an unprivileged user for Rustdesk?"
|
||||||
# If they say no, exit the script
|
then
|
||||||
exit 1
|
while :
|
||||||
|
do
|
||||||
|
RUSTDESK_USER=$(input_box_flow "Please enter the name of your non-root user:")
|
||||||
|
if ! id "$RUSTDESK_USER"
|
||||||
|
then
|
||||||
|
msg_box "We couldn't find $RUSTDESK_USER on the system, are you sure it's correct?
|
||||||
|
Please try again."
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
run_as_non_root_user() {
|
||||||
|
sudo -u "$RUSTDESK_USER" "$@";
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install needed dependencies
|
||||||
|
install_linux_package unzip
|
||||||
|
install_linux_package tar
|
||||||
|
install_linux_package dnsutils
|
||||||
|
install_linux_package ufw
|
||||||
|
if ! install_linux_package bind9-utils
|
||||||
|
then
|
||||||
|
install_linux_package bind-utils
|
||||||
|
fi
|
||||||
|
if ! install_linux_package bind9
|
||||||
|
then
|
||||||
|
install_linux_package bind
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setting up firewall
|
# Setting up firewall
|
||||||
sudo ufw allow 21115:21119/tcp
|
ufw allow 21115:21119/tcp
|
||||||
sudo ufw allow 22/tcp
|
ufw allow 22/tcp
|
||||||
sudo ufw allow 21116/udp
|
ufw allow 21116/udp
|
||||||
sudo ufw enable
|
|
||||||
|
|
||||||
# Make folder /var/lib/rustdesk-server/
|
|
||||||
if [ ! -d "/var/lib/rustdesk-server" ]; then
|
|
||||||
echo "Creating /var/lib/rustdesk-server"
|
|
||||||
sudo mkdir -p /var/lib/rustdesk-server/
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo chown "${uname}" -R /var/lib/rustdesk-server
|
|
||||||
cd /var/lib/rustdesk-server/ || exit 1
|
|
||||||
|
|
||||||
|
|
||||||
# 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"
|
# Download, extract, and move Rustdesk in place
|
||||||
if [ "${ARCH}" = "x86_64" ] ; then
|
if [ -n "${ARCH}" ]
|
||||||
wget https://github.com/rustdesk/rustdesk-server-pro/releases/download/1.1.8/rustdesk-server-linux-amd64.zip
|
then
|
||||||
unzip rustdesk-server-linux-amd64.zip
|
# If not /var/lib/rustdesk-server/ ($RUSTDESK_INSTALL_DIR) exists we can assume this is a fresh install. If it exists though, we can't move it and it will produce an error
|
||||||
mv amd64/static /var/lib/rustdesk-server/
|
if [ ! -d "$RUSTDESK_INSTALL_DIR" ]
|
||||||
sudo mv amd64/hbbr /usr/bin/
|
then
|
||||||
sudo mv amd64/hbbs /usr/bin/
|
print_text_in_color "$IGreen" "Installing RustDesk Server..."
|
||||||
rm -rf amd64/
|
# Create dir
|
||||||
rm -rf rustdesk-server-linux-amd64.zip
|
mkdir -p "$RUSTDESK_INSTALL_DIR"
|
||||||
elif [ "${ARCH}" = "armv7l" ] ; then
|
if [ -d "$RUSTDESK_INSTALL_DIR" ]
|
||||||
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-armv7.zip"
|
then
|
||||||
unzip rustdesk-server-linux-armv7.zip
|
cd "$RUSTDESK_INSTALL_DIR"
|
||||||
mv armv7/static /var/lib/rustdesk-server/
|
else
|
||||||
sudo mv armv7/hbbr /usr/bin/
|
msg_box "It seems like the installation folder wasn't created, we can't continue.
|
||||||
sudo mv armv7/hbbs /usr/bin/
|
Please report this to: https://github.com/rustdesk/rustdesk-server-pro/issues"
|
||||||
rm -rf armv7/
|
exit 1
|
||||||
rm -rf rustdesk-server-linux-armv7.zip
|
fi
|
||||||
elif [ "${ARCH}" = "aarch64" ] ; then
|
# Since the name of the actual tar files differs from the output of uname -m we need to rename acutal download file.
|
||||||
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8.zip"
|
# Preferably we would instead rename the download tarballs to the output of uname -m. This would make it possible to run a single $VAR for ARCH.
|
||||||
unzip rustdesk-server-linux-arm64v8.zip
|
if [ "${ARCH}" = "x86_64" ]
|
||||||
mv arm64v8/static /var/lib/rustdesk-server/
|
then
|
||||||
sudo mv arm64v8/hbbr /usr/bin/
|
ACTUAL_TAR_NAME=amd64
|
||||||
sudo mv arm64v8/hbbs /usr/bin/
|
elif [ "${ARCH}" = "armv7l" ]
|
||||||
rm -rf arm64v8/
|
then
|
||||||
rm -rf rustdesk-server-linux-arm64v8.zip
|
ACTUAL_TAR_NAME=armv7
|
||||||
|
elif [ "${ARCH}" = "aarch64" ]
|
||||||
|
then
|
||||||
|
ACTUAL_TAR_NAME=arm64v8
|
||||||
|
fi
|
||||||
|
# Download
|
||||||
|
if ! curl -fSLO --retry 3 https://github.com/rustdesk/rustdesk-server-pro/releases/download/"${RDLATEST}"/rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
||||||
|
then
|
||||||
|
msg_box "Sorry, the installation package failed to download.
|
||||||
|
This might be temporary, so please try to run the installation script again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Extract, move in place, and make it executable
|
||||||
|
tar -xf rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
||||||
|
# Set permissions
|
||||||
|
if [ -n "$RUSTDESK_USER" ]
|
||||||
|
then
|
||||||
|
chown "$RUSTDESK_USER":"$RUSTDESK_USER" -R "$RUSTDESK_INSTALL_DIR"
|
||||||
|
fi
|
||||||
|
# Move as root if RUSTDESK_USER is not set.
|
||||||
|
if [ -n "$RUSTDESK_USER" ]
|
||||||
|
then
|
||||||
|
run_as_non_root_user mv "${ACTUAL_TAR_NAME}"/static "$RUSTDESK_INSTALL_DIR"
|
||||||
|
else
|
||||||
|
mv "${ACTUAL_TAR_NAME}"/static "$RUSTDESK_INSTALL_DIR"
|
||||||
|
fi
|
||||||
|
mv "${ACTUAL_TAR_NAME}"/hbbr /usr/bin/
|
||||||
|
mv "${ACTUAL_TAR_NAME}"/hbbs /usr/bin/
|
||||||
|
rm -rf "$RUSTDESK_INSTALL_DIR"/"${ACTUAL_TAR_NAME:?}"
|
||||||
|
rm -rf rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
||||||
|
chmod +x /usr/bin/hbbs
|
||||||
|
chmod +x /usr/bin/hbbr
|
||||||
|
if [ -n "$RUSTDESK_USER" ]
|
||||||
|
then
|
||||||
|
chown "$RUSTDESK_USER":"$RUSTDESK_USER" -R /usr/bin/hbbr
|
||||||
|
chown "$RUSTDESK_USER":"$RUSTDESK_USER" -R /usr/bin/hbbr
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print_text_in_color "$IGreen" "Rustdesk server already installed."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
msg_box "Sorry, we can't figure out your distro, this script will now exit.
|
||||||
|
Please report this to: https://github.com/rustdesk/rustdesk-server-pro/issues"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo chmod +x /usr/bin/hbbs
|
|
||||||
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 "$RUSTDESK_LOG_DIR" ]
|
||||||
echo "Creating /var/log/rustdesk-server"
|
then
|
||||||
sudo mkdir -p /var/log/rustdesk-server/
|
print_text_in_color "$IGreen" "Creating $RUSTDESK_LOG_DIR"
|
||||||
|
install -d -m 700 "$RUSTDESK_LOG_DIR"
|
||||||
|
# Set permissions
|
||||||
|
if [ -n "$RUSTDESK_USER" ]
|
||||||
|
then
|
||||||
|
chown -R "$RUSTDESK_USER":"$RUSTDESK_USER" "$RUSTDESK_LOG_DIR"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
sudo chown "${uname}" -R /var/log/rustdesk-server/
|
|
||||||
|
|
||||||
# Setup systemd to launch hbbs
|
# Setup systemd to launch hbbs
|
||||||
rustdeskhbbs="$(cat << EOF
|
if [ ! -f "/etc/systemd/system/rustdesk-hbbs.service" ]
|
||||||
|
then
|
||||||
|
touch "/etc/systemd/system/rustdesk-hbbs.service"
|
||||||
|
if [ -n "$RUSTDESK_USER" ]
|
||||||
|
then
|
||||||
|
cat << HBBS_RUSTDESK_SERVICE > "/etc/systemd/system/rustdesk-hbbs.service"
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=RustDesk Signal Server
|
Description=RustDesk Signal Server
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
LimitNOFILE=1000000
|
LimitNOFILE=1000000
|
||||||
ExecStart=/usr/bin/hbbs
|
ExecStart=/usr/bin/hbbs
|
||||||
WorkingDirectory=/var/lib/rustdesk-server/
|
WorkingDirectory=$RUSTDESK_INSTALL_DIR
|
||||||
User=${uname}
|
User=${RUSTDESK_USER}
|
||||||
Group=${uname}
|
Group=${RUSTDESK_USER}
|
||||||
Restart=always
|
Restart=always
|
||||||
StandardOutput=append:/var/log/rustdesk-server/hbbs.log
|
StandardOutput=append:$RUSTDESK_LOG_DIR/hbbs.log
|
||||||
StandardError=append:/var/log/rustdesk-server/hbbs.error
|
StandardError=append:$RUSTDESK_LOG_DIR/hbbs.error
|
||||||
# Restart service after 10 seconds if node service crashes
|
# Restart service after 10 seconds if node service crashes
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
HBBS_RUSTDESK_SERVICE
|
||||||
)"
|
else
|
||||||
echo "${rustdeskhbbs}" | sudo tee /etc/systemd/system/rustdesk-hbbs.service > /dev/null
|
cat << HBBS_RUSTDESK_SERVICE > "/etc/systemd/system/rustdesk-hbbs.service"
|
||||||
sudo systemctl daemon-reload
|
[Unit]
|
||||||
sudo systemctl enable rustdesk-hbbs.service
|
Description=RustDesk Signal Server
|
||||||
sudo systemctl start rustdesk-hbbs.service
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
LimitNOFILE=1000000
|
||||||
|
ExecStart=/usr/bin/hbbs
|
||||||
|
WorkingDirectory=$RUSTDESK_INSTALL_DIR
|
||||||
|
User=root
|
||||||
|
Group=root
|
||||||
|
Restart=always
|
||||||
|
StandardOutput=append:$RUSTDESK_LOG_DIR/hbbs.log
|
||||||
|
StandardError=append:$RUSTDESK_LOG_DIR/hbbs.error
|
||||||
|
# Restart service after 10 seconds if node service crashes
|
||||||
|
RestartSec=10
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
HBBS_RUSTDESK_SERVICE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Setup systemd to launch hbbr
|
# Setup systemd to launch hbbr
|
||||||
rustdeskhbbr="$(cat << EOF
|
if [ ! -f "/etc/systemd/system/rustdesk-hbbr.service" ]
|
||||||
|
then
|
||||||
|
touch "/etc/systemd/system/rustdesk-hbbr.service"
|
||||||
|
if [ -n "$RUSTDESK_USER" ]
|
||||||
|
then
|
||||||
|
cat << HBBR_RUSTDESK_SERVICE > "/etc/systemd/system/rustdesk-hbbr.service"
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=RustDesk Relay Server
|
Description=RustDesk Relay Server
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
LimitNOFILE=1000000
|
LimitNOFILE=1000000
|
||||||
ExecStart=/usr/bin/hbbr
|
ExecStart=/usr/bin/hbbr
|
||||||
WorkingDirectory=/var/lib/rustdesk-server/
|
WorkingDirectory=$RUSTDESK_INSTALL_DIR
|
||||||
User=${uname}
|
User=${RUSTDESK_USER}
|
||||||
Group=${uname}
|
Group=${RUSTDESK_USER}
|
||||||
Restart=always
|
Restart=always
|
||||||
StandardOutput=append:/var/log/rustdesk-server/hbbr.log
|
StandardOutput=append:$RUSTDESK_LOG_DIR/hbbr.log
|
||||||
StandardError=append:/var/log/rustdesk-server/hbbr.error
|
StandardError=append:$RUSTDESK_LOG_DIR/hbbr.error
|
||||||
# Restart service after 10 seconds if node service crashes
|
# Restart service after 10 seconds if node service crashes
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
HBBR_RUSTDESK_SERVICE
|
||||||
)"
|
else
|
||||||
echo "${rustdeskhbbr}" | sudo tee /etc/systemd/system/rustdesk-hbbr.service > /dev/null
|
cat << HBBR_RUSTDESK_SERVICE > "/etc/systemd/system/rustdesk-hbbr.service"
|
||||||
sudo systemctl daemon-reload
|
[Unit]
|
||||||
sudo systemctl enable rustdesk-hbbr.service
|
Description=RustDesk Relay Server
|
||||||
sudo systemctl start rustdesk-hbbr.service
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
LimitNOFILE=1000000
|
||||||
|
ExecStart=/usr/bin/hbbr
|
||||||
|
WorkingDirectory=$RUSTDESK_INSTALL_DIR
|
||||||
|
User=root
|
||||||
|
Group=root
|
||||||
|
Restart=always
|
||||||
|
StandardOutput=append:$RUSTDESK_LOG_DIR/hbbr.log
|
||||||
|
StandardError=append:$RUSTDESK_LOG_DIR/hbbr.error
|
||||||
|
# Restart service after 10 seconds if node service crashes
|
||||||
|
RestartSec=10
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
HBBR_RUSTDESK_SERVICE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
while ! [[ $CHECK_RUSTDESK_READY ]]; do
|
# Enable services
|
||||||
CHECK_RUSTDESK_READY=$(sudo systemctl status rustdesk-hbbr.service | grep "Active: active (running)")
|
# HBBR
|
||||||
echo -ne "RustDesk Relay not ready yet...${NC}\n"
|
systemctl enable rustdesk-hbbr.service
|
||||||
sleep 3
|
systemctl start rustdesk-hbbr.service
|
||||||
|
# HBBS
|
||||||
|
systemctl enable rustdesk-hbbs.service
|
||||||
|
systemctl start rustdesk-hbbs.service
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
if ! systemctl status rustdesk-hbbr.service | grep "Active: active (running)"
|
||||||
|
then
|
||||||
|
sleep 2
|
||||||
|
print_text_in_color "$ICyan" "Waiting for RustDesk Relay service to become active..."
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
pubname=$(find /var/lib/rustdesk-server/ -name "*.pub")
|
while :
|
||||||
key=$(cat "${pubname}")
|
do
|
||||||
|
PUBKEYNAME=$(find "$RUSTDESK_INSTALL_DIR" -name "*.pub")
|
||||||
|
if [ -z "$PUBKEYNAME" ]
|
||||||
|
then
|
||||||
|
print_text_in_color "$ICyan" "Checking if public key is generated..."
|
||||||
|
sleep 5
|
||||||
|
else
|
||||||
|
print_text_in_color "$IGreen" "Public key path: $PUBKEYNAME"
|
||||||
|
PUBLICKEY=$(cat "$PUBKEYNAME")
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "Tidying up install"
|
choice=$(whiptail --title "Rustdesk installation script" --menu \
|
||||||
if [ "${ARCH}" = "x86_64" ] ; then
|
"Choose your preferred option, IP or DNS/Domain:
|
||||||
rm rustdesk-server-linux-amd64.zip
|
|
||||||
rm -rf amd64
|
|
||||||
elif [ "${ARCH}" = "armv7l" ] ; then
|
|
||||||
rm rustdesk-server-linux-armv7.zip
|
|
||||||
rm -rf armv7
|
|
||||||
elif [ "${ARCH}" = "aarch64" ] ; then
|
|
||||||
rm rustdesk-server-linux-arm64v8.zip
|
|
||||||
rm -rf arm64v8
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Choice for DNS or IP
|
DNS = Setup Rustdesk with TLS and your own domain
|
||||||
PS3='Choose your preferred option, IP or DNS/Domain:'
|
IP = You don't have a domain, only plain IP
|
||||||
WAN=("IP" "DNS/Domain")
|
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
|
||||||
select WANOPT in "${WAN[@]}"; do
|
"DNS" "(e.g. rustdesk.example.com)" \
|
||||||
case $WANOPT in
|
"IP" "($WANIP4)" 3>&1 1>&2 2>&3)
|
||||||
"IP")
|
|
||||||
wanip=$(dig @resolver4.opendns.com myip.opendns.com +short)
|
|
||||||
sudo ufw allow 21114/tcp
|
|
||||||
|
|
||||||
sudo ufw enable && ufw reload
|
case "$choice" in
|
||||||
break
|
"DNS")
|
||||||
;;
|
# Enter domain
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
RUSTDESK_DOMAIN=$(input_box_flow "Please enter your domain, e.g. rustdesk.example.com")
|
||||||
|
DIG=$(dig +short "${RUSTDESK_DOMAIN}" @resolver1.opendns.com)
|
||||||
|
if ! [[ "$RUSTDESK_DOMAIN" =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]
|
||||||
|
then
|
||||||
|
msg_box "$RUSTDESK_DOMAIN is an invalid domain/DNS address! Please try again."
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
"DNS/Domain")
|
# Check if DNS are forwarded correctly
|
||||||
echo -ne "Enter your preferred domain/DNS address ${NC}: "
|
if dig +short "$RUSTDESK_DOMAIN" @resolver1.opendns.com | grep -q "$WANIP4"
|
||||||
read wanip
|
then
|
||||||
# Check wanip is valid domain
|
print_text_in_color "$IGreen" "DNS seems correct when checking with dig!"
|
||||||
if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then
|
else
|
||||||
echo -e "${RED}Invalid domain/DNS address${NC}"
|
msg_box "DNS lookup failed with dig. The external IP ($WANIP4) \
|
||||||
exit 1
|
address of this server is not the same as the A-record ($DIG).
|
||||||
fi
|
Please check your DNS settings! Maybe the domain hasn't propagated?
|
||||||
sudo apt -y install nginx
|
Please check https://www.whatsmydns.net/#A/${RUSTDESK_DOMAIN} if the IP seems correct."
|
||||||
sudo apt -y install python3-certbot-nginx
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
rustdesknginx="$(
|
# Install packages
|
||||||
cat <<EOF
|
print_text_in_color "$IGreen" "Installing Nginx and Cerbot..."
|
||||||
|
if yesno_box_yes "We use Certbot to generate the free TLS certificate from Let's Encrypt.
|
||||||
|
The default behavior of installing Certbot is to use the snap package which auto updates, and provides the latest version of Certbot. If you don't like snap packages, you can opt out now and we'll use regular (old) deb packages instead.
|
||||||
|
|
||||||
|
Do you want to install Certbot with snap? (recommended)"
|
||||||
|
then
|
||||||
|
install_linux_package nginx
|
||||||
|
if ! install_linux_package snapd
|
||||||
|
then
|
||||||
|
print_text_in_color "$IRed" "Sorry, snapd wasn't found on your system, using 'python3-certbot-nginx' instead."
|
||||||
|
install_linux_package python3-certbot-nginx
|
||||||
|
else
|
||||||
|
snap install certbot --classic
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install_linux_package nginx
|
||||||
|
install_linux_package python3-certbot-nginx
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add Nginx config
|
||||||
|
if [ ! -f "/etc/nginx/sites-available/rustdesk.conf" ]
|
||||||
|
then
|
||||||
|
touch "/etc/nginx/sites-available/rustdesk.conf"
|
||||||
|
cat << NGINX_RUSTDESK_CONF > "/etc/nginx/sites-available/rustdesk.conf"
|
||||||
server {
|
server {
|
||||||
server_name ${wanip};
|
server_name ${RUSTDESK_DOMAIN};
|
||||||
location / {
|
location / {
|
||||||
|
proxy_set_header X-Real-IP \$remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||||
proxy_pass http://127.0.0.1:21114/;
|
proxy_pass http://127.0.0.1:21114/;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
NGINX_RUSTDESK_CONF
|
||||||
EOF
|
fi
|
||||||
)"
|
|
||||||
echo "${rustdesknginx}" | sudo tee /etc/nginx/sites-available/rustdesk.conf >/dev/null
|
|
||||||
|
|
||||||
sudo rm /etc/nginx/sites-available/default
|
# Enable the Nginx config file
|
||||||
sudo rm /etc/nginx/sites-enabled/default
|
if [ ! -f /etc/nginx/sites-enabled/rustdesk.conf ]
|
||||||
|
then
|
||||||
|
ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
|
||||||
|
fi
|
||||||
|
|
||||||
sudo ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
|
# Enable firewall rules for the domain
|
||||||
|
ufw allow 80/tcp
|
||||||
|
ufw allow 443/tcp
|
||||||
|
ufw --force enable
|
||||||
|
ufw --force reload
|
||||||
|
|
||||||
sudo ufw allow 80/tcp
|
# Generate the certifictae
|
||||||
sudo ufw allow 443/tcp
|
if ! certbot --nginx --cert-name "${RUSTDESK_DOMAIN}" --key-type ecdsa --renew-by-default --no-eff-email --agree-tos --server https://acme-v02.api.letsencrypt.org/directory -d "${RUSTDESK_DOMAIN}"
|
||||||
|
then
|
||||||
|
msg_box "Sorry, the TLS certificate for $RUSTDESK_DOMAIN failed to generate!
|
||||||
|
Please check that port 80/443 are correctly port forwarded, and that the DNS record points to this servers IP.
|
||||||
|
|
||||||
sudo ufw enable && ufw reload
|
Please try again."
|
||||||
|
exit
|
||||||
sudo certbot --nginx -d ${wanip}
|
fi
|
||||||
|
;;
|
||||||
break
|
"IP")
|
||||||
;;
|
ufw allow 21114/tcp
|
||||||
*) echo "Invalid option $REPLY";;
|
ufw --force enable
|
||||||
|
ufw --force reload
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
|
||||||
|
|
||||||
echo -e "Your IP/DNS Address is ${wanip}"
|
# Display final info!
|
||||||
echo -e "Your public key is ${key}"
|
if [ -n "$RUSTDESK_DOMAIN" ]
|
||||||
|
then
|
||||||
|
msg_box "
|
||||||
|
Your Public Key is:
|
||||||
|
$PUBLICKEY
|
||||||
|
Your DNS Address is:
|
||||||
|
$RUSTDESK_DOMAIN
|
||||||
|
|
||||||
|
Please login at https://$RUSTDESK_DOMAIN
|
||||||
|
Default User/Pass: admin/test1234"
|
||||||
|
else
|
||||||
|
msg_box "
|
||||||
|
Your Public Key is:
|
||||||
|
$PUBLICKEY
|
||||||
|
Your IP Address is:
|
||||||
|
$WANIP4
|
||||||
|
|
||||||
|
Please login at http://$WANIP4:21114
|
||||||
|
Default User/Pass: admin/test1234"
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_text_in_color "$IGreen" "Cleaning up..."
|
||||||
|
rm -f rustdesk-server-linux-"${ACTUAL_TAR_NAME}".zip
|
||||||
|
rm -rf "${ACTUAL_TAR_NAME}"
|
||||||
|
|||||||
288
lib.sh
Normal file
288
lib.sh
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
true
|
||||||
|
# see https://github.com/koalaman/shellcheck/wiki/Directive
|
||||||
|
|
||||||
|
############ Variables
|
||||||
|
|
||||||
|
# PATH & DIR
|
||||||
|
RUSTDESK_INSTALL_DIR=/var/lib/rustdesk-server
|
||||||
|
RUSTDESK_LOG_DIR=/var/log/rustdesk-server
|
||||||
|
# OS
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
get_wanip4() {
|
||||||
|
WANIP4=$(curl -s -k -m 5 -4 https://api64.ipify.org)
|
||||||
|
}
|
||||||
|
# Whiptail menus
|
||||||
|
TITLE="RustDesk - $(date +%Y)"
|
||||||
|
[ -n "$SCRIPT_NAME" ] && TITLE+=" - $SCRIPT_NAME"
|
||||||
|
CHECKLIST_GUIDE="Navigate with the [ARROW] keys and (de)select with the [SPACE] key. \
|
||||||
|
Confirm by pressing [ENTER]. Cancel by pressing [ESC]."
|
||||||
|
MENU_GUIDE="Navigate with the [ARROW] keys and confirm by pressing [ENTER]. Cancel by pressing [ESC]."
|
||||||
|
|
||||||
|
############ Functions
|
||||||
|
|
||||||
|
is_root() {
|
||||||
|
if [[ "$EUID" -ne 0 ]]
|
||||||
|
then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
root_check() {
|
||||||
|
if ! is_root
|
||||||
|
then
|
||||||
|
msg_box "Sorry, you are not root. You now have two options:
|
||||||
|
|
||||||
|
1. Use SUDO directly:
|
||||||
|
a) :~$ sudo bash name-of-script.sh
|
||||||
|
|
||||||
|
2. Become ROOT and then type your command:
|
||||||
|
a) :~$ sudo -i
|
||||||
|
b) :~# bash name-of-script.sh
|
||||||
|
|
||||||
|
More information can be found here: https://unix.stackexchange.com/a/3064"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
print_text_in_color() {
|
||||||
|
printf "%b%s%b\n" "$1" "$2" "$Color_Off"
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_box() {
|
||||||
|
[ -n "$2" ] && local SUBTITLE=" - $2"
|
||||||
|
whiptail --title "$TITLE$SUBTITLE" --msgbox "$1" "$WT_HEIGHT" "$WT_WIDTH" 3>&1 1>&2 2>&3
|
||||||
|
}
|
||||||
|
|
||||||
|
yesno_box_yes() {
|
||||||
|
[ -n "$2" ] && local SUBTITLE=" - $2"
|
||||||
|
if (whiptail --title "$TITLE$SUBTITLE" --yesno "$1" "$WT_HEIGHT" "$WT_WIDTH" 3>&1 1>&2 2>&3)
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
yesno_box_no() {
|
||||||
|
[ -n "$2" ] && local SUBTITLE=" - $2"
|
||||||
|
if (whiptail --title "$TITLE$SUBTITLE" --defaultno --yesno "$1" "$WT_HEIGHT" "$WT_WIDTH" 3>&1 1>&2 2>&3)
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
input_box() {
|
||||||
|
[ -n "$2" ] && local SUBTITLE=" - $2"
|
||||||
|
local RESULT && RESULT=$(whiptail --title "$TITLE$SUBTITLE" --nocancel --inputbox "$1" "$WT_HEIGHT" "$WT_WIDTH" 3>&1 1>&2 2>&3)
|
||||||
|
echo "$RESULT"
|
||||||
|
}
|
||||||
|
|
||||||
|
input_box_flow() {
|
||||||
|
local RESULT
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
RESULT=$(input_box "$1" "$2")
|
||||||
|
if [ -z "$RESULT" ]
|
||||||
|
then
|
||||||
|
msg_box "Input is empty, please try again." "$2"
|
||||||
|
elif ! yesno_box_yes "Is this correct? $RESULT" "$2"
|
||||||
|
then
|
||||||
|
msg_box "OK, please try again." "$2"
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "$RESULT"
|
||||||
|
}
|
||||||
|
|
||||||
|
identify_os() {
|
||||||
|
if [ -f /etc/os-release ]
|
||||||
|
then
|
||||||
|
# freedesktop.org and systemd
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source /etc/os-release
|
||||||
|
OS=$NAME
|
||||||
|
VER=$VERSION_ID
|
||||||
|
UPSTREAM_ID=${ID_LIKE,,}
|
||||||
|
|
||||||
|
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
|
||||||
|
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]
|
||||||
|
then
|
||||||
|
UPSTREAM_ID="$(echo "${ID_LIKE,,}" | sed s/\"//g | cut -d' ' -f1)"
|
||||||
|
fi
|
||||||
|
elif type lsb_release >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
# linuxbase.org
|
||||||
|
OS=$(lsb_release -si)
|
||||||
|
VER=$(lsb_release -sr)
|
||||||
|
elif [ -f /etc/lsb-release ]
|
||||||
|
then
|
||||||
|
# For some versions of Debian/Ubuntu without lsb_release command
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source /etc/os-release
|
||||||
|
OS=$DISTRIB_ID
|
||||||
|
VER=$DISTRIB_RELEASE
|
||||||
|
elif [ -f /etc/debian_version ]
|
||||||
|
then
|
||||||
|
# Older Debian, Ubuntu, etc.
|
||||||
|
OS=Debian
|
||||||
|
VER=$(cat /etc/debian_version)
|
||||||
|
elif [ -f /etc/SuSE-release ]
|
||||||
|
then
|
||||||
|
# Older SuSE, etc.
|
||||||
|
OS=SuSE
|
||||||
|
VER=$(cat /etc/SuSE-release)
|
||||||
|
elif [ -f /etc/redhat-release ]
|
||||||
|
then
|
||||||
|
# Older Red Hat, CentOS, etc.
|
||||||
|
OS=RedHat
|
||||||
|
VER=$(cat /etc/redhat-release)
|
||||||
|
else
|
||||||
|
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
||||||
|
OS=$(uname -s)
|
||||||
|
VER=$(uname -r)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_linux_package() {
|
||||||
|
# Install based on OS
|
||||||
|
# osInfo[/etc/redhat-release]=yum
|
||||||
|
# osInfo[/etc/arch-release]=pacman
|
||||||
|
# osInfo[/etc/gentoo-release]=emerge
|
||||||
|
# osInfo[/etc/SuSE-release]=zypp
|
||||||
|
# osInfo[/etc/debian_version]=apt-get
|
||||||
|
# osInfo[/etc/alpine-release]=apk
|
||||||
|
print_text_in_color "$IGreen" "Installing ${1}..."
|
||||||
|
if [ -x "$(command -v apt-get)" ]
|
||||||
|
then
|
||||||
|
sudo apt-get install "${1}" -y
|
||||||
|
elif [ -x "$(command -v apk)" ]
|
||||||
|
then
|
||||||
|
sudo apk add --no-cache "${1}"
|
||||||
|
elif [ -x "$(command -v dnf)" ]
|
||||||
|
then
|
||||||
|
sudo dnf install "${1}"
|
||||||
|
elif [ -x "$(command -v zypper)" ]
|
||||||
|
then
|
||||||
|
sudo zypper install "${1}"
|
||||||
|
elif [ -x "$(command -v pacman)" ]
|
||||||
|
then
|
||||||
|
sudo pacman -S install "${1}"
|
||||||
|
elif [ -x "$(command -v yum)" ]
|
||||||
|
then
|
||||||
|
sudo yum install "${1}"
|
||||||
|
elif [ -x "$(command -v emerge)" ]
|
||||||
|
then
|
||||||
|
sudo emerge -av "${1}"
|
||||||
|
else
|
||||||
|
print_text_in_color "$IRed" "FAILED TO INSTALL ${1}! Package manager not found: Your OS is currently unsupported."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
purge_linux_package() {
|
||||||
|
if [ -x "$(command -v apt-get)" ]
|
||||||
|
then
|
||||||
|
sudo apt-get purge --autoremove -y "${1}"
|
||||||
|
elif [ -x "$(command -v apk)" ]
|
||||||
|
then
|
||||||
|
sudo apk del "${1}"
|
||||||
|
elif [ -x "$(command -v dnf)" ]
|
||||||
|
then
|
||||||
|
sudo dnf purge "${1}"
|
||||||
|
elif [ -x "$(command -v zypper)" ]
|
||||||
|
then
|
||||||
|
sudo zypper remove "${1}"
|
||||||
|
elif [ -x "$(command -v pacman)" ]
|
||||||
|
then
|
||||||
|
sudo pacman -Rs "${1}"
|
||||||
|
elif [ -x "$(command -v yum)" ]
|
||||||
|
then
|
||||||
|
sudo yum remove "${1}"
|
||||||
|
elif [ -x "$(command -v emerge)" ]
|
||||||
|
then
|
||||||
|
sudo emerge -Cv "${1}"
|
||||||
|
else
|
||||||
|
print_text_in_color "$IRed" "FAILED TO REMOVE ${1}! Package manager not found: Your OS is currently unsupported."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## bash colors
|
||||||
|
# Reset
|
||||||
|
Color_Off='\e[0m' # Text Reset
|
||||||
|
|
||||||
|
# Regular Colors
|
||||||
|
Black='\e[0;30m' # Black
|
||||||
|
Red='\e[0;31m' # Red
|
||||||
|
Green='\e[0;32m' # Green
|
||||||
|
Yellow='\e[0;33m' # Yellow
|
||||||
|
Blue='\e[0;34m' # Blue
|
||||||
|
Purple='\e[0;35m' # Purple
|
||||||
|
Cyan='\e[0;36m' # Cyan
|
||||||
|
White='\e[0;37m' # White
|
||||||
|
|
||||||
|
# Bold
|
||||||
|
BBlack='\e[1;30m' # Black
|
||||||
|
BRed='\e[1;31m' # Red
|
||||||
|
BGreen='\e[1;32m' # Green
|
||||||
|
BYellow='\e[1;33m' # Yellow
|
||||||
|
BBlue='\e[1;34m' # Blue
|
||||||
|
BPurple='\e[1;35m' # Purple
|
||||||
|
BCyan='\e[1;36m' # Cyan
|
||||||
|
BWhite='\e[1;37m' # White
|
||||||
|
|
||||||
|
# Underline
|
||||||
|
UBlack='\e[4;30m' # Black
|
||||||
|
URed='\e[4;31m' # Red
|
||||||
|
UGreen='\e[4;32m' # Green
|
||||||
|
UYellow='\e[4;33m' # Yellow
|
||||||
|
UBlue='\e[4;34m' # Blue
|
||||||
|
UPurple='\e[4;35m' # Purple
|
||||||
|
UCyan='\e[4;36m' # Cyan
|
||||||
|
UWhite='\e[4;37m' # White
|
||||||
|
|
||||||
|
# Background
|
||||||
|
On_Black='\e[40m' # Black
|
||||||
|
On_Red='\e[41m' # Red
|
||||||
|
On_Green='\e[42m' # Green
|
||||||
|
On_Yellow='\e[43m' # Yellow
|
||||||
|
On_Blue='\e[44m' # Blue
|
||||||
|
On_Purple='\e[45m' # Purple
|
||||||
|
On_Cyan='\e[46m' # Cyan
|
||||||
|
On_White='\e[47m' # White
|
||||||
|
|
||||||
|
# High Intensity
|
||||||
|
IBlack='\e[0;90m' # Black
|
||||||
|
IRed='\e[0;91m' # Red
|
||||||
|
IGreen='\e[0;92m' # Green
|
||||||
|
IYellow='\e[0;93m' # Yellow
|
||||||
|
IBlue='\e[0;94m' # Blue
|
||||||
|
IPurple='\e[0;95m' # Purple
|
||||||
|
ICyan='\e[0;96m' # Cyan
|
||||||
|
IWhite='\e[0;97m' # White
|
||||||
|
|
||||||
|
# Bold High Intensity
|
||||||
|
BIBlack='\e[1;90m' # Black
|
||||||
|
BIRed='\e[1;91m' # Red
|
||||||
|
BIGreen='\e[1;92m' # Green
|
||||||
|
BIYellow='\e[1;93m' # Yellow
|
||||||
|
BIBlue='\e[1;94m' # Blue
|
||||||
|
BIPurple='\e[1;95m' # Purple
|
||||||
|
BICyan='\e[1;96m' # Cyan
|
||||||
|
BIWhite='\e[1;97m' # White
|
||||||
|
|
||||||
|
# High Intensity backgrounds
|
||||||
|
On_IBlack='\e[0;100m' # Black
|
||||||
|
On_IRed='\e[0;101m' # Red
|
||||||
|
On_IGreen='\e[0;102m' # Green
|
||||||
|
On_IYellow='\e[0;103m' # Yellow
|
||||||
|
On_IBlue='\e[0;104m' # Blue
|
||||||
|
On_IPurple='\e[0;105m' # Purple
|
||||||
|
On_ICyan='\e[0;106m' # Cyan
|
||||||
|
On_IWhite='\e[0;107m' # White
|
||||||
295
restore.sh
Normal file
295
restore.sh
Normal file
@@ -0,0 +1,295 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=2034,2059,2164
|
||||||
|
true
|
||||||
|
|
||||||
|
usern=$(whoami)
|
||||||
|
path=$(pwd)
|
||||||
|
echo "$path"
|
||||||
|
|
||||||
|
# Check for /var/lib/rustdesk-server/
|
||||||
|
if [ -d "/var/lib/rustdesk-server" ]; then
|
||||||
|
echo "Directory already exists so not needing to restore"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
|
||||||
|
# Identify OS
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
# freedesktop.org and systemd
|
||||||
|
source /etc/os-release
|
||||||
|
OS=$NAME
|
||||||
|
VER=$VERSION_ID
|
||||||
|
UPSTREAM_ID=${ID_LIKE,,}
|
||||||
|
|
||||||
|
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
|
||||||
|
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then
|
||||||
|
UPSTREAM_ID="$(echo "${ID_LIKE,,}" | sed s/\"//g | cut -d' ' -f1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif type lsb_release >/dev/null 2>&1; then
|
||||||
|
# linuxbase.org
|
||||||
|
OS=$(lsb_release -si)
|
||||||
|
VER=$(lsb_release -sr)
|
||||||
|
elif [ -f /etc/lsb-release ]; then
|
||||||
|
# For some versions of Debian/Ubuntu without lsb_release command
|
||||||
|
source /etc/lsb-release
|
||||||
|
OS=$DISTRIB_ID
|
||||||
|
VER=$DISTRIB_RELEASE
|
||||||
|
elif [ -f /etc/debian_version ]; then
|
||||||
|
# Older Debian, Ubuntu, etc.
|
||||||
|
OS=Debian
|
||||||
|
VER=$(cat /etc/debian_version)
|
||||||
|
elif [ -f /etc/SuSE-release ]; then
|
||||||
|
# Older SuSE, etc.
|
||||||
|
OS=SuSE
|
||||||
|
VER=$(cat /etc/SuSE-release)
|
||||||
|
elif [ -f /etc/redhat-release ]; then
|
||||||
|
# Older Red Hat, CentOS, etc.
|
||||||
|
OS=RedHat
|
||||||
|
VER=$(cat /etc/redhat-release)
|
||||||
|
else
|
||||||
|
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
||||||
|
OS=$(uname -s)
|
||||||
|
VER=$(uname -r)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Output debugging info if $DEBUG set
|
||||||
|
if [ "$DEBUG" = "true" ]; then
|
||||||
|
echo "OS: $OS"
|
||||||
|
echo "VER: $VER"
|
||||||
|
echo "UPSTREAM_ID: $UPSTREAM_ID"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup prereqs for server
|
||||||
|
# Common named prereqs
|
||||||
|
PREREQ="curl wget unzip tar"
|
||||||
|
PREREQDEB="dnsutils ufw sqlite3"
|
||||||
|
PREREQRPM="bind-utils sqlite"
|
||||||
|
PREREQARCH="bind sqlite"
|
||||||
|
|
||||||
|
echo "Installing prerequisites"
|
||||||
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y "${PREREQ}" "${PREREQDEB}" # git
|
||||||
|
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ] ; then
|
||||||
|
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
||||||
|
# Needs more work before it can be enabled
|
||||||
|
# || [ "${UPSTREAM_ID}" = "suse" ]
|
||||||
|
sudo yum update -y
|
||||||
|
sudo dnf install -y epel-release
|
||||||
|
sudo yum install -y "${PREREQ}" "${PREREQRPM}" # git
|
||||||
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
||||||
|
sudo pacman -Syu
|
||||||
|
sudo pacman -S "${PREREQ}" "${PREREQARCH}"
|
||||||
|
else
|
||||||
|
echo "Unsupported OS"
|
||||||
|
# Here you could ask the user for permission to try and install anyway
|
||||||
|
# If they say yes, then do the install
|
||||||
|
# If they say no, exit the script
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmp_dir=$(mktemp -d -t)
|
||||||
|
|
||||||
|
tar -xf "$path"/*.tar -C "$tmp_dir"
|
||||||
|
|
||||||
|
cp -rf "${tmp_dir}"/rustdesk-server/ /var/lib/
|
||||||
|
sudo chown "${usern}":"${usern}" -R /var/lib/rustdesk-server/
|
||||||
|
rm /var/lib/rustdesk-server/db.sqlite3
|
||||||
|
sqlite3 /var/lib/rustdesk-server/db.sqlite3 < "${tmp_dir}"/db_backup_file.sql
|
||||||
|
|
||||||
|
# Get current release version
|
||||||
|
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) }' | sed 's/-.*//')
|
||||||
|
|
||||||
|
cd /var/lib/rustdesk-server/
|
||||||
|
rm -rf static/
|
||||||
|
|
||||||
|
echo "Installing RustDesk Server"
|
||||||
|
if [ "${ARCH}" = "x86_64" ] ; then
|
||||||
|
wget https://github.com/rustdesk/rustdesk-server-pro/releases/download/"${RDLATEST}"/rustdesk-server-linux-amd64.tar.gz
|
||||||
|
tar -xf rustdesk-server-linux-amd64.tar.gz
|
||||||
|
mv amd64/static /var/lib/rustdesk-server/
|
||||||
|
sudo mv amd64/hbbr /usr/bin/
|
||||||
|
sudo mv amd64/hbbs /usr/bin/
|
||||||
|
rm -rf amd64/
|
||||||
|
rm -rf rustdesk-server-linux-amd64.tar.gz
|
||||||
|
elif [ "${ARCH}" = "armv7l" ] ; then
|
||||||
|
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-armv7.tar.gz"
|
||||||
|
tar -xf rustdesk-server-linux-armv7.tar.gz
|
||||||
|
mv armv7/static /var/lib/rustdesk-server/
|
||||||
|
sudo mv armv7/hbbr /usr/bin/
|
||||||
|
sudo mv armv7/hbbs /usr/bin/
|
||||||
|
rm -rf armv7/
|
||||||
|
rm -rf rustdesk-server-linux-armv7.tar.gz
|
||||||
|
elif [ "${ARCH}" = "aarch64" ] ; then
|
||||||
|
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8.tar.gz"
|
||||||
|
tar -xf rustdesk-server-linux-arm64v8.tar.gz
|
||||||
|
mv arm64v8/static /var/lib/rustdesk-server/
|
||||||
|
sudo mv arm64v8/hbbr /usr/bin/
|
||||||
|
sudo mv arm64v8/hbbs /usr/bin/
|
||||||
|
rm -rf arm64v8/
|
||||||
|
rm -rf rustdesk-server-linux-arm64v8.tar.gz
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo chmod +x /usr/bin/hbbs
|
||||||
|
sudo chmod +x /usr/bin/hbbr
|
||||||
|
|
||||||
|
# Make folder /var/log/rustdesk-server/
|
||||||
|
if [ ! -d "/var/log/rustdesk-server" ]; then
|
||||||
|
echo "Creating /var/log/rustdesk-server"
|
||||||
|
sudo mkdir -p /var/log/rustdesk-server/
|
||||||
|
fi
|
||||||
|
sudo chown "${usern}" -R /var/log/rustdesk-server/
|
||||||
|
|
||||||
|
# Setup systemd to launch hbbs
|
||||||
|
rustdeskhbbs="$(cat << EOF
|
||||||
|
[Unit]
|
||||||
|
Description=RustDesk Signal Server
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
LimitNOFILE=1000000
|
||||||
|
ExecStart=/usr/bin/hbbs
|
||||||
|
WorkingDirectory=/var/lib/rustdesk-server/
|
||||||
|
User=${usern}
|
||||||
|
Group=${usern}
|
||||||
|
Restart=always
|
||||||
|
StandardOutput=append:/var/log/rustdesk-server/hbbs.log
|
||||||
|
StandardError=append:/var/log/rustdesk-server/hbbs.error
|
||||||
|
# Restart service after 10 seconds if node service crashes
|
||||||
|
RestartSec=10
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
echo "${rustdeskhbbs}" | sudo tee /etc/systemd/system/rustdesk-hbbs.service > /dev/null
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable rustdesk-hbbs.service
|
||||||
|
sudo systemctl start rustdesk-hbbs.service
|
||||||
|
|
||||||
|
# Setup systemd to launch hbbr
|
||||||
|
rustdeskhbbr="$(cat << EOF
|
||||||
|
[Unit]
|
||||||
|
Description=RustDesk Relay Server
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
LimitNOFILE=1000000
|
||||||
|
ExecStart=/usr/bin/hbbr
|
||||||
|
WorkingDirectory=/var/lib/rustdesk-server/
|
||||||
|
User=${usern}
|
||||||
|
Group=${usern}
|
||||||
|
Restart=always
|
||||||
|
StandardOutput=append:/var/log/rustdesk-server/hbbr.log
|
||||||
|
StandardError=append:/var/log/rustdesk-server/hbbr.error
|
||||||
|
# Restart service after 10 seconds if node service crashes
|
||||||
|
RestartSec=10
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
echo "${rustdeskhbbr}" | sudo tee /etc/systemd/system/rustdesk-hbbr.service > /dev/null
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable rustdesk-hbbr.service
|
||||||
|
sudo systemctl start rustdesk-hbbr.service
|
||||||
|
|
||||||
|
while ! [[ $CHECK_RUSTDESK_READY ]]; do
|
||||||
|
CHECK_RUSTDESK_READY=$(sudo systemctl status rustdesk-hbbr.service | grep "Active: active (running)")
|
||||||
|
echo -ne "RustDesk Relay not ready yet...${NC}\n"
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
|
||||||
|
pubname=$(find /var/lib/rustdesk-server/ -name "*.pub")
|
||||||
|
key=$(cat "${pubname}")
|
||||||
|
|
||||||
|
echo "Tidying up install"
|
||||||
|
if [ "${ARCH}" = "x86_64" ] ; then
|
||||||
|
rm rustdesk-server-linux-amd64.tar.gz
|
||||||
|
rm -rf amd64
|
||||||
|
elif [ "${ARCH}" = "armv7l" ] ; then
|
||||||
|
rm rustdesk-server-linux-armv7.tar.gz
|
||||||
|
rm -rf armv7
|
||||||
|
elif [ "${ARCH}" = "aarch64" ] ; then
|
||||||
|
rm rustdesk-server-linux-arm64v8.tar.gz
|
||||||
|
rm -rf arm64v8
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "${tmp_dir:?}"/
|
||||||
|
|
||||||
|
# Choice for DNS or IP
|
||||||
|
PS3='Choose your preferred option, IP or DNS/Domain:'
|
||||||
|
WAN=("IP" "DNS/Domain")
|
||||||
|
select WANOPT in "${WAN[@]}"; do
|
||||||
|
case $WANOPT in
|
||||||
|
"IP")
|
||||||
|
wanip=$(dig @resolver4.opendns.com myip.opendns.com +short)
|
||||||
|
sudo ufw allow 21114/tcp
|
||||||
|
|
||||||
|
sudo ufw enable && ufw reload
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
|
"DNS/Domain")
|
||||||
|
echo -ne "Enter your preferred domain/DNS address ${NC}: "
|
||||||
|
read wanip
|
||||||
|
# Check wanip is valid domain
|
||||||
|
if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then
|
||||||
|
echo -e "${RED}Invalid domain/DNS address${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing nginx"
|
||||||
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
||||||
|
sudo apt -y install nginx
|
||||||
|
sudo apt -y install python3-certbot-nginx
|
||||||
|
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ] ; then
|
||||||
|
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
||||||
|
# Needs more work before it can be enabled
|
||||||
|
# || [ "${UPSTREAM_ID}" = "suse" ]
|
||||||
|
sudo yum -y install nginx
|
||||||
|
sudo yum -y install python3-certbot-nginx
|
||||||
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
||||||
|
sudo pacman -S install nginx
|
||||||
|
sudo pacman -S install python3-certbot-nginx
|
||||||
|
else
|
||||||
|
echo "Unsupported OS"
|
||||||
|
# Here you could ask the user for permission to try and install anyway
|
||||||
|
# If they say yes, then do the install
|
||||||
|
# If they say no, exit the script
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rustdesknginx="$(
|
||||||
|
cat <<EOF
|
||||||
|
server {
|
||||||
|
server_name ${wanip};
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:21114/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
echo "${rustdesknginx}" | sudo tee /etc/nginx/sites-available/rustdesk.conf >/dev/null
|
||||||
|
|
||||||
|
sudo ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
|
||||||
|
|
||||||
|
sudo ufw allow 80/tcp
|
||||||
|
sudo ufw allow 443/tcp
|
||||||
|
|
||||||
|
sudo ufw enable && ufw reload
|
||||||
|
|
||||||
|
sudo certbot --nginx -d "${wanip}"
|
||||||
|
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "Invalid option $REPLY";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -e "Your IP/DNS Address is ${wanip}"
|
||||||
|
echo -e "Your public key is ${key}"
|
||||||
|
|
||||||
|
echo -e "Restore is complete"
|
||||||
45
terms
Normal file
45
terms
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
Purslane Limited Software License Agreement
|
||||||
|
|
||||||
|
IMPORTANT: PLEASE READ THIS SOFTWARE LICENSE AGREEMENT ("LICENSE AGREEMENT") CAREFULLY BEFORE USING THE RustDesk Server Pro SOFTWARE. BY USING THE SOFTWARE, YOU (EITHER AN INDIVIDUAL OR A SINGLE ENTITY) AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE AGREEMENT, DO NOT USE THE SOFTWARE.
|
||||||
|
|
||||||
|
1. License Grant:
|
||||||
|
Subject to the terms and conditions of this License Agreement, Purslane Limited ("Licensor") grants you a non-exclusive, non-transferable license to use the RustDesk Server Pro software ("Software") for your internal business purposes. This license is granted on a per-server (per-machine) basis.
|
||||||
|
|
||||||
|
2 License Restrictions:
|
||||||
|
a) You shall not copy, modify, distribute, sell, lease, sublicense, or transfer the Software or any portion thereof.
|
||||||
|
b) You shall not reverse engineer, decompile, or disassemble the Software, except to the extent expressly permitted by applicable law.
|
||||||
|
c) You shall not remove or alter any proprietary notices or labels on the Software.
|
||||||
|
|
||||||
|
3. License Key:
|
||||||
|
a) Purslane Limited will provide you with a unique license key ("License Key") to activate the Software on a specific server (machine).
|
||||||
|
b) You agree that the License Key provided to you by Purslane Limited will be used exclusively on the designated server (machine) and will not be shared, transferred, or used on any other server (machine) without explicit written permission from Purslane Limited.
|
||||||
|
|
||||||
|
4. Term and Billing:
|
||||||
|
a) The license term for the Software shall be one (1) year, starting from the date of purchase.
|
||||||
|
b) You agree to pay the annual license fee as specified by Licensor. Failure to make timely payments may result in suspension or termination of the license.
|
||||||
|
|
||||||
|
5. Maintenance and Support:
|
||||||
|
a) Support is offered via email.
|
||||||
|
b) During the license term, Licensor may provide maintenance and support services for the Software as separately agreed upon or specified in a separate support agreement.
|
||||||
|
c) Licensor reserves the right to modify or enhance the support services at its sole discretion.
|
||||||
|
|
||||||
|
6. Intellectual Property:
|
||||||
|
a) You acknowledge that the Software and any accompanying documentation are protected by intellectual property laws and treaties.
|
||||||
|
b) You agree not to remove or alter any copyright, trademark, or other proprietary rights notices contained in or on the Software.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty:
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. LICENSOR DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||||
|
|
||||||
|
8. Limitation of Liability:
|
||||||
|
IN NO EVENT SHALL LICENSOR BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, CONSEQUENTIAL, OR PUNITIVE DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE AGREEMENT OR THE USE OF THE SOFTWARE, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
9. Termination:
|
||||||
|
This License Agreement is effective until terminated. Licensor may terminate this License Agreement immediately upon notice to you if you breach any of the terms and conditions. Upon termination, you must cease all use of the Software and destroy all copies in your possession.
|
||||||
|
|
||||||
|
10. Governing Law:
|
||||||
|
This License Agreement shall be governed by and construed in accordance with the laws of The Cayman Islands. Any legal action or proceeding arising under this License Agreement shall be brought exclusively in the courts of The Cayman Islands.
|
||||||
|
|
||||||
|
11. Entire Agreement:
|
||||||
|
This License Agreement shall be governed by and construed in accordance with the laws of the Cayman Islands. Any legal action or proceeding arising under this License Agreement shall be brought exclusively in the courts of the Cayman Islands.
|
||||||
|
|
||||||
|
By using the RustDesk Server Pro software, you acknowledge that you have read and understood this License Agreement and agree to be bound by its terms and conditions.
|
||||||
265
uninstall.sh
Normal file
265
uninstall.sh
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
##################################################################################################################
|
||||||
|
|
||||||
|
# Install curl and whiptail if needed
|
||||||
|
if [ ! -x "$(command -v curl)" ] || [ ! -x "$(command -v whiptail)" ]
|
||||||
|
then
|
||||||
|
# We need curl to fetch the lib
|
||||||
|
# There are the package managers for different OS:
|
||||||
|
# osInfo[/etc/redhat-release]=yum
|
||||||
|
# osInfo[/etc/arch-release]=pacman
|
||||||
|
# osInfo[/etc/gentoo-release]=emerge
|
||||||
|
# osInfo[/etc/SuSE-release]=zypp
|
||||||
|
# osInfo[/etc/debian_version]=apt-get
|
||||||
|
# osInfo[/etc/alpine-release]=apk
|
||||||
|
NEEDED_DEPS=(curl whiptail)
|
||||||
|
echo "Installing" "${NEEDED_DEPS[@]}"
|
||||||
|
if [ -x "$(command -v apt-get)" ]
|
||||||
|
then
|
||||||
|
sudo apt-get install "${NEEDED_DEPS[@]}" -y
|
||||||
|
elif [ -x "$(command -v apk)" ]
|
||||||
|
then
|
||||||
|
sudo apk add --no-cache "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v dnf)" ]
|
||||||
|
then
|
||||||
|
sudo dnf install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v zypper)" ]
|
||||||
|
then
|
||||||
|
sudo zypper install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v pacman)" ]
|
||||||
|
then
|
||||||
|
sudo pacman -S install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v yum)" ]
|
||||||
|
then
|
||||||
|
sudo yum install "${NEEDED_DEPS[@]}"
|
||||||
|
elif [ -x "$(command -v emerge)" ]
|
||||||
|
then
|
||||||
|
sudo emerge -av "${NEEDED_DEPS[@]}"
|
||||||
|
else
|
||||||
|
echo "FAILED TO INSTALL! Package manager not found. You must manually install:" "${NEEDED_DEPS[@]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We need to source directly from the Github repo to be able to use the functions here
|
||||||
|
# shellcheck disable=2034,2059,2164
|
||||||
|
true
|
||||||
|
SCRIPT_NAME="Uninstall script"
|
||||||
|
export SCRIPT_NAME
|
||||||
|
# shellcheck source=lib.sh
|
||||||
|
source <(curl -sL https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/lib.sh)
|
||||||
|
# see https://github.com/koalaman/shellcheck/wiki/Directive
|
||||||
|
unset SCRIPT_NAME
|
||||||
|
|
||||||
|
##################################################################################################################
|
||||||
|
|
||||||
|
# Check if root
|
||||||
|
root_check
|
||||||
|
|
||||||
|
# Output debugging info if $DEBUG set
|
||||||
|
if [ "$DEBUG" = "true" ]
|
||||||
|
then
|
||||||
|
identify_os
|
||||||
|
print_text_in_color "$ICyan" "OS: $OS"
|
||||||
|
print_text_in_color "$ICyan" "VER: $VER"
|
||||||
|
print_text_in_color "$ICyan" "UPSTREAM_ID: $UPSTREAM_ID"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Switch for Certbot
|
||||||
|
if [ -d /etc/letsencrypt ]
|
||||||
|
then
|
||||||
|
CERTBOT_SWITCH=ON
|
||||||
|
else
|
||||||
|
CERTBOT_SWITCH=OFF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Uninstall Rustdesk Menu
|
||||||
|
choice=$(whiptail --title "$TITLE" --checklist \
|
||||||
|
"Please choose what to uninstall:\n\n
|
||||||
|
$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
|
||||||
|
"certbot" "(Everything related to Let's Encrypt)" "$CERTBOT_SWITCH" \
|
||||||
|
"rustdesk-logs" "(RustDesk LOG dir)" ON \
|
||||||
|
"rustdesk-server" "(RustDesk SERVER + RustDesk services)" ON \
|
||||||
|
"nginx-rustdesk" "(RustDesk Nginx config)" OFF \
|
||||||
|
"nginx" "(Linux webserver package + ALL configs)" ON \
|
||||||
|
"ufw" "(Linux firewall package + RustDesk rules)" ON \
|
||||||
|
"whiptail" "(Linux menu package)" ON \
|
||||||
|
"curl" "(Linux package)" OFF \
|
||||||
|
"wget" "(Linux package)" OFF \
|
||||||
|
"unzip" "(Linux package)" OFF \
|
||||||
|
"dnsutils" "(Linux package)" ON \
|
||||||
|
"bind-utils" "(Linux package)" ON \
|
||||||
|
"bind" "(Linux package)" ON 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
case "$choice" in
|
||||||
|
*"nginx-rustdesk"*)
|
||||||
|
REMOVE_NGINX_CONF="yes"
|
||||||
|
;;&
|
||||||
|
*"nginx"*)
|
||||||
|
REMOVE_NGINX_ALL="yes"
|
||||||
|
;;&
|
||||||
|
*"wget"*)
|
||||||
|
REMOVE_WGET="yes"
|
||||||
|
;;&
|
||||||
|
*"whiptail"*)
|
||||||
|
REMOVE_WHIPTAIL="yes"
|
||||||
|
;;&
|
||||||
|
*"unzip"*)
|
||||||
|
REMOVE_UNZIP="yes"
|
||||||
|
;;&
|
||||||
|
*"dnsutils"*)
|
||||||
|
REMOVE_DNSUTILS="yes"
|
||||||
|
;;&
|
||||||
|
*"bind-utils"*)
|
||||||
|
REMOVE_BIND_UTILS="yes"
|
||||||
|
;;&
|
||||||
|
*"bind"*)
|
||||||
|
REMOVE_BIND="yes"
|
||||||
|
;;&
|
||||||
|
*"ufw"*)
|
||||||
|
REMOVE_UFW="yes"
|
||||||
|
;;&
|
||||||
|
*"rustdesk-logs"*)
|
||||||
|
REMOVE_RUSTDESK_LOG="yes"
|
||||||
|
;;&
|
||||||
|
*"rustdesk-server"*)
|
||||||
|
REMOVE_RUSTDESK_SERVER="yes"
|
||||||
|
;;&
|
||||||
|
*"curl"*)
|
||||||
|
REMOVE_CURL="yes"
|
||||||
|
;;&
|
||||||
|
*"certbot"*)
|
||||||
|
REMOVE_CERTBOT="yes"
|
||||||
|
;;&
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
msg_box "WARNING WARNING WARNING
|
||||||
|
|
||||||
|
This script will remove EVERYTHING that was chosen in the previous selection.
|
||||||
|
You can choose to opt out after you hit OK."
|
||||||
|
|
||||||
|
if ! yesno_box_no "Are you REALLY sure you want to continue with the uninstallation?"
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$UFW" ]
|
||||||
|
then
|
||||||
|
# Deleting UFW rules
|
||||||
|
ufw delete allow 21115:21119/tcp
|
||||||
|
# ufw delete 22/tcp # If connected to a remote VPS, this deletion will make the connection go down
|
||||||
|
ufw delete allow 21116/udp
|
||||||
|
if [ -f "/etc/nginx/sites-available/rustdesk.conf" ]
|
||||||
|
then
|
||||||
|
ufw delete allow 80/tcp
|
||||||
|
ufw delete allow 443/tcp
|
||||||
|
else
|
||||||
|
ufw delete allow 21114/tcp
|
||||||
|
fi
|
||||||
|
ufw --force disable
|
||||||
|
ufw --force reload
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Rustdesk Server
|
||||||
|
if [ -n "$REMOVE_RUSTDESK_SERVER" ]
|
||||||
|
then
|
||||||
|
# Rustdesk installation dir
|
||||||
|
print_text_in_color "$IGreen" "Removing RustDesk Server..."
|
||||||
|
rm -rf "$RUSTDESK_INSTALL_DIR"
|
||||||
|
rm -rf /usr/bin/hbbs
|
||||||
|
rm -rf /usr/bin/hbbr
|
||||||
|
|
||||||
|
# systemctl services
|
||||||
|
# HBBS
|
||||||
|
systemctl disable rustdesk-hbbs.service
|
||||||
|
systemctl stop rustdesk-hbbs.service
|
||||||
|
rm -f "/etc/systemd/system/rustdesk-hbbs.service"
|
||||||
|
# HBBR
|
||||||
|
systemctl disable rustdesk-hbbr.service
|
||||||
|
systemctl stop rustdesk-hbbr.service
|
||||||
|
rm -f "/etc/systemd/system/rustdesk-hbbr.service"
|
||||||
|
# daemon-reload
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Rustdesk LOG
|
||||||
|
if [ -n "$REMOVE_RUSTDESK_LOG" ]
|
||||||
|
then
|
||||||
|
# Rustdesk LOG dir
|
||||||
|
rm -rf "$RUSTDESK_LOG_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Certbot
|
||||||
|
if [ -n "$REMOVE_CERTBOT" ]
|
||||||
|
then
|
||||||
|
if snap list | grep -q certbot > /dev/null
|
||||||
|
then
|
||||||
|
purge_linux_package snap
|
||||||
|
snap remove certbot
|
||||||
|
else
|
||||||
|
purge_linux_package python3-certbot-nginx -y
|
||||||
|
fi
|
||||||
|
# Also remove the actual certs
|
||||||
|
rm -rf /etc/letsencrypt
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Nginx
|
||||||
|
if [ -n "$REMOVE_NGINX_CONF" ]
|
||||||
|
then
|
||||||
|
rm -f "/etc/nginx/sites-available/rustdesk.conf"
|
||||||
|
rm -f "/etc/nginx/sites-enabled/rustdesk.conf"
|
||||||
|
service nginx restart
|
||||||
|
elif [ -n "$REMOVE_NGINX_ALL" ]
|
||||||
|
then
|
||||||
|
purge_linux_package nginx
|
||||||
|
rm -rf "/etc/nginx"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The rest
|
||||||
|
if [ -n "$REMOVE_CURL" ]
|
||||||
|
then
|
||||||
|
purge_linux_package curl
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$REMOVE_WGET" ]
|
||||||
|
then
|
||||||
|
purge_linux_package wget
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$REMOVE_UNZIP" ]
|
||||||
|
then
|
||||||
|
purge_linux_package unzip
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$REMOVE_DNSUTILS" ]
|
||||||
|
then
|
||||||
|
purge_linux_package dnsutils
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$REMOVE_BIND_UTILS" ]
|
||||||
|
then
|
||||||
|
purge_linux_package bind-utils
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$REMOVE_BIND" ]
|
||||||
|
then
|
||||||
|
purge_linux_package bind
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$REMOVE_UFW" ]
|
||||||
|
then
|
||||||
|
purge_linux_package ufw
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg_box "Uninstallation complete!
|
||||||
|
|
||||||
|
Please hit OK to remove the last package."
|
||||||
|
|
||||||
|
if [ -n "$REMOVE_WHIPTAIL" ]
|
||||||
|
then
|
||||||
|
purge_linux_package whiptail
|
||||||
|
fi
|
||||||
25
update.sh
25
update.sh
@@ -1,10 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# shellcheck disable=2034,2059,2164
|
||||||
|
true
|
||||||
|
|
||||||
# Get username
|
# Get username
|
||||||
uname=$(whoami) # not used btw ... yet
|
usern=$(whoami) # not used btw ... yet
|
||||||
|
|
||||||
# Get current release version
|
# Get current release version
|
||||||
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) }' | sed 's/-.*//')
|
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) }')
|
||||||
RDCURRENT=$(/usr/bin/hbbr --version | sed -r 's/hbbr (.*)/\1/')
|
RDCURRENT=$(/usr/bin/hbbr --version | sed -r 's/hbbr (.*)/\1/')
|
||||||
|
|
||||||
if [ $RDLATEST == $RDCURRENT ]; then
|
if [ $RDLATEST == $RDCURRENT ]; then
|
||||||
@@ -81,29 +84,29 @@ rm -rf static/
|
|||||||
|
|
||||||
echo "Upgrading RustDesk Server"
|
echo "Upgrading 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/${RDLATEST}/rustdesk-server-linux-amd64.tar.gz
|
||||||
unzip rustdesk-server-linux-amd64.zip
|
tar -xf rustdesk-server-linux-amd64.tar.gz
|
||||||
mv amd64/static /var/lib/rustdesk-server/
|
mv amd64/static /var/lib/rustdesk-server/
|
||||||
sudo mv amd64/hbbr /usr/bin/
|
sudo mv amd64/hbbr /usr/bin/
|
||||||
sudo mv amd64/hbbs /usr/bin/
|
sudo mv amd64/hbbs /usr/bin/
|
||||||
rm -rf amd64/
|
rm -rf amd64/
|
||||||
rm -rf rustdesk-server-linux-amd64.zip
|
rm -rf rustdesk-server-linux-amd64.tar.gz
|
||||||
elif [ "${ARCH}" = "armv7l" ] ; then
|
elif [ "${ARCH}" = "armv7l" ] ; then
|
||||||
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-armv7.zip"
|
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-armv7.tar.gz"
|
||||||
unzip rustdesk-server-linux-armv7.zip
|
tar -xf rustdesk-server-linux-armv7.tar.gz
|
||||||
mv armv7/static /var/lib/rustdesk-server/
|
mv armv7/static /var/lib/rustdesk-server/
|
||||||
sudo mv armv7/hbbr /usr/bin/
|
sudo mv armv7/hbbr /usr/bin/
|
||||||
sudo mv armv7/hbbs /usr/bin/
|
sudo mv armv7/hbbs /usr/bin/
|
||||||
rm -rf armv7/
|
rm -rf armv7/
|
||||||
rm -rf rustdesk-server-linux-armv7.zip
|
rm -rf rustdesk-server-linux-armv7.tar.gz
|
||||||
elif [ "${ARCH}" = "aarch64" ] ; then
|
elif [ "${ARCH}" = "aarch64" ] ; then
|
||||||
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8.zip"
|
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8.tar.gz"
|
||||||
unzip rustdesk-server-linux-arm64v8.zip
|
tar -xf rustdesk-server-linux-arm64v8.tar.gz
|
||||||
mv arm64v8/static /var/lib/rustdesk-server/
|
mv arm64v8/static /var/lib/rustdesk-server/
|
||||||
sudo mv arm64v8/hbbr /usr/bin/
|
sudo mv arm64v8/hbbr /usr/bin/
|
||||||
sudo mv arm64v8/hbbs /usr/bin/
|
sudo mv arm64v8/hbbs /usr/bin/
|
||||||
rm -rf arm64v8/
|
rm -rf arm64v8/
|
||||||
rm -rf rustdesk-server-linux-arm64v8.zip
|
rm -rf rustdesk-server-linux-arm64v8.tar.gz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo chmod +x /usr/bin/hbbs
|
sudo chmod +x /usr/bin/hbbs
|
||||||
|
|||||||
Reference in New Issue
Block a user