summaryrefslogtreecommitdiff
path: root/ntfy
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-10-31 13:20:27 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-10-31 13:20:27 +0900
commitb4ecef96fae14a92d12279927986e69c2e223180 (patch)
tree822b448e7544aa197a9db6efc43f2ddb875eae55 /ntfy
parent5a55c7893615c5a64856ecca681325a609d1fac0 (diff)
Add status pages, ntfy alerts, and license-slot-checker repo
- status/: lightweight status checker (status.yyamashita.com, /api/status) with ntfy DOWN/recovered alerts after consecutive failures - uptime-kuma/: Uptime Kuma at uptime.yyamashita.com - hetzner-admin: authenticated /status page (status-app results + docker ps -a) - ntfy/: self-hosted ntfy at ntfy.yyamashita.com (deny-all auth, install.sh creates admin user and status-app token) - Caddyfile, DNS, post-receive hook, tests/check.sh, docs updated - license-slot-checker: add to repos.txt, hook, and Claude sessions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'ntfy')
-rwxr-xr-xntfy/deploy.sh6
-rw-r--r--ntfy/docker-compose.yml23
-rwxr-xr-xntfy/install.sh34
-rw-r--r--ntfy/server.yml15
4 files changed, 78 insertions, 0 deletions
diff --git a/ntfy/deploy.sh b/ntfy/deploy.sh
new file mode 100755
index 0000000..239c3db
--- /dev/null
+++ b/ntfy/deploy.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+set -euo pipefail
+cd "$(dirname "$0")"
+docker compose pull -q
+# server.yml はファイル単位のマウントなので、git checkout で差し替わった内容を反映するため再作成する
+docker compose up -d --force-recreate
diff --git a/ntfy/docker-compose.yml b/ntfy/docker-compose.yml
new file mode 100644
index 0000000..d794baf
--- /dev/null
+++ b/ntfy/docker-compose.yml
@@ -0,0 +1,23 @@
+services:
+ ntfy:
+ image: binwiederhier/ntfy
+ container_name: ntfy
+ command: serve
+ restart: unless-stopped
+ environment:
+ - TZ=Asia/Tokyo
+ volumes:
+ - ./server.yml:/etc/ntfy/server.yml:ro
+ - ntfy_cache:/var/cache/ntfy
+ - ntfy_lib:/var/lib/ntfy
+ networks:
+ - web
+
+networks:
+ web:
+ external: true
+ name: web
+
+volumes:
+ ntfy_cache:
+ ntfy_lib:
diff --git a/ntfy/install.sh b/ntfy/install.sh
new file mode 100755
index 0000000..f65f867
--- /dev/null
+++ b/ntfy/install.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# 初回セットアップ: コンテナ起動 → 管理ユーザー作成 → status-app 用トークン発行
+set -euo pipefail
+cd "$(dirname "$0")"
+
+USER_NAME="${1:-admin}"
+TOPIC="${NTFY_TOPIC:-status}"
+STATUS_ENV="$(pwd)/../status/.env"
+
+bash ./deploy.sh
+sleep 2
+
+if docker exec ntfy ntfy user list 2>&1 | grep -q "^user $USER_NAME "; then
+ echo "User $USER_NAME already exists"
+else
+ echo "Creating ntfy admin user: $USER_NAME"
+ docker exec -it ntfy ntfy user add --role=admin "$USER_NAME"
+fi
+
+if grep -q '^NTFY_TOKEN=' "$STATUS_ENV" 2>/dev/null; then
+ echo "NTFY_TOKEN already set in $STATUS_ENV"
+else
+ TOKEN=$(docker exec ntfy ntfy token add --label=status-app "$USER_NAME" | grep -o 'tk_[a-z0-9]*')
+ {
+ echo "NTFY_URL=http://ntfy/$TOPIC"
+ echo "NTFY_TOKEN=$TOKEN"
+ } >> "$STATUS_ENV"
+ chmod 600 "$STATUS_ENV"
+ echo "Token written to $STATUS_ENV"
+ bash ../status/deploy.sh
+fi
+
+echo ""
+echo "購読: ntfy アプリで サーバー https://ntfy.yyamashita.com / トピック $TOPIC / ユーザー $USER_NAME でログイン"
diff --git a/ntfy/server.yml b/ntfy/server.yml
new file mode 100644
index 0000000..29a6a83
--- /dev/null
+++ b/ntfy/server.yml
@@ -0,0 +1,15 @@
+# ntfy サーバー設定 https://docs.ntfy.sh/config/
+base-url: "https://ntfy.yyamashita.com"
+listen-http: ":80"
+behind-proxy: true
+
+cache-file: "/var/cache/ntfy/cache.db"
+cache-duration: "72h"
+attachment-cache-dir: "/var/cache/ntfy/attachments"
+
+# 認証必須。ユーザー・トークンは install.sh で作成する
+auth-file: "/var/lib/ntfy/user.db"
+auth-default-access: "deny-all"
+
+# iOS アプリで即時通知を受けるために ntfy.sh 経由で push をトリガーする(本文は送られない)
+upstream-base-url: "https://ntfy.sh"