installation script tuning
This commit is contained in:
125
install.sh
125
install.sh
@@ -1,7 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
# 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
|
# 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
|
||||||
@@ -14,118 +18,25 @@ true
|
|||||||
|
|
||||||
##################################################################################################################
|
##################################################################################################################
|
||||||
|
|
||||||
if [[ "$EUID" -ne 0 ]]
|
# This must run as root
|
||||||
then
|
root_check
|
||||||
echo "Sorry, you are not root. You now have two options:"
|
|
||||||
echo
|
|
||||||
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
|
# Install needed dependencies
|
||||||
if [ -f /etc/os-release ]
|
install_linux_package curl
|
||||||
then
|
install_linux_package wget
|
||||||
# freedesktop.org and systemd
|
install_linux_package unzip
|
||||||
# shellcheck source=/dev/null
|
install_linux_package tar
|
||||||
source /etc/os-release
|
install_linux_package whiptail
|
||||||
OS=$NAME
|
install_linux_package dnsutils
|
||||||
VER=$VERSION_ID
|
install_linux_package ufw
|
||||||
UPSTREAM_ID=${ID_LIKE,,}
|
install_linux_package bind-utils
|
||||||
|
install_linux_package bind
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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
|
|
||||||
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
|
|
||||||
|
|
||||||
# shellcheck disable=2034,2059,2164
|
|
||||||
true
|
|
||||||
# shellcheck source=lib.sh
|
|
||||||
source lib.sh
|
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
Reference in New Issue
Block a user