# Update Server Flask-based update server that bots query to check for new versions and send modmail notifications when updates are available. ## Features - **API Server** (Port 5555) - Bots query this for version information - **Admin GUI** (Port 5566) - Web interface to easily manage bot versions - Simple JSON-based version storage - Health check endpoint ## Setup ### Local Development 1. Install dependencies: ```bash pip install -r requirements.txt ``` 2. Run the server: ```bash python app.py ``` - API Server: http://localhost:5555 - Admin GUI: http://localhost:5566 ### Production Deployment #### Using Docker ```bash docker build -t update-server . docker run -p 5555:5555 -p 5566:5566 update-server ``` #### Using Docker Compose From the parent directory: ```bash docker-compose up botupdateserver ``` This exposes: - Port 5555 for API calls (public-facing) - Port 5566 for Admin GUI (should be protected, e.g., behind Authentik) ### Production with Nginx (HTTPS) Configure nginx as a reverse proxy: ```nginx # Public API endpoint server { listen 443 ssl http2; server_name updts.slfhstd.uk; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.pem; location / { proxy_pass http://localhost:5555; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } # Admin GUI with authentication (Authentik, etc.) server { listen 443 ssl http2; server_name updts-admin.slfhstd.uk; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.pem; # Protect with Authentik (or your auth system) auth_request /auth; location / { proxy_pass http://localhost:5566; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } ``` ## Managing Versions ### Using the Admin GUI 1. Navigate to `http://localhost:5566` (or your admin domain for production) 2. Fill in the bot details: - **Bot Name**: The name of the bot (e.g., `TestPostsBot`) - **Version**: The current version (e.g., `0.2`) - **Changelog URL**: (Optional) Link to the changelog 3. Click "Save Version" 4. View all current versions in the right panel 5. Edit by clicking "Edit" on any bot, or delete with "Delete" ### Manual Edit (versions.json) If preferred, directly edit `versions.json`: ```json { "TestPostsBot": { "version": "0.2", "changelog_url": "https://github.com/yourrepo/releases/tag/v0.2" }, "AnotherBot": { "version": "1.0", "changelog_url": "https://github.com/yourrepo/AnotherBot/releases" } } ``` ## API Endpoints (Port 5555) ### Public API - `GET /` - Server info and available endpoints - `GET /health` - Health check - `GET /api/versions` - Get all bot versions - `GET /api/version/` - Get specific bot version Example: ```bash curl https://updts.slfhstd.uk/api/version/TestPostsBot ``` Response: ```json { "version": "0.2", "changelog_url": "https://github.com/yourrepo/releases/tag/v0.2" } ``` ### Admin API (Port 5566) **Note:** These endpoints should be protected. Secure with Authentik or another authentication method. #### Add/Update Version ```bash curl -X POST http://localhost:5566/admin/api/add \ -H "Content-Type: application/json" \ -d '{ "bot_name": "TestPostsBot", "version": "0.3", "changelog_url": "https://github.com/yourrepo/releases/tag/v0.3" }' ``` #### Delete Version ```bash curl -X POST http://localhost:5566/admin/api/delete \ -H "Content-Type: application/json" \ -d '{"bot_name": "TestPostsBot"}' ``` ## Logs Update check requests are logged to `update_checks.log` with timestamps and bot names. ## Architecture - **API Server (Port 5555)**: Public endpoint for bots to check versions - **Admin GUI (Port 5566)**: Web interface for managing versions - **Single versioning source**: Both use the same `versions.json` file - **No authentication built-in**: Use a reverse proxy (Authentik, etc.) for security ## Hosting Options - **Heroku** - Easy deployment with free tier - **Railway.app** - Simple alternative to Heroku - **DigitalOcean/AWS/GCP** - Full control, more expensive - **VPS with Nginx** - Most control, requires setup