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