[WIP] Consistency is key!
This PR aims to make everything more consistent, and correct smaller errors/bugs.
This commit is contained in:
1 parent
53a6765771
commit
a36ac3ba13
1 file changed
+55
-31
+55
-31
@@ -2,33 +2,59 @@
|
|||||||
|
|
||||||
##################################################################################################################
|
##################################################################################################################
|
||||||
|
|
||||||
if [[ "$EUID" -ne 0 ]]
|
# Install curl and whiptail if needed
|
||||||
|
if [ ! -x "$(command -v curl)" ] || [ ! -x "$(command -v whiptail)" ]
|
||||||
then
|
then
|
||||||
echo "Sorry, you are not root. You now have two options:"
|
# We need curl to fetch the lib
|
||||||
echo
|
# There are the package managers for different OS:
|
||||||
echo "1. Use SUDO directly:"
|
# osInfo[/etc/redhat-release]=yum
|
||||||
echo " a) :~$ sudo bash install.sh"
|
# osInfo[/etc/arch-release]=pacman
|
||||||
echo
|
# osInfo[/etc/gentoo-release]=emerge
|
||||||
echo "2. Become ROOT and then type your command:"
|
# osInfo[/etc/SuSE-release]=zypp
|
||||||
echo " a) :~$ sudo -i"
|
# osInfo[/etc/debian_version]=apt-get
|
||||||
echo " b) :~# bash install.sh"
|
# osInfo[/etc/alpine-release]=apk
|
||||||
echo
|
NEEDED_DEPS=(curl whiptail)
|
||||||
echo "More information can be found here: https://unix.stackexchange.com/a/3064"
|
if [ -x "$(command -v apt-get)" ]
|
||||||
exit 1
|
then
|
||||||
fi
|
sudo apt-get install "${NEEDED_DEPS[@]}" -y
|
||||||
|
elif [ -x "$(command -v apk)" ]
|
||||||
# Download the lib file
|
then
|
||||||
if ! curl -fSL https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/lib.sh -o lib.sh
|
sudo apk add --no-cache "${NEEDED_DEPS[@]}"
|
||||||
then
|
elif [ -x "$(command -v dnf)" ]
|
||||||
echo "Failed to download the lib.sh file. Please try again"
|
then
|
||||||
exit 1
|
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
|
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="Uninstall Script"
|
SCRIPT_NAME="Uninstall 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
|
||||||
|
|
||||||
|
##################################################################################################################
|
||||||
|
|
||||||
|
# Check if root
|
||||||
|
root_check
|
||||||
|
|
||||||
# Output debugging info if $DEBUG set
|
# Output debugging info if $DEBUG set
|
||||||
if [ "$DEBUG" = "true" ]
|
if [ "$DEBUG" = "true" ]
|
||||||
@@ -40,7 +66,6 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Switch for Certbot
|
# Switch for Certbot
|
||||||
if [ -d /etc/letsencrypt ]
|
if [ -d /etc/letsencrypt ]
|
||||||
then
|
then
|
||||||
@@ -53,7 +78,6 @@ fi
|
|||||||
choice=$(whiptail --title "$TITLE" --checklist \
|
choice=$(whiptail --title "$TITLE" --checklist \
|
||||||
"What do you want to uninstall?
|
"What do you want to uninstall?
|
||||||
$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
|
$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
|
||||||
"curl" "(Removes curl:// linux package)" OFF \
|
|
||||||
"nginxconf" "(Removes Rustdesk Nginx config)" OFF \
|
"nginxconf" "(Removes Rustdesk Nginx config)" OFF \
|
||||||
"nginxall" "(Removes *everything* releated to Nginx)" ON \
|
"nginxall" "(Removes *everything* releated to Nginx)" ON \
|
||||||
"wget" "(Removes wget linux package)" ON \
|
"wget" "(Removes wget linux package)" ON \
|
||||||
@@ -65,12 +89,10 @@ $CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
|
|||||||
"UFW" "(Removes UFW linux package plus rules)" ON \
|
"UFW" "(Removes UFW linux package plus rules)" ON \
|
||||||
"Rustdesk LOGs" "(Removes RustDesk log dir)" ON \
|
"Rustdesk LOGs" "(Removes RustDesk log dir)" ON \
|
||||||
"Rustdesk Server" "(Removes Rustdesk server + services)" ON \
|
"Rustdesk Server" "(Removes Rustdesk server + services)" ON \
|
||||||
|
"curl" "(Removes curl:// linux package)" OFF \
|
||||||
"Certbot" "(Removes Certbot package plus Let's Encrypt)" "$CERTBOT_SWITCH" 3>&1 1>&2 2>&3)
|
"Certbot" "(Removes Certbot package plus Let's Encrypt)" "$CERTBOT_SWITCH" 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
*"curl"*)
|
|
||||||
REMOVE_CURL="yes"
|
|
||||||
;;&
|
|
||||||
*"nginxconf"*)
|
*"nginxconf"*)
|
||||||
REMOVE_NGINX_CONF="yes"
|
REMOVE_NGINX_CONF="yes"
|
||||||
;;&
|
;;&
|
||||||
@@ -104,6 +126,9 @@ case "$choice" in
|
|||||||
*"Rustdesk SERVER"*)
|
*"Rustdesk SERVER"*)
|
||||||
REMOVE_RUSTDESK_SERVER="yes"
|
REMOVE_RUSTDESK_SERVER="yes"
|
||||||
;;&
|
;;&
|
||||||
|
*"curl"*)
|
||||||
|
REMOVE_CURL="yes"
|
||||||
|
;;&
|
||||||
*"Certbot"*)
|
*"Certbot"*)
|
||||||
REMOVE_CERTBOT="yes"
|
REMOVE_CERTBOT="yes"
|
||||||
;;&
|
;;&
|
||||||
@@ -113,7 +138,7 @@ esac
|
|||||||
|
|
||||||
msg_box "WARNING WARNING WARNING
|
msg_box "WARNING WARNING WARNING
|
||||||
|
|
||||||
This script will remove EVERYTHING that was you chose in the previous selection.
|
This script will remove EVERYTHING that was chosen in the previous selection.
|
||||||
You can choose to opt out after you hit OK."
|
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?"
|
if ! yesno_box_no "Are you REALLY sure you want to continue with the uninstallation?"
|
||||||
@@ -134,8 +159,8 @@ then
|
|||||||
else
|
else
|
||||||
ufw delete allow 21114/tcp
|
ufw delete allow 21114/tcp
|
||||||
fi
|
fi
|
||||||
ufw disable
|
ufw --force disable
|
||||||
ufw reload
|
ufw --force reload
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Rustdesk Server
|
# Rustdesk Server
|
||||||
@@ -231,10 +256,9 @@ fi
|
|||||||
|
|
||||||
msg_box "Uninstallation complete!
|
msg_box "Uninstallation complete!
|
||||||
|
|
||||||
Please hit OK to remove the last file."
|
Please hit OK to remove the last package."
|
||||||
|
|
||||||
if [ -n "$REMOVE_WHIPTAIL" ]
|
if [ -n "$REMOVE_WHIPTAIL" ]
|
||||||
then
|
then
|
||||||
purge_linux_package whiptail
|
purge_linux_package whiptail
|
||||||
fi
|
fi
|
||||||
rm -f lib.sh
|
|
||||||
Reference in new issue
Block a user