2026-10-01 13:19:16 +02:00
|
|
|
#!/usr/bin/env bash
|
2026-10-03 11:42:03 +02:00
|
|
|
# A private test fediverse on one podman network: PrivaPub (privapub.test) and the peers asked for, behind one Caddy
|
|
|
|
|
# whose internal CA every side is told to accept (its root is copied to .ca/root.crt). From the workstation: PrivaPub's
|
2026-10-05 00:32:54 +02:00
|
|
|
# API at http://127.0.0.1:6971 ($PASTURE_PORT), every site at https://<name>.test:6443 (curl --resolve <name>.test:6443:127.0.0.1 -k).
|
|
|
|
|
# usage: tools/pasture/run.sh up [peer...] | add <peer...> | down [--purge] | logs <name> | ps | stats
|
|
|
|
|
# up starts everything afresh (PrivaPub republished, Mongo empty); add starts more peers next to a running pasture.
|
2026-10-05 15:44:13 +02:00
|
|
|
# peers: gts (default), mastodon, misskey, sharkey, akkoma, lemmy, decepub, and every other file in peers/
|
2026-10-01 13:19:16 +02:00
|
|
|
set -euo pipefail
|
2026-10-03 11:42:03 +02:00
|
|
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/pasture.sh"
|
2026-10-01 13:19:16 +02:00
|
|
|
|
|
|
|
|
case "${1:-up}" in
|
|
|
|
|
up)
|
2026-10-03 11:42:03 +02:00
|
|
|
shift || true
|
|
|
|
|
peers=("${@:-gts}")
|
|
|
|
|
pasture_base_up
|
|
|
|
|
for peer in "${peers[@]}"; do
|
|
|
|
|
[ -f "$here/peers/$peer.sh" ] || { echo "no such peer: $peer" >&2; exit 1; }
|
|
|
|
|
. "$here/peers/$peer.sh"
|
|
|
|
|
"${peer}_up"
|
|
|
|
|
done
|
2026-10-05 00:32:54 +02:00
|
|
|
echo "privapub: http://127.0.0.1:$port, https://privapub.test:6443"
|
2026-10-01 13:19:16 +02:00
|
|
|
;;
|
2026-10-05 00:32:54 +02:00
|
|
|
add)
|
|
|
|
|
shift
|
|
|
|
|
podman container exists pasture-privapub || { echo "the pasture is not up: run.sh up first" >&2; exit 1; }
|
|
|
|
|
caddy_current || caddy_up
|
|
|
|
|
podman exec pasture-caddy caddy reload --config /etc/caddy/Caddyfile >/dev/null 2>&1 || true
|
|
|
|
|
for peer in "$@"; do
|
|
|
|
|
[ -f "$here/peers/$peer.sh" ] || { echo "no such peer: $peer" >&2; exit 1; }
|
|
|
|
|
. "$here/peers/$peer.sh"
|
|
|
|
|
"${peer}_up"
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
down) pasture_down "${2:-}" ;;
|
2026-10-03 11:42:03 +02:00
|
|
|
logs) podman logs --tail 200 "pasture-${2:-privapub}" ;;
|
|
|
|
|
ps) podman ps --filter name=pasture- --format '{{.Names}}\t{{.Status}}' ;;
|
2026-10-05 00:32:54 +02:00
|
|
|
stats) pasture_stats ;;
|
|
|
|
|
*) echo "usage: $0 up [peer...] | add <peer...> | down [--purge] | logs <name> | ps | stats" >&2; exit 2 ;;
|
2026-10-01 13:19:16 +02:00
|
|
|
esac
|