26 lines
940 B
Bash
Executable File
26 lines
940 B
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
# Wait for DB
|
|
while ! pg_isready -U ${POSTGRES_USER:-pleroma} -d postgres://${POSTGRES_HOST:-postgres}:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-pleroma} -t 1; do
|
|
echo "Waiting for ${POSTGRES_HOST} to come up..."
|
|
sleep 1
|
|
done
|
|
|
|
# Fix the user on the config directory and re-run the script as the pleroma user
|
|
chown pleroma:pleroma -R /config /uploads /static /opt/pleroma
|
|
|
|
# Create config file, if necessary
|
|
if [ ! -f "/config/config.exs" ]; then
|
|
/sbin/su-exec pleroma cp /opt/pleroma/config.dist.exs /config/config.exs
|
|
/sbin/su-exec pleroma /opt/pleroma/bin/pleroma_ctl migrate
|
|
/sbin/su-exec pleroma /opt/pleroma/bin/pleroma_ctl config migrate_to_db
|
|
/sbin/su-exec pleroma echo "config :pleroma, configurable_from_database: true" >> /config/config.exs
|
|
fi
|
|
|
|
# Migrate database
|
|
/sbin/su-exec pleroma /opt/pleroma/bin/pleroma_ctl migrate
|
|
|
|
# Run Pleroma as the "pleroma" user
|
|
exec /sbin/su-exec pleroma "$@"
|