25 lines
700 B
Bash
Executable File
25 lines
700 B
Bash
Executable File
#!/bin/sh
|
|
. /@PREFIX@/etc/default/postgresql
|
|
: ${PGDATA:="$PGROOT/data"}
|
|
|
|
if [ "$PGROOT" != "/var/lib/postgresql@VERSION@" ]; then
|
|
echo "Creating symlink /var/lib/postgresql@VERSION@ -> $PGROOT"
|
|
ln -sf "$PGROOT" /var/lib/postgresql@VERSION@
|
|
fi
|
|
|
|
|
|
if [ ! -d "$PGDATA" ]; then
|
|
echo "Initializing database in $PGDATA"
|
|
|
|
mkdir -p "$PGDATA"
|
|
chown -R postgres:postgres "$PGDATA"
|
|
chmod 0700 "$PGDATA"
|
|
su - postgres -m -c "/@PREFIX@/bin/initdb $INITOPTS -D '$PGDATA'" >/dev/null
|
|
|
|
if [ -f /@PREFIX@/etc/postgresql/postgresql.conf ]; then
|
|
ln -sf /@PREFIX@/etc/postgresql/postgresql.conf "$PGDATA/postgresql.conf"
|
|
fi
|
|
fi
|
|
|
|
exec chpst -u postgres:postgres /@PREFIX@/bin/postgres -D "$PGDATA" $PGOPTS 2>&1
|