commit
53a6765771
193
install.sh
193
install.sh
@ -1,131 +1,88 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# shellcheck disable=2034,2059,2164
|
|
||||||
true
|
|
||||||
# see https://github.com/koalaman/shellcheck/wiki/Directive
|
|
||||||
|
|
||||||
# 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 ("$RUSTDESK_LOG_DIR")
|
# 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
|
||||||
|
|
||||||
##################################################################################################################
|
##################################################################################################################
|
||||||
|
|
||||||
if [[ "$EUID" -ne 0 ]]
|
# 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)
|
||||||
|
if [ -x "$(command -v apt-get)" ]
|
||||||
then
|
then
|
||||||
echo "Sorry, you are not root. You now have two options:"
|
sudo apt-get install "${NEEDED_DEPS[@]}" -y
|
||||||
echo
|
elif [ -x "$(command -v apk)" ]
|
||||||
echo "1. Use SUDO directly:"
|
|
||||||
echo " a) :~$ sudo bash install.sh"
|
|
||||||
echo
|
|
||||||
echo "2. Become ROOT and then type your command:"
|
|
||||||
echo " a) :~$ sudo -i"
|
|
||||||
echo " b) :~# bash install.sh"
|
|
||||||
echo
|
|
||||||
echo "More information can be found here: https://unix.stackexchange.com/a/3064"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Identify OS
|
|
||||||
if [ -f /etc/os-release ]
|
|
||||||
then
|
then
|
||||||
# freedesktop.org and systemd
|
sudo apk add --no-cache "${NEEDED_DEPS[@]}"
|
||||||
# shellcheck source=/dev/null
|
elif [ -x "$(command -v dnf)" ]
|
||||||
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
|
then
|
||||||
# linuxbase.org
|
sudo dnf install "${NEEDED_DEPS[@]}"
|
||||||
OS=$(lsb_release -si)
|
elif [ -x "$(command -v zypper)" ]
|
||||||
VER=$(lsb_release -sr)
|
|
||||||
elif [ -f /etc/lsb-release ]
|
|
||||||
then
|
then
|
||||||
# For some versions of Debian/Ubuntu without lsb_release command
|
sudo zypper install "${NEEDED_DEPS[@]}"
|
||||||
# shellcheck source=/dev/null
|
elif [ -x "$(command -v pacman)" ]
|
||||||
source /etc/os-release
|
|
||||||
OS=$DISTRIB_ID
|
|
||||||
VER=$DISTRIB_RELEASE
|
|
||||||
elif [ -f /etc/debian_version ]
|
|
||||||
then
|
then
|
||||||
# Older Debian, Ubuntu, etc.
|
sudo pacman -S install "${NEEDED_DEPS[@]}"
|
||||||
OS=Debian
|
elif [ -x "$(command -v yum)" ]
|
||||||
VER=$(cat /etc/debian_version)
|
|
||||||
elif [ -f /etc/SuSE-release ]
|
|
||||||
then
|
then
|
||||||
# Older SuSE, etc.
|
sudo yum install "${NEEDED_DEPS[@]}"
|
||||||
OS=SuSE
|
elif [ -x "$(command -v emerge)" ]
|
||||||
VER=$(cat /etc/SuSE-release)
|
|
||||||
elif [ -f /etc/redhat-release ]
|
|
||||||
then
|
then
|
||||||
# Older Red Hat, CentOS, etc.
|
sudo emerge -av "${NEEDED_DEPS[@]}"
|
||||||
OS=RedHat
|
|
||||||
VER=$(cat /etc/redhat-release)
|
|
||||||
else
|
else
|
||||||
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
echo "FAILED TO INSTALL PACKAGE! Package manager not found. You must manually install:" "${NEEDED_DEPS[@]}"
|
||||||
OS=$(uname -s)
|
|
||||||
VER=$(uname -r)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Setup prereqs for server
|
|
||||||
# Common named prereqs
|
|
||||||
PREREQ=(curl wget unzip tar whiptail)
|
|
||||||
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
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y "${PREREQ[@]}" "${PREREQDEB[@]}"
|
|
||||||
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" ]
|
|
||||||
yum update -y
|
|
||||||
yum install -y "${PREREQ[@]}" "${PREREQRPM[@]}" # git
|
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]
|
|
||||||
then
|
|
||||||
pacman -Syu
|
|
||||||
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download the lib file
|
|
||||||
if ! curl -fSL https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/lib.sh -o lib.sh
|
|
||||||
then
|
|
||||||
echo "Failed to download the lib.sh file. Please try again"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# We need to source directly from the Github repo to be able to use the functions here
|
||||||
# shellcheck disable=2034,2059,2164
|
# shellcheck disable=2034,2059,2164
|
||||||
true
|
true
|
||||||
|
SCRIPT_NAME="Install script"
|
||||||
|
export SCRIPT_NAME
|
||||||
# shellcheck source=lib.sh
|
# shellcheck source=lib.sh
|
||||||
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
|
||||||
|
|
||||||
|
##################################################################################################################
|
||||||
|
|
||||||
|
# This must run as root
|
||||||
|
root_check
|
||||||
|
|
||||||
|
# We need the WAN IP
|
||||||
|
get_wanip4
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
# Select user for installation
|
# Select user for installation
|
||||||
msg_box "Rustdesk needs to be installed as root, but you can still do some parts as an unprivileged user.
|
msg_box "Rustdesk can be installed as an unprivileged user, but we need root for everything else.
|
||||||
Running with an unprivileged user enhances security, and is recommended."
|
Running with an unprivileged user enhances security, and is recommended."
|
||||||
|
|
||||||
if yesno_box_yes "Do you want to use an unprivileged user where it's possible?"
|
if yesno_box_yes "Do you want to use an unprivileged user for Rustdesk?"
|
||||||
then
|
then
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
@ -149,6 +106,7 @@ fi
|
|||||||
# Output debugging info if $DEBUG set
|
# Output debugging info if $DEBUG set
|
||||||
if [ "$DEBUG" = "true" ]
|
if [ "$DEBUG" = "true" ]
|
||||||
then
|
then
|
||||||
|
identify_os
|
||||||
print_text_in_color "$ICyan" "OS: $OS"
|
print_text_in_color "$ICyan" "OS: $OS"
|
||||||
print_text_in_color "$ICyan" "VER: $VER"
|
print_text_in_color "$ICyan" "VER: $VER"
|
||||||
print_text_in_color "$ICyan" "UPSTREAM_ID: $UPSTREAM_ID"
|
print_text_in_color "$ICyan" "UPSTREAM_ID: $UPSTREAM_ID"
|
||||||
@ -406,41 +364,27 @@ Please check https://www.whatsmydns.net/#A/${RUSTDESK_DOMAIN} if the IP seems co
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Install packages
|
||||||
print_text_in_color "$IGreen" "Installing Nginx"
|
print_text_in_color "$IGreen" "Installing Nginx and Cerbot..."
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]
|
if yesno_box_yes "We use Certbot to generate the free TLS certificate from Let's Encrypt.
|
||||||
then
|
|
||||||
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.
|
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)"
|
Do you want to install Certbot with snap? (recommended)"
|
||||||
|
then
|
||||||
|
install_linux_package nginx
|
||||||
|
if ! install_linux_package snapd
|
||||||
then
|
then
|
||||||
apt-get install nginx -y
|
print_text_in_color "$IRed" "Sorry, snapd wasn't found on your system, reverting to python-certbot."
|
||||||
apt-get install snapd -y
|
install_linux_package python3-certbot-nginx
|
||||||
snap install certbot --classic
|
|
||||||
else
|
else
|
||||||
apt-get install nginx -y
|
snap install certbot --classic
|
||||||
apt-get install python3-certbot-nginx -y
|
|
||||||
fi
|
fi
|
||||||
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" ]
|
|
||||||
yum -y install nginx
|
|
||||||
yum -y install python3-certbot-nginx
|
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]
|
|
||||||
then
|
|
||||||
pacman -S install nginx
|
|
||||||
pacman -S install python3-certbot-nginx
|
|
||||||
else
|
else
|
||||||
msg_box "Sorry, your OS is unsupported"
|
install_linux_package nginx
|
||||||
if ! yesno_box_no "It might work anyway though... Do you want to give it a shot?"
|
install_linux_package python3-certbot-nginx
|
||||||
then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Add Nginx config
|
||||||
if [ ! -f "/etc/nginx/sites-available/rustdesk.conf" ]
|
if [ ! -f "/etc/nginx/sites-available/rustdesk.conf" ]
|
||||||
then
|
then
|
||||||
rm -f "/etc/nginx/sites-available/rustdesk.conf"
|
rm -f "/etc/nginx/sites-available/rustdesk.conf"
|
||||||
@ -518,4 +462,3 @@ fi
|
|||||||
print_text_in_color "$IGreen" "Cleaning up..."
|
print_text_in_color "$IGreen" "Cleaning up..."
|
||||||
rm -f rustdesk-server-linux-"${ACTUAL_TAR_NAME}".zip
|
rm -f rustdesk-server-linux-"${ACTUAL_TAR_NAME}".zip
|
||||||
rm -rf "${ACTUAL_TAR_NAME}"
|
rm -rf "${ACTUAL_TAR_NAME}"
|
||||||
rm -f lib.sh
|
|
||||||
|
31
lib.sh
31
lib.sh
@ -11,8 +11,9 @@ RUSTDESK_INSTALL_DIR=/var/lib/rustdesk-server
|
|||||||
RUSTDESK_LOG_DIR=/var/log/rustdesk-server
|
RUSTDESK_LOG_DIR=/var/log/rustdesk-server
|
||||||
# OS
|
# OS
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
# Network
|
get_wanip4() {
|
||||||
WANIP4=$(curl -s -k -m 5 -4 https://api64.ipify.org)
|
WANIP4=$(curl -s -k -m 5 -4 https://api64.ipify.org)
|
||||||
|
}
|
||||||
# Whiptail menus
|
# Whiptail menus
|
||||||
TITLE="RustDesk - $(date +%Y)"
|
TITLE="RustDesk - $(date +%Y)"
|
||||||
[ -n "$SCRIPT_NAME" ] && TITLE+=" - $SCRIPT_NAME"
|
[ -n "$SCRIPT_NAME" ] && TITLE+=" - $SCRIPT_NAME"
|
||||||
@ -22,6 +23,32 @@ MENU_GUIDE="Navigate with the [ARROW] keys and confirm by pressing [ENTER]. Canc
|
|||||||
|
|
||||||
############ Functions
|
############ 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() {
|
print_text_in_color() {
|
||||||
printf "%b%s%b\n" "$1" "$2" "$Color_Off"
|
printf "%b%s%b\n" "$1" "$2" "$Color_Off"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user