containers-postgresql/postgresqld.sh

24 lines
511 B
Bash
Raw Normal View History

#!/bin/sh
set -e
2022-03-07 18:35:23 +00:00
user=postgres
case $1 in
stop)
2022-03-07 18:35:23 +00:00
su ${user} -c "pg_ctl stop -D ${PGDATA}" ;;
reload)
2022-03-07 18:35:23 +00:00
su ${user} -c "pg_ctl reload -D ${PGDATA}" ;;
*)
install -dm 2750 -o ${user} -g ${user} /run/postgresql
chown -R ${user}:${user} ${PGBASE}
if test ! -f ${PGDATA}/PG_VERSION ; then
2022-03-07 18:35:23 +00:00
su ${user} -c "/usr/bin/initdb -D ${PGDATA}"
echo "include_dir = '/etc/postgres.d'" >> ${PGDATA}/postgresql.conf
fi
2022-03-07 18:35:23 +00:00
daemonize -u ${user} -c ${PGDATA} /usr/bin/postgres
;;
esac