2010-03-02 06:01:46 +01:00
|
|
|
#!/sbin/runscript
|
|
|
|
|
2010-03-02 06:45:21 +01:00
|
|
|
: ${PGLOG:=/var/log/postgresql.log}
|
|
|
|
extra_commands="reload"
|
2010-03-02 06:01:46 +01:00
|
|
|
|
|
|
|
depend()
|
|
|
|
{
|
|
|
|
use net
|
|
|
|
provide postgresql
|
|
|
|
}
|
|
|
|
|
2010-03-02 06:45:21 +01:00
|
|
|
start_pre()
|
2010-03-02 06:01:46 +01:00
|
|
|
{
|
|
|
|
if [ ! -d "$PGDATA" ] ; then
|
2010-03-02 06:45:21 +01:00
|
|
|
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}
|
2010-03-02 06:01:46 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
ebegin "Starting PostgreSQL"
|
2010-03-02 06:45:21 +01:00
|
|
|
su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} \
|
|
|
|
-W start ${PGOPTS}"
|
2010-03-02 06:01:46 +01:00
|
|
|
eend $?
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
2010-03-02 06:45:21 +01:00
|
|
|
ebegin "Stopping PostgreSQL"
|
|
|
|
su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} -w stop"
|
2010-03-02 06:01:46 +01:00
|
|
|
eend $?
|
|
|
|
}
|
|
|
|
|
|
|
|
reload()
|
|
|
|
{
|
|
|
|
ebegin "Reloading PostgreSQL configuration"
|
2010-03-02 06:45:21 +01:00
|
|
|
su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} reload"
|
2010-03-02 06:01:46 +01:00
|
|
|
eend $?
|
|
|
|
}
|