37 lines
1.7 KiB
Bash
37 lines
1.7 KiB
Bash
# Activity-Relay 2.0.9 (yukimochi): a Mastodon-style relay as relay.test. A server subscribes by following Public from an
|
|||
|
|
# actor with a shared inbox; the relay then passes on, signed with its own key, every public activity another subscriber
|
||
|
|
# sends it (a LitePub-style follower, whose actor ends in /relay, gets an Announce instead). Its state is in the shared
|
||
|
|
# Redis (database 13); its actor key is made once. Go trusts the bundle the pasture mounts over the system one.
|
||
|
|
RELAY_IMAGE=${RELAY_IMAGE:-docker.io/yukimochi/activity-relay:v2.0.9}
|
||
|
|
. "$here/peers/shared.sh"
|
||
|
|
|
||
|
|
relay_up() {
|
||
|
|
shared_redis_up
|
||
|
|
local st="$here/.state/relay"
|
||
|
|
mkdir -p "$st"
|
||
|
|
[ -s "$st/actor.pem" ] || openssl genrsa -traditional -out "$st/actor.pem" 2048 2>/dev/null
|
||
|
|
chmod 644 "$st/actor.pem"
|
||
|
|
cat > "$st/config.yml" <<-EOF
|
||
|
|
ACTOR_PEM: /var/lib/relay/actor.pem
|
||
|
|
REDIS_URL: redis://redis:6379/13
|
||
|
|
RELAY_BIND: 0.0.0.0:8080
|
||
|
|
RELAY_DOMAIN: relay.test
|
||
|
|
RELAY_SERVICENAME: Pasture Relay
|
||
|
|
JOB_CONCURRENCY: 10
|
||
|
|
RELAY_ICON: https://relay.test/icon.png
|
||
|
|
RELAY_IMAGE: https://relay.test/image.png
|
||
|
|
EOF
|
||
|
|
for role in server worker; do
|
||
|
|
podman run -d --replace --name pasture-relay-$role --label pasture=1 --network $net \
|
||
|
|
-v "$st:/var/lib/relay:z,ro" -v "$ca/bundle.pem:/etc/ssl/certs/ca-certificates.crt:z,ro" \
|
||
|
|
$RELAY_IMAGE relay --config /var/lib/relay/config.yml $role >/dev/null
|
||
|
|
done
|
||
|
|
for _ in $(seq 1 60); do
|
||
|
|
site relay.test -s -o /dev/null -w '%{http_code}' https://relay.test:6443/actor 2>/dev/null | grep -q 200 && break
|
||
|
|
sleep 1
|
||
|
|
done
|
||
|
|
echo "relay: https://relay.test:6443"
|
||
|
|
}
|
||
|
|
|
||
|
|
# relay_subscribers: the hosts subscribed to the relay, from its Redis
|
||
|
|
relay_subscribers() { podman exec pasture-redis redis-cli -n 13 --raw keys 'relay:subscription:*' | sed 's/relay:subscription://'; }
|