Skip to content

Commit

Permalink
[WIP] Add postgresql service.
Browse files Browse the repository at this point in the history
  • Loading branch information
flexibeast committed Oct 17, 2021
1 parent 3d4363a commit 5694eef
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions usr/share/66/service/postgresql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[main]
@type = classic
@version = 0.0.1
@description = "PostgreSQL daemon"
@user = ( root )

[start]
@build = custom
@shebang = "/bin/sh"
@execute = (

. /etc/default/postgresql
: ${PGDATA:="$PGROOT/data"}

if [ "$PGROOT" != "/var/lib/postgresql" ]; then
echo "Creating symlink /var/lib/postgresql -> $PGROOT"

# Remove /var/lib/postgres if empty dir, but not if symlink
if [ ! -L /var/lib/postgres ] && [ -d /var/lib/postgres ]; then
rmdir /var/lib/postgres
fi

ln -sf "$PGROOT" /var/lib/postgresql
fi


if [ ! -d "$PGDATA" ]; then
echo "Initializing database in $PGDATA"

execl-toc -X -d "$PGDATA" -u postgres -g postgres -m 0700
su - postgres -m -c "/usr/bin/initdb $INITOPTS -D '$PGDATA'" >/dev/null

if [ -f /etc/postgresql/postgresql.conf ]; then
ln -sf /etc/postgresql/postgresql.conf "$PGDATA/postgresql.conf"
fi
fi

exec s6-setuidgid postgres:postgres postgres -D "$PGDATA" $PGOPTS 2>&1

)

0 comments on commit 5694eef

Please sign in to comment.