Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bb76c2e9d | ||
|
|
5696f381c8 | ||
|
|
2e0388ec0c | ||
|
|
40855c65a3 | ||
|
|
4f46a53c77 | ||
|
|
43a8b5ce1a | ||
|
|
724593a77b | ||
|
|
6a9a726a65 | ||
|
|
87cb900da8 | ||
|
|
ef0785c03d | ||
|
|
c7ac7a628c | ||
|
|
33ff465148 | ||
|
|
e0138ceb39 | ||
|
|
39a769db72 |
157
backup.sh
157
backup.sh
@@ -1,157 +0,0 @@
|
|||||||
#!/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
|
|
||||||
32
install.sh
32
install.sh
@@ -12,6 +12,13 @@
|
|||||||
|
|
||||||
##################################################################################################################
|
##################################################################################################################
|
||||||
|
|
||||||
|
TLS=""
|
||||||
|
if command -v ldconfig &> /dev/null; then
|
||||||
|
if ldconfig -p | grep -q "libssl.so.3"; then
|
||||||
|
TLS="-nativetls"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Install curl and whiptail if needed
|
# Install curl and whiptail if needed
|
||||||
if [ ! -x "$(command -v curl)" ] || [ ! -x "$(command -v whiptail)" ]
|
if [ ! -x "$(command -v curl)" ] || [ ! -x "$(command -v whiptail)" ]
|
||||||
then
|
then
|
||||||
@@ -166,6 +173,7 @@ Please report this to: https://github.com/rustdesk/rustdesk-server-pro/issues"
|
|||||||
then
|
then
|
||||||
ACTUAL_TAR_NAME=arm64v8
|
ACTUAL_TAR_NAME=arm64v8
|
||||||
fi
|
fi
|
||||||
|
ACTUAL_TAR_NAME=${ACTUAL_TAR_NAME}${TLS}
|
||||||
# Download
|
# Download
|
||||||
if ! curl -fSLO --retry 3 https://github.com/rustdesk/rustdesk-server-pro/releases/download/"${RDLATEST}"/rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
if ! curl -fSLO --retry 3 https://github.com/rustdesk/rustdesk-server-pro/releases/download/"${RDLATEST}"/rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
||||||
then
|
then
|
||||||
@@ -189,14 +197,17 @@ This might be temporary, so please try to run the installation script again."
|
|||||||
fi
|
fi
|
||||||
mv "${ACTUAL_TAR_NAME}"/hbbr /usr/bin/
|
mv "${ACTUAL_TAR_NAME}"/hbbr /usr/bin/
|
||||||
mv "${ACTUAL_TAR_NAME}"/hbbs /usr/bin/
|
mv "${ACTUAL_TAR_NAME}"/hbbs /usr/bin/
|
||||||
|
mv "${ACTUAL_TAR_NAME}"/rustdesk-utils /usr/bin/
|
||||||
rm -rf "$RUSTDESK_INSTALL_DIR"/"${ACTUAL_TAR_NAME:?}"
|
rm -rf "$RUSTDESK_INSTALL_DIR"/"${ACTUAL_TAR_NAME:?}"
|
||||||
rm -rf rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
rm -rf rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
||||||
chmod +x /usr/bin/hbbs
|
chmod +x /usr/bin/hbbs
|
||||||
chmod +x /usr/bin/hbbr
|
chmod +x /usr/bin/hbbr
|
||||||
|
chmod +x /usr/bin/rustdesk-utils
|
||||||
if [ -n "$RUSTDESK_USER" ]
|
if [ -n "$RUSTDESK_USER" ]
|
||||||
then
|
then
|
||||||
chown "$RUSTDESK_USER":"$RUSTDESK_USER" -R /usr/bin/hbbr
|
chown "$RUSTDESK_USER":"$RUSTDESK_USER" -R /usr/bin/hbbr
|
||||||
chown "$RUSTDESK_USER":"$RUSTDESK_USER" -R /usr/bin/hbbr
|
chown "$RUSTDESK_USER":"$RUSTDESK_USER" -R /usr/bin/hbbs
|
||||||
|
chown "$RUSTDESK_USER":"$RUSTDESK_USER" -R /usr/bin/rustdesk-utils
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
print_text_in_color "$IGreen" "Rustdesk server already installed."
|
print_text_in_color "$IGreen" "Rustdesk server already installed."
|
||||||
@@ -401,10 +412,21 @@ Do you want to install Certbot with snap? (recommended)"
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Add Nginx config
|
# Add Nginx config
|
||||||
if [ ! -f "/etc/nginx/sites-available/rustdesk.conf" ]
|
if [ -d "/etc/nginx/sites-available" ] && [ -d "/etc/nginx/sites-enabled" ]
|
||||||
then
|
then
|
||||||
touch "/etc/nginx/sites-available/rustdesk.conf"
|
SITES_CONF_DIR="sites-available"
|
||||||
cat << NGINX_RUSTDESK_CONF > "/etc/nginx/sites-available/rustdesk.conf"
|
elif [ -d "/etc/nginx/conf.d" ]
|
||||||
|
then
|
||||||
|
SITES_CONF_DIR="conf.d"
|
||||||
|
else
|
||||||
|
msg_box "Couldn't find the Nginx config directory. Please check your system!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "/etc/nginx/$SITES_CONF_DIR/rustdesk.conf" ]
|
||||||
|
then
|
||||||
|
touch "/etc/nginx/$SITES_CONF_DIR/rustdesk.conf"
|
||||||
|
cat << NGINX_RUSTDESK_CONF > "/etc/nginx/$SITES_CONF_DIR/rustdesk.conf"
|
||||||
server {
|
server {
|
||||||
server_name ${RUSTDESK_DOMAIN};
|
server_name ${RUSTDESK_DOMAIN};
|
||||||
location / {
|
location / {
|
||||||
@@ -417,7 +439,7 @@ NGINX_RUSTDESK_CONF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Enable the Nginx config file
|
# Enable the Nginx config file
|
||||||
if [ ! -f /etc/nginx/sites-enabled/rustdesk.conf ]
|
if [ "$SITES_CONF_DIR" = "sites-available" ] && [ ! -f /etc/nginx/sites-enabled/rustdesk.conf ]
|
||||||
then
|
then
|
||||||
ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
|
ln -s /etc/nginx/sites-available/rustdesk.conf /etc/nginx/sites-enabled/rustdesk.conf
|
||||||
fi
|
fi
|
||||||
|
|||||||
295
restore.sh
295
restore.sh
@@ -1,295 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
@@ -153,7 +153,7 @@ then
|
|||||||
ufw delete allow 21115:21119/tcp
|
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 22/tcp # If connected to a remote VPS, this deletion will make the connection go down
|
||||||
ufw delete allow 21116/udp
|
ufw delete allow 21116/udp
|
||||||
if [ -f "/etc/nginx/sites-available/rustdesk.conf" ]
|
if [ -f "/etc/nginx/sites-available/rustdesk.conf" ] || [ -f "/etc/nginx/conf.d/rustdesk.conf" ]
|
||||||
then
|
then
|
||||||
ufw delete allow 80/tcp
|
ufw delete allow 80/tcp
|
||||||
ufw delete allow 443/tcp
|
ufw delete allow 443/tcp
|
||||||
@@ -212,6 +212,7 @@ if [ -n "$REMOVE_NGINX_CONF" ]
|
|||||||
then
|
then
|
||||||
rm -f "/etc/nginx/sites-available/rustdesk.conf"
|
rm -f "/etc/nginx/sites-available/rustdesk.conf"
|
||||||
rm -f "/etc/nginx/sites-enabled/rustdesk.conf"
|
rm -f "/etc/nginx/sites-enabled/rustdesk.conf"
|
||||||
|
rm -f "/etc/nginx/conf.d/rustdesk.conf"
|
||||||
service nginx restart
|
service nginx restart
|
||||||
elif [ -n "$REMOVE_NGINX_ALL" ]
|
elif [ -n "$REMOVE_NGINX_ALL" ]
|
||||||
then
|
then
|
||||||
|
|||||||
39
update.sh
39
update.sh
@@ -3,6 +3,13 @@
|
|||||||
# shellcheck disable=2034,2059,2164
|
# shellcheck disable=2034,2059,2164
|
||||||
true
|
true
|
||||||
|
|
||||||
|
TLS=""
|
||||||
|
if command -v ldconfig &> /dev/null; then
|
||||||
|
if ldconfig -p | grep -q "libssl.so.3"; then
|
||||||
|
TLS="-nativetls"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Get username
|
# Get username
|
||||||
usern=$(whoami) # not used btw ... yet
|
usern=$(whoami) # not used btw ... yet
|
||||||
|
|
||||||
@@ -84,33 +91,37 @@ 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/${RDLATEST}/rustdesk-server-linux-amd64.tar.gz
|
wget https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-amd64${TLS}.tar.gz
|
||||||
tar -xf rustdesk-server-linux-amd64.tar.gz
|
tar -xf rustdesk-server-linux-amd64${TLS}.tar.gz
|
||||||
mv amd64/static /var/lib/rustdesk-server/
|
mv amd64${TLS}/static /var/lib/rustdesk-server/
|
||||||
sudo mv amd64/hbbr /usr/bin/
|
sudo mv amd64${TLS}/hbbr /usr/bin/
|
||||||
sudo mv amd64/hbbs /usr/bin/
|
sudo mv amd64${TLS}/hbbs /usr/bin/
|
||||||
rm -rf amd64/
|
sudo mv amd64${TLS}/rustdesk-utils /usr/bin/
|
||||||
rm -rf rustdesk-server-linux-amd64.tar.gz
|
rm -rf amd64${TLS}/
|
||||||
|
rm -rf rustdesk-server-linux-amd64${TLS}.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.tar.gz"
|
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
|
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/
|
||||||
|
sudo mv armv7/rustdesk-utils /usr/bin/
|
||||||
rm -rf armv7/
|
rm -rf armv7/
|
||||||
rm -rf rustdesk-server-linux-armv7.tar.gz
|
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.tar.gz"
|
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8${TLS}.tar.gz"
|
||||||
tar -xf rustdesk-server-linux-arm64v8.tar.gz
|
tar -xf rustdesk-server-linux-arm64v8${TLS}.tar.gz
|
||||||
mv arm64v8/static /var/lib/rustdesk-server/
|
mv arm64v8${TLS}/static /var/lib/rustdesk-server/
|
||||||
sudo mv arm64v8/hbbr /usr/bin/
|
sudo mv arm64v8${TLS}/hbbr /usr/bin/
|
||||||
sudo mv arm64v8/hbbs /usr/bin/
|
sudo mv arm64v8${TLS}/hbbs /usr/bin/
|
||||||
rm -rf arm64v8/
|
sudo mv arm64v8${TLS}/rustdesk-utils /usr/bin/
|
||||||
rm -rf rustdesk-server-linux-arm64v8.tar.gz
|
rm -rf arm64v8${TLS}/
|
||||||
|
rm -rf rustdesk-server-linux-arm64v8${TLS}.tar.gz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo chmod +x /usr/bin/hbbs
|
sudo chmod +x /usr/bin/hbbs
|
||||||
sudo chmod +x /usr/bin/hbbr
|
sudo chmod +x /usr/bin/hbbr
|
||||||
|
sudo chmod +x /usr/bin/rustdesk-utils
|
||||||
|
|
||||||
sudo systemctl start rustdesk-hbbs.service
|
sudo systemctl start rustdesk-hbbs.service
|
||||||
sudo systemctl start rustdesk-hbbr.service
|
sudo systemctl start rustdesk-hbbr.service
|
||||||
|
|||||||
Reference in New Issue
Block a user