diff --git a/README.md b/README.md index 4c37b1c..30600f9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,95 @@ -# unraid-docker-manager -Unraid Docker Manager +# Docker Manager Bot + +Telegram bot for managing Docker containers on Unraid. Control containers from your phone with simple keyword commands. + +## Prerequisites + +- Unraid server with Docker enabled +- n8n container running on Unraid +- Telegram Bot Token (from [@BotFather](https://t.me/botfather)) +- Your Telegram User ID (from [@userinfobot](https://t.me/userinfobot)) + +## Installation + +### 1. Configure n8n Container + +Your n8n container needs Docker socket access to manage other containers. Add these flags to your n8n container configuration: + +```bash +docker run -d \ + --name n8n \ + --group-add 281 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v /path/to/curl:/usr/bin/curl:ro \ + -p 5678:5678 \ + n8nio/n8n +``` + +**Required flags:** + +- `--group-add 281` - Adds Docker group (GID 281 on Unraid) so n8n can access the Docker socket +- `-v /var/run/docker.sock:/var/run/docker.sock` - Mounts the Docker socket for container management +- `-v /path/to/curl:/usr/bin/curl:ro` - Mounts a static curl binary (hardened n8n image lacks package manager) + +If using Unraid's Community Applications, add these to the "Extra Parameters" and "Path" sections of your n8n container template. + +### 2. Create n8n Credentials + +In the n8n web interface, create two credentials: + +**Telegram API credential:** + +1. Go to Settings > Credentials > Add Credential +2. Search for "Telegram API" +3. Name: `Telegram API` +4. Access Token: paste your bot token from @BotFather + +**Telegram Auth credential:** + +1. Go to Settings > Credentials > Add Credential +2. Search for "Header Auth" +3. Name: `Telegram Auth` +4. Header Name: `userId` +5. Header Value: your Telegram user ID (numeric, e.g., `123456789`) + +### 3. Import Workflow + +1. Download `n8n-workflow.json` from this repository +2. In n8n: Workflows > Import from File +3. Select `n8n-workflow.json` +4. When prompted, map credentials: + - `Telegram API` -> your Telegram API credential + - `Telegram Auth` -> your Telegram Auth credential + +### 4. Activate Workflow + +1. Open the imported workflow in n8n +2. Click the "Active" toggle in the top-right corner +3. Test by sending "status" to your bot in Telegram + +## Usage + +Send commands via Telegram or use the persistent menu buttons: + +| Command | Description | +|---------|-------------| +| `status` | View all containers with status indicators | +| `start ` | Start a stopped container | +| `stop ` | Stop a running container | +| `restart ` | Restart a container | +| `update ` | Pull latest image and recreate container | +| `logs [lines]` | View container logs (default: 50 lines) | + +Container names support partial matching. For example, `start plex` will match `linuxserver-plex`. + +### Menu Buttons + +Send `/start` or any unrecognized text to display the persistent keyboard with quick-access buttons for all commands. + +## Security + +The bot only responds to the Telegram user ID configured in the "Telegram Auth" credential. Messages from other users are silently ignored. + +## License + +MIT