vp-build/srcpkgs/postgresql/files/postgresql.rc
Juan RP e791f83899 postgresql: improve rc service, INSTALL, add pam conf file.
--HG--
extra : convert_revision : d5fe81f0ac5134f796f8e9fce96e53c764fbfacf
2010-03-02 06:45:21 +01:00

48 lines
870 B
Plaintext

#!/sbin/runscript
: ${PGLOG:=/var/log/postgresql.log}
extra_commands="reload"
depend()
{
use net
provide postgresql
}
start_pre()
{
if [ ! -d "$PGDATA" ] ; then
einfo "Creating PostgreSQL dbdir: ${PGDATA}"
mkdir -p ${PGDATA} && \
chown -R ${PGUSER}.${PGGROUP} ${PGDATA}
einfo "Initializing PostgreSQL dbdir: ${PGDATA}"
su -l ${PGUSER} -c "/usr/bin/initdb -D ${PGDATA}"
fi
if [ ! -e ${PGLOG} ]; then
touch -f ${PGLOG}
chown ${PGUSER} ${PGLOG}
fi
}
start()
{
ebegin "Starting PostgreSQL"
su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} \
-W start ${PGOPTS}"
eend $?
}
stop()
{
ebegin "Stopping PostgreSQL"
su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} -w stop"
eend $?
}
reload()
{
ebegin "Reloading PostgreSQL configuration"
su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} reload"
eend $?
}