Update install.sh
This commit is contained in:
35
install.sh
35
install.sh
@@ -41,6 +41,22 @@ function check_and_install_docker() {
|
||||
fi
|
||||
}
|
||||
|
||||
function check_existing_container() {
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^$CRON_NAME$"; then
|
||||
echo -e "${RED}⚠️ A Docker container named '$CRON_NAME' already exists.${NC}"
|
||||
read -rp "$(echo -e "${YELLOW}🔁 Do you want to stop and remove it (including its image)? [Y/n] ${NC}")" confirm
|
||||
confirm="${confirm,,}"
|
||||
if [[ "$confirm" =~ ^(y|yes| )?$ ]]; then
|
||||
echo -e "${YELLOW}🛑 Removing existing container and image...${NC}"
|
||||
docker rm -f "$CRON_NAME" >/dev/null 2>&1
|
||||
docker rmi -f "$CRON_NAME" >/dev/null 2>&1
|
||||
echo -e "${GREEN}✅ Removed container and image.${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Skipping removal. Existing instance may cause conflicts.${NC}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function menu() {
|
||||
echo -e "${YELLOW}1. Install bot (clone + build)"
|
||||
echo -e "2. Check bot status + send test Telegram message"
|
||||
@@ -63,21 +79,6 @@ function set_telegram_credentials() {
|
||||
}
|
||||
|
||||
function clone_and_build() {
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^$CRON_NAME$"; then
|
||||
echo -e "${RED}⚠️ A Docker container named '$CRON_NAME' already exists.${NC}"
|
||||
read -rp "$(echo -e "${YELLOW}🔁 Do you want to stop and remove it (including its image)? [Y/n] ${NC}")" confirm
|
||||
confirm="${confirm,,}"
|
||||
if [[ "$confirm" =~ ^(y|yes| )?$ ]]; then
|
||||
echo -e "${YELLOW}🛑 Stopping and removing existing container and image...${NC}"
|
||||
docker rm -f "$CRON_NAME" >/dev/null 2>&1
|
||||
docker rmi -f "$CRON_NAME" >/dev/null 2>&1
|
||||
echo -e "${GREEN}✅ Container and image removed.${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Aborted by user. Not reinstalling.${NC}"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "$CLONE_DIR" ]; then
|
||||
echo -e "${RED}⚠️ Folder '$CLONE_DIR' already exists.${NC}"
|
||||
read -rp "$(echo -e "${YELLOW}🔁 Do you want me to remove it? Press Enter to continue, or Ctrl+C to cancel...${NC}")"
|
||||
@@ -147,6 +148,10 @@ function check_bot_status() {
|
||||
echo -e "${GREEN}✅ Done. If your Telegram is configured, you should receive a message now.${NC}"
|
||||
}
|
||||
|
||||
# 🔍 Check for container/image immediately on script start
|
||||
check_existing_container
|
||||
|
||||
# ⏳ Main Menu Loop
|
||||
while true; do
|
||||
clear
|
||||
banner
|
||||
|
||||
Reference in New Issue
Block a user