Skip to content

Add maintenance script #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README-apikeys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# API key management

This applies, if you're operating shutter-api with rate limiting/api keys enabled (see `docker-compose.rate_limit.yaml` and `apikeys/apikeys.py` for more details), via `docker compose`.

Keys are stored in `shutter-api/data/keys.csv`.

There is a script on `shutter-api.shutter.network:shutter-api/add-apikey.sh` for adding new keys while the `compose` stack is running. It executes the python script from `apikeys/apikeys.py` inside the `docker compose` environment (see header of the python script for more documentation).

When you execute it, it will ask for an email address or other reference for a new key, that will be added to `keys.csv`.

If you manually change the contents of `keys.csv`, for example to remove a key, run `add-apikey.sh` and don't give a new keys reference -- that will compile the edited `.csv` and restart the webserver.
9 changes: 9 additions & 0 deletions add-apikey.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# This writes a new apikey to the keysfile and the configuration
docker run --rm -it -v $(pwd)/apikeys/apikeys.py:/apikeys.py:ro -v $(pwd)/data:/data -e KEYS_FILE=/data/keys.csv -e CADDY_SNIPPET=/data/apikeys.caddy ghcr.io/astral-sh/uv:python3.13-alpine uv run --script /apikeys.py

echo "Activating new API key by restarting caddy"
tail -1 data/keys.csv

docker compose -f docker-compose.yml -f docker-compose.rate_limit.yaml restart caddy