Files

175 lines
4.4 KiB
Markdown
Raw Permalink Normal View History

2026-03-11 19:43:33 +00:00
# Update Server
Flask-based update server that bots query to check for new versions and send modmail notifications when updates are available.
2026-03-13 13:22:46 +00:00
## 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
2026-03-11 19:43:33 +00:00
## Setup
### Local Development
1. Install dependencies:
```bash
pip install -r requirements.txt
```
2. Run the server:
```bash
python app.py
```
2026-03-13 13:22:46 +00:00
- API Server: http://localhost:5555
- Admin GUI: http://localhost:5566
2026-03-11 19:43:33 +00:00
### Production Deployment
#### Using Docker
```bash
docker build -t update-server .
2026-03-13 13:22:46 +00:00
docker run -p 5555:5555 -p 5566:5566 update-server
2026-03-11 19:43:33 +00:00
```
#### Using Docker Compose
From the parent directory:
```bash
2026-03-13 13:22:46 +00:00
docker-compose up botupdateserver
2026-03-11 19:43:33 +00:00
```
2026-03-13 13:22:46 +00:00
This exposes:
- Port 5555 for API calls (public-facing)
- Port 5566 for Admin GUI (should be protected, e.g., behind Authentik)
2026-03-11 19:43:33 +00:00
### Production with Nginx (HTTPS)
2026-03-13 13:22:46 +00:00
Configure nginx as a reverse proxy:
2026-03-11 19:43:33 +00:00
```nginx
2026-03-13 13:22:46 +00:00
# Public API endpoint
2026-03-11 19:43:33 +00:00
server {
listen 443 ssl http2;
server_name updts.slfhstd.uk;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
2026-03-13 13:22:46 +00:00
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;
2026-03-11 19:43:33 +00:00
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
2026-03-13 13:22:46 +00:00
### 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`:
2026-03-11 19:43:33 +00:00
```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"
}
}
```
2026-03-13 13:22:46 +00:00
## API Endpoints (Port 5555)
2026-03-11 19:43:33 +00:00
2026-03-13 13:22:46 +00:00
### Public API
2026-03-11 19:43:33 +00:00
- `GET /` - Server info and available endpoints
- `GET /health` - Health check
- `GET /api/versions` - Get all bot versions
- `GET /api/version/<bot_name>` - 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"
}
```
2026-03-13 13:22:46 +00:00
### 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"}'
```
2026-03-11 19:43:33 +00:00
## Logs
Update check requests are logged to `update_checks.log` with timestamps and bot names.
2026-03-13 13:22:46 +00:00
## 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
2026-03-11 19:43:33 +00:00
## 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