haini.sh/bin/postgresql

30 lines
801 B
Text
Raw Permalink Normal View History

2021-06-08 18:07:45 +00:00
#!/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}"
2021-06-09 16:39:33 +00:00
mkdir -p /run/postgresql
2021-06-08 18:07:45 +00:00
daemonize -c "${PGDATA}" -o "${log}" -a -e "${log}" /usr/bin/postgres
;;
esac