-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvps_setup.sh
More file actions
86 lines (73 loc) · 2.53 KB
/
vps_setup.sh
File metadata and controls
86 lines (73 loc) · 2.53 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
#!/bin/bash
# Copyright (c) 2026 Nardo. AGPL-3.0 — see LICENSE
# VPS Setup Script for telegram-claude-bot
# Run as root on a fresh Ubuntu 24.04 server
set -e
echo "=== Step 1: System update ==="
apt update && apt upgrade -y
echo "=== Step 2: Install Python + dependencies ==="
apt install -y python3 python3-venv python3-pip git curl
echo "=== Step 3: Create user bernard ==="
if ! id bernard &>/dev/null; then
adduser --disabled-password --gecos "" bernard
usermod -aG sudo bernard
# Copy SSH keys from root
mkdir -p ~/.ssh
cp /root/.ssh/authorized_keys ~/.ssh/
chown -R bernard:bernard ~/.ssh
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
# Allow sudo without password for convenience
echo "bernard ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/bernard
fi
echo "=== Step 4: Setup project ==="
PROJECT="~/telegram-claude-bot"
if [ ! -d "$PROJECT" ]; then
mkdir -p "$PROJECT"
fi
echo "=== Step 5: Setup Python venv ==="
cd "$PROJECT"
if [ ! -d "venv" ]; then
python3 -m venv venv
fi
echo "=== Step 6: Install Playwright deps ==="
apt install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxdamage1 \
libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2t64 libxshmfence1 2>/dev/null || true
echo "=== Step 7: Setup systemd service ==="
cat > /etc/systemd/system/telegram-bots.service <<'EOF'
[Unit]
Description=Telegram Bots
After=network.target
[Service]
User=bernard
WorkingDirectory=~/telegram-claude-bot
ExecStart=/bin/bash start_all.sh
Restart=always
RestartSec=10
Environment=PATH=~/telegram-claude-bot/venv/bin:/usr/local/bin:/usr/bin:/bin
StandardOutput=append:/tmp/start_all.log
StandardError=append:/tmp/start_all.log
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable telegram-bots
echo "=== Step 8: Install Claude CLI ==="
if [ ! -f ~/.local/bin/claude ]; then
su - bernard -c 'curl -fsSL https://claude.ai/install.sh | sh'
fi
echo "=== Step 9: Fix ownership ==="
chown -R bernard:bernard "$PROJECT"
chown -R bernard:bernard ~/.local 2>/dev/null || true
echo ""
echo "========================================="
echo " VPS Setup Complete!"
echo "========================================="
echo ""
echo "Remaining manual steps:"
echo " 1. Upload project files (rsync from Mac)"
echo " 2. Install Python packages: cd ~/telegram-claude-bot && source venv/bin/activate && pip install -r requirements.txt"
echo " 3. Install Playwright: playwright install chromium"
echo " 4. Login to Claude: claude login"
echo " 5. Start bots: sudo systemctl start telegram-bots"
echo ""