From cc097bf4f6e05f4ecd45ca33340c2771ce0ddd37 Mon Sep 17 00:00:00 2001 From: Frank Schwenk Date: Mon, 6 Jul 2026 11:27:05 +0200 Subject: [PATCH] Add README with copy-paste client install for ntfyschwenkonline. Documents per-host topic naming and manual token setup via the web UI. Co-authored-by: Cursor --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b685004 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# ntfy.schwenk.online + +Self-hosted [ntfy](https://ntfy.sh) push server behind Traefik. + +## Server setup + +```bash +docker compose up -d +docker exec -it ntfy.schwenk.online ntfy user add frank --role=admin +``` + +## Per-host notifications + +Each machine posts to a topic derived from its FQDN (`hostname -f`, lowercased, dots → hyphens). +For example, `web01.example.com` publishes to topic `web01-example-com`. + +1. Create a user and access token in the web UI at https://ntfy.schwenk.online +2. Grant that user read-write access to the host topic (e.g. `web01-example-com`) +3. Install the command below on the machine, replacing `tk_PASTE_YOUR_TOKEN_HERE` + +### Install `ntfyschwenkonline` on a client + +Replace the token, then copy and paste the whole block: + +```bash +sudo tee /usr/local/bin/ntfyschwenkonline > /dev/null <<'EOF' +#!/bin/sh +set -eu + +NTFY_URL="https://ntfy.schwenk.online" +NTFY_TOKEN="tk_PASTE_YOUR_TOKEN_HERE" + +topic() { + hostname -f | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' +} + +if [ "$#" -gt 0 ]; then + message="$*" +elif [ -t 0 ]; then + echo "usage: ntfyschwenkonline [message]" >&2 + echo " echo message | ntfyschwenkonline" >&2 + exit 1 +else + message=$(cat) +fi + +curl -fsS \ + -H "Authorization: Bearer ${NTFY_TOKEN}" \ + -H "Title: $(hostname -s)" \ + -d "${message}" \ + "${NTFY_URL}/$(topic)" +EOF +sudo chmod 755 /usr/local/bin/ntfyschwenkonline +``` + +### Use + +```bash +ntfyschwenkonline "backup finished" +echo "disk 95% full" | ntfyschwenkonline +``` + +Messages appear on the host topic in the ntfy web UI or any subscriber.