summaryrefslogtreecommitdiff
path: root/ntfy/install.sh
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/install.sh
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/install.sh')
-rwxr-xr-xntfy/install.sh34
1 files changed, 34 insertions, 0 deletions
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 でログイン"