-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
64 lines (49 loc) Β· 1.7 KB
/
start.sh
File metadata and controls
64 lines (49 loc) Β· 1.7 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
#!/bin/bash
# CleanAcc Bot Startup Script
set -e
echo "π Starting CleanAcc Bot..."
# Check if .env exists
if [ ! -f .env ]; then
echo "β .env file not found!"
echo "π Please copy .env.example to .env and configure it"
exit 1
fi
# Load environment variables
export $(cat .env | grep -v '^#' | xargs)
# Validate required variables
required_vars=("BOT_TOKEN" "API_ID" "API_HASH" "ADMIN_IDS")
for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
echo "β Required environment variable $var is not set!"
exit 1
fi
done
# Create necessary directories
mkdir -p logs sessions data
# Check Python version
python_version=$(python3 --version 2>&1 | cut -d' ' -f2 | cut -d'.' -f1,2)
required_version="3.8"
if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then
echo "β Python $required_version or higher is required (found $python_version)"
exit 1
fi
# Install dependencies if requirements.txt is newer than last install
if [ requirements.txt -nt .last_install ] || [ ! -f .last_install ]; then
echo "π¦ Installing/updating dependencies..."
pip3 install -r requirements.txt
touch .last_install
fi
# Check Redis connection
echo "π Checking Redis connection..."
if ! redis-cli -h ${REDIS_HOST:-localhost} -p ${REDIS_PORT:-6379} ${REDIS_PASSWORD:+-a $REDIS_PASSWORD} ping > /dev/null 2>&1; then
echo "β Cannot connect to Redis server!"
echo "π‘ Make sure Redis is running: redis-server"
exit 1
fi
echo "β
Redis connection OK"
# Set up logging
export PYTHONUNBUFFERED=1
# Start the bot with proper error handling
echo "π€ Starting bot..."
python3 main.py
echo "π Bot stopped"