Files
postgresql/source-files/postgresql.sh
T
2025-09-30 20:55:34 +03:00

18 lines
512 B
Bash

#!/bin/sh
PGROOT=/srv/postgresql
PGDATA="$PGROOT"/data
[ -d /run/postgresql ] || install -d -o postgres -g postgres /run/postgresql
[ "$PGROOT" != "/srv/postgresql" ] && ln -sf "$PGROOT" /srv/postgresql
if [ ! -d "$PGDATA" ]; then
install -dm0700 -o postgres -g postgres "$PGDATA"
su - postgres -m -c "/usr/bin/initdb -D '$PGDATA'"
[ -f /etc/postgresql/postgresql.conf ] && ln -sf /etc/postgresql/postgresql.conf "$PGDATA"/postgresql.conf
fi
exec su - postgres -m -c "/usr/bin/postgres -D '$PGDATA'"