18 lines
512 B
Bash
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'"
|