-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
89 lines (75 loc) · 2.11 KB
/
deploy.sh
File metadata and controls
89 lines (75 loc) · 2.11 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
#!/bin/bash
# Framework Patcher Bot - Deployment Script
# This script automates the setup and deployment of the bot.
# Text colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_status() {
echo -e "${YELLOW}[*] $1${NC}"
}
print_success() {
echo -e "${GREEN}[+] $1${NC}"
}
print_error() {
echo -e "${RED}[!] $1${NC}"
}
# Check if .env exists
if [ ! -f ".env" ]; then
print_error ".env file not found!"
print_status "Creating a template .env file..."
cat <<EOF > .env
BOT_TOKEN=your_telegram_bot_token
API_ID=your_telegram_api_id
API_HASH=your_telegram_api_hash
GITHUB_TOKEN=your_github_token
GITHUB_OWNER=FrameworksForge
GITHUB_REPO=FrameworkPatcher
PIXELDRAIN_API_KEY=your_pixeldrain_api_key
EOF
print_status "Please edit the .env file with your credentials and run this script again."
exit 1
fi
# Check for Python
if ! command -v python3 &> /dev/null; then
print_error "Python 3 is not installed!"
exit 1
fi
# Create virtual environment
if [ ! -d "venv" ]; then
print_status "Creating virtual environment..."
python3 -m venv venv
fi
# Install dependencies
print_status "Installing dependencies..."
./venv/bin/pip install --upgrade pip
./venv/bin/pip install -r requirements.txt
# Create systemd service (Optional)
read -p "Do you want to create a systemd service? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
CUR_DIR=$(pwd)
USER_NAME=$(whoami)
print_status "Creating systemd service 'framework-bot'..."
cat <<EOF | sudo tee /etc/systemd/system/framework-bot.service
[Unit]
Description=Framework Patcher Bot
After=network.target
[Service]
User=$USER_NAME
WorkingDirectory=$CUR_DIR
Environment="PYTHONPATH=$CUR_DIR"
ExecStart=$CUR_DIR/venv/bin/python3 -m Framework
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
print_success "Service created! You can start it with: sudo systemctl start framework-bot"
fi
print_success "Setup completed successfully!"
print_status "To start the bot manually, run: ./venv/bin/python3 -m Framework"