Update install.sh
This commit is contained in:
73
install.sh
73
install.sh
@@ -23,36 +23,70 @@ function system_status() {
|
||||
echo -n "📦 Docker: "
|
||||
if command -v docker &>/dev/null; then
|
||||
echo -e "${GREEN}Installed${NC}"
|
||||
docker_status="ok"
|
||||
else
|
||||
echo -e "${RED}Missing${NC}"
|
||||
docker_status="missing"
|
||||
fi
|
||||
|
||||
echo -n "🐳 Docker Compose: "
|
||||
if docker compose version &>/dev/null; then
|
||||
echo -e "${GREEN}Available (v2)${NC}"
|
||||
compose_status="ok"
|
||||
else
|
||||
echo -e "${RED}Missing or incompatible${NC}"
|
||||
compose_status="missing"
|
||||
fi
|
||||
|
||||
echo -n "📁 Project folder '$CLONE_DIR': "
|
||||
if [ -d "$CLONE_DIR" ]; then
|
||||
echo -e "${YELLOW}Exists${NC}"
|
||||
folder_status="exists"
|
||||
else
|
||||
echo -e "${GREEN}Not present${NC}"
|
||||
folder_status="missing"
|
||||
fi
|
||||
|
||||
echo -n "📦 Docker image '$CRON_NAME': "
|
||||
if docker images --format '{{.Repository}}' | grep -q "$CRON_NAME"; then
|
||||
echo -e "${YELLOW}Already built${NC}"
|
||||
image_status="built"
|
||||
else
|
||||
echo -e "${RED}Not built${NC}"
|
||||
image_status="missing"
|
||||
fi
|
||||
|
||||
echo -n "📦 Docker container '$CRON_NAME': "
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^$CRON_NAME$"; then
|
||||
echo -e "${YELLOW}Exists${NC}"
|
||||
echo -e "${RED}Not running${NC}"
|
||||
container_status="exists"
|
||||
else
|
||||
echo -e "${GREEN}Not running${NC}"
|
||||
container_status="missing"
|
||||
fi
|
||||
}
|
||||
|
||||
function check_and_install_docker() {
|
||||
if [ "$docker_status" = "missing" ]; then
|
||||
echo -e "${YELLOW}Installing Docker...${NC}"
|
||||
apt update
|
||||
apt install -y docker.io
|
||||
systemctl enable --now docker
|
||||
echo -e "${GREEN}✅ Docker installed.${NC}"
|
||||
fi
|
||||
|
||||
if [ "$compose_status" = "missing" ]; then
|
||||
echo -e "${YELLOW}Installing Docker Compose plugin...${NC}"
|
||||
if apt-cache show docker-compose-plugin &>/dev/null; then
|
||||
apt install -y docker-compose-plugin
|
||||
else
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -SL https://github.com/docker/compose/releases/download/v2.27.1/docker-compose-linux-x86_64 \
|
||||
-o ~/.docker/cli-plugins/docker-compose
|
||||
chmod +x ~/.docker/cli-plugins/docker-compose
|
||||
export PATH="$HOME/.docker/cli-plugins:$PATH"
|
||||
fi
|
||||
echo -e "${GREEN}✅ Docker Compose v2 installed.${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -68,10 +102,41 @@ function menu() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Insert your previous functions here if needed (clone_and_build, etc.)
|
||||
# Only showing header and status + menu for this snippet.
|
||||
function clone_and_build() {
|
||||
check_and_install_docker
|
||||
|
||||
# Start script
|
||||
if [ "$folder_status" = "exists" ] || [ "$image_status" = "built" ]; then
|
||||
echo -e "${YELLOW}⚠️ Project folder or image already exists.${NC}"
|
||||
read -rp "$(echo -e "${YELLOW}🔁 Do you want to reinstall everything? This will remove old data. [Y/n] ${NC}")" confirm
|
||||
confirm="${confirm,,}"
|
||||
if [[ "$confirm" =~ ^(y|yes| )?$ ]]; then
|
||||
echo -e "${YELLOW}🧹 Cleaning up...${NC}"
|
||||
docker rm -f "$CRON_NAME" >/dev/null 2>&1
|
||||
docker rmi -f "$CRON_NAME" >/dev/null 2>&1
|
||||
rm -rf "$CLONE_DIR"
|
||||
echo -e "${GREEN}✅ Cleaned up previous install.${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Installation aborted.${NC}"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}📥 Cloning repo...${NC}"
|
||||
git clone "$REPO_URL" "$CLONE_DIR"
|
||||
cd "$CLONE_DIR" || exit 1
|
||||
echo -e "${GREEN}🔧 Building Docker image...${NC}"
|
||||
docker compose build
|
||||
|
||||
echo -e "${YELLOW}📨 Enter your Telegram bot token:${NC}"
|
||||
read -rp "🔑 TELEGRAM_TOKEN: " token
|
||||
echo -e "${YELLOW}👥 Enter your Telegram chat ID:${NC}"
|
||||
read -rp "🆔 TELEGRAM_CHAT_ID: " chat_id
|
||||
sed -i "s|^TELEGRAM_TOKEN = .*|TELEGRAM_TOKEN = \"$token\"|" bot.py
|
||||
sed -i "s|^CHAT_ID = .*|CHAT_ID = \"$chat_id\"|" bot.py
|
||||
echo -e "${GREEN}✅ Credentials updated in bot.py${NC}"
|
||||
}
|
||||
|
||||
# --- script start ---
|
||||
clear
|
||||
banner
|
||||
system_status
|
||||
|
||||
Reference in New Issue
Block a user