mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
+1








14fba21e57
Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com> Signed-off-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co> Signed-off-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub17jjz49l9jjmhhk7cac63j8yt9z555n9cw8vk7v5jz4vzw4ppld5qgj57cc <f4a42a97e594b77bdbd8ee35191c8b28a94a4cb871d96f32921558275421fb68@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Mari <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Sami <f4a42a97e594b77bdbd8ee35191c8b28a94a4cb871d96f32921558275421fb68@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Quinn <96f056ad5f2305c8ddf637dc65d048aa4c12d7daeb8867690e34fca46b0ef64c@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Dawn <c6237ef84fa537c78dcee78efd2d4e59f728859c7f194da42ac51ededfa0be05@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Co-authored-by: Sami <sami@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co>
134 lines
3.7 KiB
Bash
Executable File
134 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "${SCRIPT_DIR}"
|
|
|
|
COMPOSE_FILES=(-f compose.yml)
|
|
if [[ "${BUZZ_COMPOSE_TLS:-false}" == "true" ]]; then
|
|
COMPOSE_FILES+=(-f compose.caddy.yml)
|
|
fi
|
|
if [[ "${BUZZ_COMPOSE_DEV:-false}" == "true" ]]; then
|
|
COMPOSE_FILES+=(-f compose.dev.yml)
|
|
fi
|
|
|
|
compose() {
|
|
docker compose --env-file .env "${COMPOSE_FILES[@]}" "$@"
|
|
}
|
|
|
|
require_env() {
|
|
if [[ ! -f .env ]]; then
|
|
cat >&2 <<'MSG'
|
|
Missing deploy/compose/.env.
|
|
|
|
Copy .env.example to .env and replace every CHANGE_ME value, or run the bootstrap
|
|
script once it lands. Do not start production with generated secrets missing.
|
|
MSG
|
|
exit 1
|
|
fi
|
|
if grep -Eq '^[[:space:]]*[A-Za-z_][A-Za-z0-9_]*=.*CHANGE_ME' .env; then
|
|
cat >&2 <<'MSG'
|
|
deploy/compose/.env still contains CHANGE_ME placeholders.
|
|
Generate stable secrets first; these values must not rotate on restart.
|
|
MSG
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
backup_hint() {
|
|
cat <<'MSG'
|
|
Back up these before upgrades and on a regular schedule:
|
|
|
|
- deploy/compose/.env, especially BUZZ_RELAY_PRIVATE_KEY, DB/Redis/S3 secrets, and BUZZ_GIT_HOOK_HMAC_SECRET
|
|
- The owner private key if bootstrap generated one for RELAY_OWNER_PUBKEY
|
|
- Postgres data (prefer pg_dump or a quiesced volume snapshot)
|
|
- MinIO/S3 bucket contents for media and git objects
|
|
- buzz-git-data volume (BUZZ_GIT_REPO_PATH=/data/git)
|
|
- Caddy data/config volumes if using compose.caddy.yml
|
|
|
|
Keep Postgres + object/git state snapshots from the same maintenance window.
|
|
MSG
|
|
}
|
|
|
|
case "${1:-help}" in
|
|
start|up)
|
|
require_env
|
|
compose up -d --wait
|
|
;;
|
|
stop|down)
|
|
compose down
|
|
;;
|
|
restart)
|
|
require_env
|
|
compose up -d --wait --force-recreate relay
|
|
;;
|
|
pull)
|
|
require_env
|
|
compose pull
|
|
;;
|
|
upgrade)
|
|
require_env
|
|
compose pull
|
|
compose up -d --wait
|
|
backup_hint
|
|
;;
|
|
logs)
|
|
shift || true
|
|
compose logs -f "${@:-relay}"
|
|
;;
|
|
status|ps)
|
|
compose ps
|
|
;;
|
|
config)
|
|
require_env
|
|
compose config
|
|
;;
|
|
backup-hint)
|
|
backup_hint
|
|
;;
|
|
add-member)
|
|
docker compose exec relay /usr/local/bin/buzz-admin add-member --pubkey "${2:?Usage: ./run.sh add-member <npub-or-hex> [--role member|admin]}" "${@:3}"
|
|
;;
|
|
remove-member)
|
|
docker compose exec relay /usr/local/bin/buzz-admin remove-member --pubkey "${2:?Usage: ./run.sh remove-member <npub-or-hex> [--role member|admin]}" "${@:3}"
|
|
;;
|
|
list-members)
|
|
docker compose exec relay /usr/local/bin/buzz-admin list-members
|
|
;;
|
|
help|-h|--help)
|
|
cat <<'MSG'
|
|
Usage: ./run.sh <command>
|
|
|
|
Commands:
|
|
start Start Buzz with docker compose up -d --wait
|
|
stop Stop containers without deleting volumes
|
|
restart Recreate the relay after env/image changes
|
|
pull Pull configured images
|
|
upgrade Pull and restart, then print backup reminders
|
|
logs [svc] Follow logs (default: relay)
|
|
status Show compose service status
|
|
config Render merged compose config
|
|
backup-hint Print the production backup checklist
|
|
|
|
add-member <npub-or-hex> [--role member|admin]
|
|
Add a relay member (default role: member)
|
|
remove-member <npub-or-hex> [--role member|admin]
|
|
Remove a relay member
|
|
list-members List all relay members
|
|
|
|
Note: when adding multiple members in a loop, add `sleep 1` between
|
|
invocations to avoid same-second timestamp collisions in the kind:13534
|
|
roster event. Do not use parallel adds (e.g. xargs -P).
|
|
|
|
Environment switches:
|
|
BUZZ_COMPOSE_TLS=true Include compose.caddy.yml for automatic HTTPS
|
|
BUZZ_COMPOSE_DEV=true Include compose.dev.yml for local admin ports/tools
|
|
MSG
|
|
;;
|
|
*)
|
|
echo "Unknown command: $1" >&2
|
|
echo "Run ./run.sh help" >&2
|
|
exit 1
|
|
;;
|
|
esac
|