Files
SocialPub/tools/pasture/peers/shared.sh
T
thepraandClaude Opus 5.5 761cfc2cce Pasture: Mobilizon joins
Mobilizon 5.2.4 on a PostGIS of its own (it needs the extension, which the shared Postgres has not got), trusting
Caddy's CA through the bundle mounted over certifi's and castore's files (hackney trusts only those), with geocoding
pointed at a closed local port. scenarios/mobilizon.sh passes its 23 checks: alice follows a group; the event its
organiser makes arrives as an Event with its start, end and located place; comments both ways; the organiser's edit,
closing the comments (PrivaPub then refuses a reply) and deletes of a comment and the event; a group post with its
title; the unfollow; statistics. An event made through Mobilizon's API without options has its comments closed, so
the scenario opens them. No RSVP yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
2026-10-05 10:54:32 +02:00

49 lines
2.8 KiB
Bash

# Services several peers share: one Postgres and one MySQL (each peer gets its own database), and one Redis (each its own
# db number).
shared_postgres_up() {
podman container exists pasture-postgres && return 0
podman run -d --replace --name pasture-postgres --network $net --network-alias postgres \
-e POSTGRES_USER=pasture -e POSTGRES_PASSWORD=pasture -e POSTGRES_DB=pasture docker.io/library/postgres:17-alpine >/dev/null
for _ in $(seq 1 60); do podman exec pasture-postgres pg_isready -U pasture >/dev/null 2>&1 && return 0; sleep 1; done
echo "postgres did not start" >&2; return 1
}
shared_redis_up() {
podman container exists pasture-redis && return 0
podman run -d --replace --name pasture-redis --network $net --network-alias redis docker.io/library/redis:7-alpine >/dev/null
}
# pg_db <name> [extension...]: a database of the shared Postgres for one peer, with the extensions it needs
pg_db() {
local name=$1; shift
podman exec pasture-postgres sh -c "psql -U pasture -tc \"select 1 from pg_database where datname='$name'\" | grep -q 1 || createdb -U pasture $name"
for ext in "$@"; do
podman exec pasture-postgres psql -U pasture -d "$name" -qc "create extension if not exists \"$ext\";" >/dev/null
done
}
# a PostGIS of its own for the peers that need the extension (Mobilizon), beside the shared Postgres that has not got it.
# Its first start runs a server on the socket alone to set itself up: only TCP answers when it is ready
shared_postgis_up() {
podman container exists pasture-postgis && return 0
podman run -d --replace --name pasture-postgis --network $net --network-alias postgis --label pasture=1 \
-e POSTGRES_USER=pasture -e POSTGRES_PASSWORD=pasture -e POSTGRES_DB=pasture docker.io/postgis/postgis:17-3.5-alpine >/dev/null
for _ in $(seq 1 90); do podman exec pasture-postgis pg_isready -h 127.0.0.1 -U pasture >/dev/null 2>&1 && return 0; sleep 1; done
echo "postgis did not start" >&2; return 1
}
shared_mysql_up() {
podman container exists pasture-mysql && return 0
podman run -d --replace --name pasture-mysql --network $net --network-alias mysql \
-e MYSQL_ROOT_PASSWORD=pasture -e MYSQL_USER=pasture -e MYSQL_PASSWORD=pasture docker.io/library/mysql:8.4 >/dev/null
# its first start runs a temporary server without networking to set itself up: only TCP answers when it is ready
for _ in $(seq 1 90); do podman exec pasture-mysql mysqladmin ping -h127.0.0.1 --protocol=tcp -uroot -ppasture --silent >/dev/null 2>&1 && return 0; sleep 2; done
echo "mysql did not start" >&2; return 1
}
# mysql_db <name>: a database of the shared MySQL for one peer, the pasture user owning it
mysql_db() {
podman exec pasture-mysql mysql -uroot -ppasture -e \
"create database if not exists \`$1\` character set utf8mb4 collate utf8mb4_unicode_ci; grant all on \`$1\`.* to 'pasture'@'%';" 2>/dev/null
}