Files
shokollm 965c84379b Add uv support, systemd service, and deployment tooling
- pyproject.toml: uv-native project definition (replaces requirements.txt for uv users)
- requirements.txt: kept for pip compatibility
- deploy/jigaido-bot.service: systemd service file (copy to /etc/systemd/system/)
- deploy/setup.sh: automated deployment script
- README.md: updated with uv instructions, tmux, and systemd setup
2026-04-01 09:15:41 +00:00

57 lines
1.6 KiB
Bash

#!/bin/bash
# JIGAIDO Telegram Bot — Deployment setup script
# Run once on a fresh server to set everything up.
set -e
BOT_DIR="/home/shoko/repositories/jigaido/apps/telegram-bot"
SERVICE_NAME="jigaido-bot"
SERVICE_FILE="$BOT_DIR/deploy/$SERVICE_NAME.service"
SYSTEMD_DIR="/etc/systemd/system"
echo "=== JIGAIDO Bot Setup ==="
# 1. Check for uv
if ! command -v uv &> /dev/null; then
echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
fi
# 2. Check for bot token
if [ -z "$JIGAIDO_BOT_TOKEN" ]; then
echo "ERROR: JIGAIDO_BOT_TOKEN is not set."
echo "Get a token from @BotFather on Telegram, then run:"
echo " export JIGAIDO_BOT_TOKEN='your:token'"
echo " $0"
exit 1
fi
# 3. Create .env from example if it doesn't exist
if [ ! -f "$BOT_DIR/.env" ]; then
cp "$BOT_DIR/.env.example" "$BOT_DIR/.env"
echo "Created .env — edit it and add your JIGAIDO_BOT_TOKEN"
exit 1
fi
# 4. Install dependencies (uv creates venv automatically)
cd "$BOT_DIR"
uv sync
# 5. Install systemd service
echo "Installing systemd service..."
sudo cp "$SERVICE_FILE" "$SYSTEMD_DIR/"
sudo sed -i "s|/home/shoko/repositories/jigaido|$BOT_DIR|g" "$SYSTEMD_DIR/$SERVICE_NAME.service"
# 6. Reload systemd, enable and start
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
echo ""
echo "=== Done ==="
echo "Bot is running. Check status with: sudo systemctl status $SERVICE_NAME"
echo "View logs with: journalctl -u $SERVICE_NAME -f"
echo "Stop with: sudo systemctl stop $SERVICE_NAME"
echo "Restart with: sudo systemctl restart $SERVICE_NAME"