DragonFly BSD
DragonFly users List (threaded) for 2011-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

postgresql start-script


From: shi hd <78dd085bdacf@xxxxxxxxx>
Date: Thu, 13 Jan 2011 23:12:44 +0800

I don't know if there is someone already did that, I constructed myself. It does work though it is a little bit primitive and rudimentary. Any modifications and improvements are welcomed.

#! /bin/sh

# $PostgreSQL boot time startup script for DragonflyBSD.  Copy this file to
# /usr/pkg/etc/rc.d/postgresql and link to /etc/rc.d/postgresql. v 0.9
# 2011/01/08 00:40:00 Shi Exp $

. /etc/rc.subr

name="pgsql"
command="/usr/pkg/bin/pg_ctl"
start_cmd="pg_start"
stop_cmd="pg_stop"
restart_cmd="pg_restart"
status_cmd="pg_status"
pg_user="pgsql"
datadir="/home/database"
logfile="/home/database/log"

pg_start()
{
    echo -n 'Starting POSTGRESQL'
    su -fm ${pg_user} -c "${command} -D ${datadir} -l ${logfile} start -w" &
}

pg_stop()
{
    echo -n 'Stopping POSTGRESQL'
    su -fm ${pg_user} -c "${command} -D ${datadir} stop -s -m fast -w"
}

pg_restart()
{
    echo -n 'Restarting POSTGRESQL'
    su -fm ${pg_user} -c "${command} -D ${datadir} stop -s -m fast -w"
    su -fm ${pg_user} -c "${command} -D ${datadir} -l ${logfile} start -w" &
}

pg_status()
{
    echo -n 'Show STATUS'
    su -fm ${pg_user} -c "${command} -D ${datadir} status"
}

load_rc_config $name
run_rc_command "$1"

---------------------------------
                             hd


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]