Omnibus-style container for Rebased and Soapbox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

set -e
if [ -n "$IP" ]; then
echo "Will check name resolution."
resolv=$(curl "$DOMAIN" | jq -c -r .Answer[0].data)
while [ "$resolv" != "$IP" ]; do
echo "Waiting for name to resolve properly (want $IP for $DOMAIN, got $resolv)..."
sleep 60
resolv=$(curl "$DOMAIN" | jq -c -r .Answer[0].data)
echo "$DOMAIN resolves to $resolv"
export DATABASE_URL="postgres://pleroma:bleromer@localhost:5433/pleroma"
echo "-- Setting up PostgreSQL..."
chown -R postgres:postgres /var/lib/postgresql/14
chmod -R 750 /var/lib/postgresql/14
set +e
pg_createcluster 14 pleroma
cp /etc/postgresql/14/pleroma/*.conf /var/lib/postgresql/14/pleroma
set -e
pg_ctlcluster 14 pleroma start
gosu postgres /run/
echo "-- Starting Caddy..."
chown -R caddy:caddy /caddy
sed -i -e "s/{{domain}}/$DOMAIN/" /etc/Caddyfile
gosu caddy caddy start --config /etc/Caddyfile
echo "-- Running migrations..."
gosu pleroma sh -c "/opt/pleroma/bin/pleroma_ctl migrate"
if [ ! -f "/var/lib/pleroma/uploads/.migrated" ]; then
echo "-- Transferring config to database"
gosu pleroma sh -c "/opt/pleroma/bin/pleroma start" &
sleep 10
gosu pleroma sh -c "/opt/pleroma/bin/pleroma_ctl config migrate_to_db"
if [ -n "ADMIN" ]; then
echo "-- Creating admin user"
set +e
gosu pleroma sh -c "/opt/pleroma/bin/pleroma_ctl user new $ADMIN admin@$DOMAIN --password \"$PASSWORD\" --admin -y"
set -e
gosu pleroma sh -c "/opt/pleroma/bin/pleroma stop" &
echo "migrated" > /var/lib/pleroma/uploads/.migrated
sleep 10
echo "-- Already migrated config to DB. Skipping."
echo "-- Starting!"
gosu pleroma sh -c "/opt/pleroma/bin/pleroma start"