-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
113 lines (96 loc) · 3.59 KB
/
install.sh
File metadata and controls
113 lines (96 loc) · 3.59 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
set -e
# ── Telegram Supervisor — Quick Install ──
# Usage: curl -fsSL https://raw.githubusercontent.com/Anda4ka/telegram-supervisor/main/install.sh | bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Telegram Supervisor — Quick Install${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# Check Docker
if ! command -v docker &> /dev/null; then
echo -e "${RED}❌ Docker not found. Install it first: https://docs.docker.com/get-docker/${NC}"
exit 1
fi
if ! docker compose version &> /dev/null 2>&1; then
echo -e "${RED}❌ Docker Compose not found. Install Docker Desktop or docker-compose-plugin.${NC}"
exit 1
fi
echo -e "${GREEN}✅ Docker found${NC}"
# Clone or update
INSTALL_DIR="telegram-supervisor"
if [ -d "$INSTALL_DIR" ]; then
echo -e "${YELLOW}Directory $INSTALL_DIR exists, pulling latest...${NC}"
cd "$INSTALL_DIR"
git pull --ff-only 2>/dev/null || true
else
echo "Cloning repository..."
git clone https://github.com/Anda4ka/telegram-supervisor.git "$INSTALL_DIR"
cd "$INSTALL_DIR"
fi
# Interactive setup
if [ ! -f .env ]; then
echo ""
echo -e "${BLUE}━━ Step 1/3: Bot Token ━━${NC}"
echo "Create a bot via @BotFather in Telegram and paste the token:"
read -r -p "> " BOT_TOKEN
if [ -z "$BOT_TOKEN" ]; then
echo -e "${RED}❌ Token is required${NC}"
exit 1
fi
echo ""
echo -e "${BLUE}━━ Step 2/3: Admin ID ━━${NC}"
echo "Your Telegram user ID (get it from @userinfobot):"
read -r -p "> " ADMIN_ID
if [ -z "$ADMIN_ID" ]; then
echo -e "${RED}❌ Admin ID is required${NC}"
exit 1
fi
echo ""
echo -e "${BLUE}━━ Step 3/3: OpenRouter API Key (optional) ━━${NC}"
echo "Get one at https://openrouter.ai/keys (press Enter to skip — AI features will be disabled):"
read -r -p "> " OPENROUTER_KEY
# Generate .env
cat > .env << EOF
# Generated by install.sh on $(date -Iseconds)
# ── Required ──
MODERATOR_BOT_TOKEN=${BOT_TOKEN}
ADMIN_SUPER_ADMINS=${ADMIN_ID}
# ── Database (managed by Docker) ──
DB_USER=postgres
DB_PASSWORD=$(openssl rand -hex 16 2>/dev/null || echo "changeme_$(date +%s)")
DB_HOST=db
DB_PORT=5432
DB_NAME=supervisor_bot
# ── AI Features (optional) ──
OPENROUTER_API_KEY=${OPENROUTER_KEY}
# ── Features (auto-enabled if API key is set) ──
CHANNEL_ENABLED=${OPENROUTER_KEY:+true}
CHANNEL_ENABLED=${CHANNEL_ENABLED:-false}
MODERATION_ENABLED=false
ASSISTANT_BOT_ENABLED=false
# ── Logging ──
LOG_LEVEL=INFO
EOF
echo ""
echo -e "${GREEN}✅ .env created${NC}"
else
echo -e "${YELLOW}⚠️ .env already exists, keeping current config${NC}"
fi
# Start
echo ""
echo "Starting services..."
docker compose -f docker-compose.full.yaml up -d
echo ""
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN} ✅ Bot is running!${NC}"
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo " Send /start to your bot in Telegram"
echo " Logs: docker compose -f docker-compose.full.yaml logs -f bot"
echo " Stop: docker compose -f docker-compose.full.yaml down"
echo ""