forked from B3H1Z/Hiddify-Telegram-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
40 lines (32 loc) · 1.1 KB
/
uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Define text colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
RESET='\033[0m' # Reset text color
HIDY_BOT_ID="@HidyBotGroup"
INSTALL_DIR="/opt/Hiddify-Telegram-Bot"
# Function to display error messages and exit
function display_error_and_exit() {
echo -e "${RED}Error: $1${RESET}"
echo -e "${YELLOW}${HIDY_BOT_ID}${RESET}"
exit 1
}
echo -e "${GREEN}Uninstalling the Hiddify-Telegram-Bot...${RESET}"
# Check if the installation directory exists
if [ -d "$INSTALL_DIR" ]; then
# Stop the running bot if it's still running
if pgrep -f "python3 hiddifyTelegramBot.py" >/dev/null; then
echo -e "${GREEN}Stopping the bot...${RESET}"
pkill -9 -f "hiddifyTelegramBot.py"
fi
# Remove cron jobs
echo -e "${GREEN}Removing cron jobs...${RESET}"
crontab -l | grep -v "$INSTALL_DIR" | crontab -
# Remove the installation directory
echo -e "${GREEN}Removing the installation directory...${RESET}"
rm -rf "$INSTALL_DIR"
echo -e "${GREEN}Uninstallation complete.${RESET}"
else
display_error_and_exit "The installation directory does not exist. Nothing to uninstall."
fi