starting to look like something shiny
This commit is contained in:
367
install.sh
367
install.sh
@@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# TEEEEEEEST
|
||||||
|
sudo rm -Rf /usr/bin/hbbr /usr/bin/hbbs /var/log/rustdesk-server /var/lib/rustdesk-server
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
true
|
true
|
||||||
# see https://github.com/koalaman/shellcheck/wiki/Directive
|
# see https://github.com/koalaman/shellcheck/wiki/Directive
|
||||||
@@ -12,11 +15,29 @@ true
|
|||||||
# 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
|
# Download the lib file
|
||||||
usern=$(whoami)
|
if ! curl -fSL --retry 3 https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/lib.sh -o /tmp/lib.sh
|
||||||
# Not used?
|
then
|
||||||
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16)
|
echo "Failed to download the lib.sh file. Please try again"
|
||||||
export admintoken
|
fi
|
||||||
|
|
||||||
|
# shellcheck source=lib.sh
|
||||||
|
source /tmp/lib.sh
|
||||||
|
|
||||||
|
if [[ "$EUID" -ne 0 ]]
|
||||||
|
then
|
||||||
|
msg_box "Sorry, you are not root. You now have two options:
|
||||||
|
|
||||||
|
1. Use SUDO directly:
|
||||||
|
a) :~$ sudo bash install.sh
|
||||||
|
|
||||||
|
2. Become ROOT and then type your command:
|
||||||
|
a) :~$ sudo -i
|
||||||
|
b) :~# bash install.sh
|
||||||
|
|
||||||
|
More information can be found here: https://unix.stackexchange.com/a/3064"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
@@ -72,6 +93,29 @@ fi
|
|||||||
# shellcheck source=lib.sh
|
# shellcheck source=lib.sh
|
||||||
source ./lib.sh
|
source ./lib.sh
|
||||||
|
|
||||||
|
# Select user for installation
|
||||||
|
msg_box "Rustdesk needs to be installed as root, but you can still do some parts as an unprivileged user.
|
||||||
|
Running with an unprivileged user enhances security, and is recomended."
|
||||||
|
|
||||||
|
if yesno_box_yes "Do you want to use an unprivileged user where it's possible?"
|
||||||
|
then
|
||||||
|
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
|
||||||
|
|
||||||
# Output debugging info if $DEBUG set
|
# Output debugging info if $DEBUG set
|
||||||
if [ "$DEBUG" = "true" ]
|
if [ "$DEBUG" = "true" ]
|
||||||
then
|
then
|
||||||
@@ -91,19 +135,19 @@ PREREQARCH=(bind)
|
|||||||
print_text_in_color "$IGreen" "Installing prerequisites"
|
print_text_in_color "$IGreen" "Installing prerequisites"
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]
|
||||||
then
|
then
|
||||||
sudo apt-get update
|
apt-get update
|
||||||
sudo apt-get install -y "${PREREQ[@]}" "${PREREQDEB[@]}" # git
|
apt-get install -y "${PREREQ[@]}" "${PREREQDEB[@]}" # git
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ]
|
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ]
|
||||||
then
|
then
|
||||||
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
||||||
# Needs more work before it can be enabled
|
# Needs more work before it can be enabled
|
||||||
# || [ "${UPSTREAM_ID}" = "suse" ]
|
# || [ "${UPSTREAM_ID}" = "suse" ]
|
||||||
sudo yum update -y
|
yum update -y
|
||||||
sudo yum install -y "${PREREQ[@]}" "${PREREQRPM[@]}" # git
|
yum install -y "${PREREQ[@]}" "${PREREQRPM[@]}" # git
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]
|
||||||
then
|
then
|
||||||
sudo pacman -Syu
|
pacman -Syu
|
||||||
sudo pacman -S "${PREREQ[@]}" "${PREREQARCH[@]}"
|
pacman -S "${PREREQ[@]}" "${PREREQARCH[@]}"
|
||||||
else
|
else
|
||||||
print_text_in_color "$IRed" "Unsupported OS"
|
print_text_in_color "$IRed" "Unsupported OS"
|
||||||
# Here you could ask the user for permission to try and install anyway
|
# Here you could ask the user for permission to try and install anyway
|
||||||
@@ -113,10 +157,10 @@ else
|
|||||||
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
|
ufw enable
|
||||||
|
|
||||||
# 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) }')
|
||||||
@@ -129,12 +173,13 @@ then
|
|||||||
then
|
then
|
||||||
print_text_in_color "$IGreen" "Installing RustDesk Server..."
|
print_text_in_color "$IGreen" "Installing RustDesk Server..."
|
||||||
# Create dir
|
# Create dir
|
||||||
sudo mkdir -p "$RUSTDESK_INSTALL_DIR"
|
mkdir -p "$RUSTDESK_INSTALL_DIR"
|
||||||
|
chown -R "$RUSTDESK_USER":"$RUSTDESK_USER" "$RUSTDESK_INSTALL_DIR"
|
||||||
if [ -d "$RUSTDESK_INSTALL_DIR" ]
|
if [ -d "$RUSTDESK_INSTALL_DIR" ]
|
||||||
then
|
then
|
||||||
cd "$RUSTDESK_INSTALL_DIR"
|
cd "$RUSTDESK_INSTALL_DIR"
|
||||||
# Set permissions
|
# Set permissions
|
||||||
sudo chown "${usern}" -R "$RUSTDESK_INSTALL_DIR"
|
chown "${usern}" -R "$RUSTDESK_INSTALL_DIR"
|
||||||
else
|
else
|
||||||
msg_box "It seems like the installation folder wasn't created, we can't continue.
|
msg_box "It seems like the installation folder wasn't created, we can't continue.
|
||||||
Please report this to: https://github.com/rustdesk/rustdesk-server-pro/issues"
|
Please report this to: https://github.com/rustdesk/rustdesk-server-pro/issues"
|
||||||
@@ -161,13 +206,14 @@ This might be temporary, so please try to run the installation script again."
|
|||||||
fi
|
fi
|
||||||
# Extract, move in place, and make it executable
|
# Extract, move in place, and make it executable
|
||||||
tar -xf rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
tar -xf rustdesk-server-linux-"${ACTUAL_TAR_NAME}".tar.gz
|
||||||
mv "${ACTUAL_TAR_NAME}"/static "$RUSTDESK_INSTALL_DIR"
|
chown -R "$RUSTDESK_USER":"$RUSTDESK_USER" "$RUSTDESK_INSTALL_DIR"
|
||||||
sudo mv "${ACTUAL_TAR_NAME}"/hbbr /usr/bin/
|
run_as_non_root_user mv "${ACTUAL_TAR_NAME}"/static "$RUSTDESK_INSTALL_DIR"
|
||||||
sudo mv "${ACTUAL_TAR_NAME}"/hbbs /usr/bin/
|
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_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
|
||||||
sudo chmod +x /usr/bin/hbbs
|
chmod +x /usr/bin/hbbs
|
||||||
sudo chmod +x /usr/bin/hbbr
|
chmod +x /usr/bin/hbbr
|
||||||
else
|
else
|
||||||
print_text_in_color "$IGreen" "Rustdesk server already installed."
|
print_text_in_color "$IGreen" "Rustdesk server already installed."
|
||||||
fi
|
fi
|
||||||
@@ -181,15 +227,16 @@ fi
|
|||||||
if [ ! -d "$RUSTDESK_LOG_DIR" ]
|
if [ ! -d "$RUSTDESK_LOG_DIR" ]
|
||||||
then
|
then
|
||||||
print_text_in_color "$IGreen" "Creating $RUSTDESK_LOG_DIR"
|
print_text_in_color "$IGreen" "Creating $RUSTDESK_LOG_DIR"
|
||||||
sudo mkdir -p "$RUSTDESK_LOG_DIR"
|
install -d -m 700 "$RUSTDESK_LOG_DIR"
|
||||||
|
chown -R "$RUSTDESK_USER" "$RUSTDESK_LOG_DIR"
|
||||||
fi
|
fi
|
||||||
sudo chown "${usern}" -R "$RUSTDESK_LOG_DIR"
|
|
||||||
|
|
||||||
# Setup systemd to launch hbbs
|
# Setup systemd to launch hbbs
|
||||||
if [ ! -f "/etc/systemd/system/rustdesk-hbbs.service" ]
|
if [ -f "/etc/systemd/system/rustdesk-hbbs.service" ]
|
||||||
then
|
then
|
||||||
|
systemctl stop rustdesk-hbbs.service
|
||||||
rm -f "/etc/systemd/system/rustdesk-hbbs.service"
|
rm -f "/etc/systemd/system/rustdesk-hbbs.service"
|
||||||
rm -f "/etc/systemd/system/rustdesk-hbbs.service"
|
systemctl daemon-reload
|
||||||
touch "/etc/systemd/system/rustdesk-hbbs.service"
|
touch "/etc/systemd/system/rustdesk-hbbs.service"
|
||||||
cat << HBBS_RUSTDESK_SERVICE > "/etc/systemd/system/rustdesk-hbbs.service"
|
cat << HBBS_RUSTDESK_SERVICE > "/etc/systemd/system/rustdesk-hbbs.service"
|
||||||
[Unit]
|
[Unit]
|
||||||
@@ -198,27 +245,28 @@ Description=RustDesk Signal Server
|
|||||||
Type=simple
|
Type=simple
|
||||||
LimitNOFILE=1000000
|
LimitNOFILE=1000000
|
||||||
ExecStart=/usr/bin/hbbs
|
ExecStart=/usr/bin/hbbs
|
||||||
WorkingDirectory="$RUSTDESK_INSTALL_DIR"
|
WorkingDirectory=$RUSTDESK_INSTALL_DIR
|
||||||
User="${usern}"
|
User=${usern}
|
||||||
Group="${usern}"
|
Group=${usern}
|
||||||
Restart=always
|
Restart=always
|
||||||
StandardOutput=append:"$RUSTDESK_LOG_DIR"/hbbs.log
|
StandardOutput=append:$RUSTDESK_LOG_DIR/hbbs.log
|
||||||
StandardError=append:"$RUSTDESK_LOG_DIR"/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
|
||||||
HBBS_RUSTDESK_SERVICE
|
HBBS_RUSTDESK_SERVICE
|
||||||
fi
|
fi
|
||||||
sudo systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
sudo systemctl enable rustdesk-hbbs.service
|
systemctl enable rustdesk-hbbs.service
|
||||||
sudo systemctl start rustdesk-hbbs.service
|
systemctl start rustdesk-hbbs.service
|
||||||
|
|
||||||
# Setup systemd to launch hbbr
|
# Setup systemd to launch hbbr
|
||||||
if [ ! -f "/etc/systemd/system/rustdesk-hbbr.service" ]
|
if [ -f "/etc/systemd/system/rustdesk-hbbr.service" ]
|
||||||
then
|
then
|
||||||
|
systemctl stop rustdesk-hbbs.service
|
||||||
rm -f "/etc/systemd/system/rustdesk-hbbr.service"
|
rm -f "/etc/systemd/system/rustdesk-hbbr.service"
|
||||||
rm -f "/etc/systemd/system/rustdesk-hbbr.service"
|
systemctl daemon-reload
|
||||||
touch "/etc/systemd/system/rustdesk-hbbr.service"
|
touch "/etc/systemd/system/rustdesk-hbbr.service"
|
||||||
cat << HBBR_RUSTDESK_SERVICE > "/etc/systemd/system/rustdesk-hbbr.service"
|
cat << HBBR_RUSTDESK_SERVICE > "/etc/systemd/system/rustdesk-hbbr.service"
|
||||||
[Unit]
|
[Unit]
|
||||||
@@ -227,99 +275,130 @@ Description=RustDesk Relay Server
|
|||||||
Type=simple
|
Type=simple
|
||||||
LimitNOFILE=1000000
|
LimitNOFILE=1000000
|
||||||
ExecStart=/usr/bin/hbbr
|
ExecStart=/usr/bin/hbbr
|
||||||
WorkingDirectory="$RUSTDESK_INSTALL_DIR"
|
WorkingDirectory=$RUSTDESK_INSTALL_DIR
|
||||||
User="${usern}"
|
User=${usern}
|
||||||
Group="${usern}"
|
Group=${usern}
|
||||||
Restart=always
|
Restart=always
|
||||||
StandardOutput=append:"$RUSTDESK_LOG_DIR"/hbbr.log
|
StandardOutput=append:$RUSTDESK_LOG_DIR/hbbr.log
|
||||||
StandardError=append:"$RUSTDESK_LOG_DIR"/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
|
||||||
HBBR_RUSTDESK_SERVICE
|
HBBR_RUSTDESK_SERVICE
|
||||||
fi
|
fi
|
||||||
sudo systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
sudo systemctl enable rustdesk-hbbr.service
|
systemctl enable rustdesk-hbbr.service
|
||||||
sudo systemctl start rustdesk-hbbr.service
|
systemctl start rustdesk-hbbr.service
|
||||||
|
|
||||||
while ! [[ $CHECK_RUSTDESK_READY ]]
|
while :
|
||||||
do
|
do
|
||||||
CHECK_RUSTDESK_READY=$(sudo systemctl status rustdesk-hbbr.service | grep "Active: active (running)")
|
if ! systemctl status rustdesk-hbbr.service | grep "Active: active (running)"
|
||||||
echo -ne "Waiting for RustDesk Relay service${NC}\n"
|
then
|
||||||
sleep 2
|
sleep 2
|
||||||
|
print_text_in_color "$ICyan" "Waiting for RustDesk Relay service to become active..."
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
pubname=$(find "$RUSTDESK_INSTALL_DIR" -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" "Pubilc key path: $PUBKEYNAME"
|
||||||
|
PUBLICKEY=$(cat "$PUBKEYNAME")
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "Tidying up install"
|
echo "Tidying up install"
|
||||||
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}"
|
||||||
|
|
||||||
# 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")
|
choice=$(whiptail --title "Rustdesk installation script" --menu \
|
||||||
echo -ne "Enter your preferred domain/DNS address ${NC}: "
|
"Choose your preferred option, IP or DNS/Domain:
|
||||||
read -r 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
|
|
||||||
|
|
||||||
print_text_in_color "$IGreen" "Installing Nginx"
|
DNS = Setup Rustdesk with TLS and your own domain
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]
|
IP = You don't have a domain, only plain IP
|
||||||
then
|
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
|
||||||
if yesno_box_yes "We use Certbot to generate the free TLS certificate from Let's Encrypt.
|
"DNS" "(e.g. rustdesk.example.com)" \
|
||||||
|
"IP" "($WANIP4)" 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
case "$choice" in
|
||||||
|
"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
|
||||||
|
|
||||||
|
# Check if DNS are forwarded correctly
|
||||||
|
if dig +short "$RUSTDESK_DOMAIN" @resolver1.opendns.com | grep -q "$WANIP4"
|
||||||
|
then
|
||||||
|
print_text_in_color "$IGreen" "DNS seems correct when checking with dig!"
|
||||||
|
else
|
||||||
|
msg_box "DNS lookup failed with dig. The external IP ($WANIP4) \
|
||||||
|
address of this server is not the same as the A-record ($DIG).
|
||||||
|
Please check your DNS settings! Maybe the domain hasn't propagated?
|
||||||
|
Please check https://www.whatsmydns.net/#A/${RUSTDESK_DOMAIN} if the IP seems correct."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
print_text_in_color "$IGreen" "Installing Nginx"
|
||||||
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]
|
||||||
|
then
|
||||||
|
if yesno_box_yes "We use Certbot to generate the free TLS certificate from Let's Encrypt.
|
||||||
The default behaviour 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 behaviour 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
|
then
|
||||||
sudo apt-get install nginx -y
|
apt-get install nginx -y
|
||||||
sudo apt-get install snapd -y
|
apt-get install snapd -y
|
||||||
sudo snap install certbot --classic
|
snap install certbot --classic
|
||||||
else
|
else
|
||||||
sudo apt-get install nginx -y
|
apt-get install nginx -y
|
||||||
sudo apt-get install python3-certbot-nginx -y
|
apt-get install python3-certbot-nginx -y
|
||||||
fi
|
fi
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ]
|
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ]
|
||||||
then
|
then
|
||||||
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
# openSUSE 15.4 fails to run the relay service and hangs waiting for it
|
||||||
# Needs more work before it can be enabled
|
# Needs more work before it can be enabled
|
||||||
# || [ "${UPSTREAM_ID}" = "suse" ]
|
# || [ "${UPSTREAM_ID}" = "suse" ]
|
||||||
sudo yum -y install nginx
|
yum -y install nginx
|
||||||
sudo yum -y install python3-certbot-nginx
|
yum -y install python3-certbot-nginx
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]
|
||||||
then
|
then
|
||||||
sudo pacman -S install nginx
|
pacman -S install nginx
|
||||||
sudo pacman -S install python3-certbot-nginx
|
pacman -S install python3-certbot-nginx
|
||||||
else
|
else
|
||||||
print_text_in_color "$IRed" "Unsupported OS"
|
msg_box "Sorry, your OS is unsupported"
|
||||||
# Here you could ask the user for permission to try and install anyway
|
if ! yesno_box_no "It might work anyway though... Do you want to continue anyway?"
|
||||||
# If they say yes, then do the install
|
then
|
||||||
# If they say no, exit the script
|
exit 1
|
||||||
exit 1
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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"
|
||||||
rm -f "/etc/nginx/sites-enabled/rustdesk.conf"
|
rm -f "/etc/nginx/sites-enabled/rustdesk.conf"
|
||||||
touch "/etc/nginx/sites-available/rustdesk.conf"
|
touch "/etc/nginx/sites-available/rustdesk.conf"
|
||||||
cat << NGINX_RUSTDESK_CONF > "/etc/nginx/sites-available/rustdesk.conf"
|
cat << NGINX_RUSTDESK_CONF > "/etc/nginx/sites-available/rustdesk.conf"
|
||||||
server {
|
server {
|
||||||
server_name ${wanip};
|
server_name ${wanip};
|
||||||
location / {
|
location / {
|
||||||
@@ -329,41 +408,59 @@ server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
NGINX_RUSTDESK_CONF
|
NGINX_RUSTDESK_CONF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the default Nginx configs
|
# Remove the default Nginx configs
|
||||||
sudo rm -f /etc/nginx/sites-available/default
|
rm -f /etc/nginx/sites-available/default
|
||||||
sudo rm -f /etc/nginx/sites-enabled/default
|
rm -f /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
# Enable the Nginx config file
|
# Enable the Nginx config file
|
||||||
if [ ! -f /etc/nginx/sites-enabled/rustdesk.conf ]
|
if [ ! -f /etc/nginx/sites-enabled/rustdesk.conf ]
|
||||||
then
|
then
|
||||||
sudo 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
|
||||||
|
|
||||||
# Enable firewall rules for the domain
|
# Enable firewall rules for the domain
|
||||||
sudo ufw allow 80/tcp
|
ufw allow 80/tcp
|
||||||
sudo ufw allow 443/tcp
|
ufw allow 443/tcp
|
||||||
sudo ufw enable
|
ufw enable
|
||||||
sudo ufw reload
|
ufw reload
|
||||||
|
|
||||||
# Generate the certifictae
|
# Generate the certifictae
|
||||||
if ! sudo certbot --nginx --cert-name "${wanip}" --key-type ecdsa --renew-by-default --no-eff-email --agree-tos --server https://acme-v02.api.letsencrypt.org/directory -d "${wanip}"
|
if ! certbot --nginx --cert-name "${wanip}" --key-type ecdsa --renew-by-default --no-eff-email --agree-tos --server https://acme-v02.api.letsencrypt.org/directory -d "${wanip}"
|
||||||
then
|
then
|
||||||
msg_box "Sorry, the TLS certificate for $wanip failed to generate!
|
msg_box "Sorry, the TLS certificate for $wanip failed to generate!
|
||||||
Please check that port 80/443 are correctly port forwarded, and that the DNS record points to this servers IP.
|
Please check that port 80/443 are correctly port forwarded, and that the DNS record points to this servers IP.
|
||||||
|
|
||||||
Please try again."
|
Please try again."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
break
|
"IP")
|
||||||
;;
|
ufw allow 21114/tcp
|
||||||
*) print_text_in_color "$IRed" "Invalid option $REPLY";;
|
ufw enable
|
||||||
|
ufw reload
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
|
||||||
|
|
||||||
print_text_in_color "$IGreen" "Your IP/DNS Address is:"
|
# Display final info!
|
||||||
print_text_in_color "$ICyan" "$wanip"
|
if [ -n "$RUSTDESK_DOMAIN" ]
|
||||||
print_text_in_color "$IGreen" "Your public key is:"
|
then
|
||||||
print_text_in_color "$ICyan" "$key"
|
msg_box "Your Public Key is:
|
||||||
|
$PUBLICKEY
|
||||||
|
|
||||||
|
Your DNS Address is:
|
||||||
|
$RUSTDESK_DOMAIN
|
||||||
|
|
||||||
|
Please login at https://$RUSTDESK_DOMAIN"
|
||||||
|
else
|
||||||
|
msg_box "Your Public Key is:
|
||||||
|
$PUBLICKEY
|
||||||
|
|
||||||
|
Your IP Address is:
|
||||||
|
$WANIP4
|
||||||
|
|
||||||
|
Please login at http://$WANIP4"
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user