#!/bin/sh set -e export PGVER="${PGVER:-13}" export PGBASE="${PGBASE:-/var/lib/postgresql}" export PGDATA="${PGDATA:-$PGBASE/$PGVER/data}" export PGLANG="${PGLANG:-en_US.utf8}" case $1 in stop) pg_ctl stop -D "${PGDATA}" ;; reload) pg_ctl reload -D "${PGDATA}" ;; *) pid=/tmp/postgresql.pid log=${PGDATA}/postgresql.log if test ! -f "${PGDATA}/PG_VERSION" ; then /usr/bin/initdb --locale "${PGLANG}" -E UTF8 -D "${PGDATA}" echo "host all all samenet trust" >> "${PGDATA}/pg_hba.conf" echo "listen_addresses = '*'" >> "${PGDATA}/postgresql.conf" echo "external_pid_file = '${pid}'" >> "${PGDATA}/postgresql.conf" fi rm -f "${pid}" daemonize -c "${PGDATA}" -o "${log}" -a -e "${log}" /usr/bin/postgres ;; esac