#!/bin/sh # # /etc/rc.d/rc.postgres # # Start/stop/restart the PostgreSQL database server. # export PGDATA=/var/lib/pgsql USE_TCP=1 if [ "$2" = "usetcp" ]; then USE_TCP=1 elif [ "$2" = "notcp" ]; then USE_TCP=0 fi if [ "${USE_TCP}" == "1" ]; then OPTIONS="-o -i" fi postgres_start() { if [ -x /usr/bin/pg_ctl -a -x /usr/bin/postmaster ]; then echo "Starting PostgreSQL..." su postgres -c "/usr/bin/pg_ctl start -l /var/log/postgresql -D ${PGDATA} ${OPTIONS}" fi } postgres_stop() { echo "Stopping PostgreSQL..." su postgres -c "/usr/bin/pg_ctl stop -w -m fast" } postgres_restart() { echo "Restarting PostgreSQL..." su postgres -c "/usr/bin/pg_ctl restart -w -m fast ${OPTIONS}" } postgres_reload() { echo "Reloading PostgreSQL..." su postgres -c "/usr/bin/pg_ctl reload" } postgres_status() { su postgres -c "/usr/bin/pg_ctl status" } case "$1" in 'start') postgres_start ;; 'stop') postgres_stop ;; 'restart') postgres_restart ;; 'reload') postgres_reload ;; 'status') postgres_status ;; *) echo "Usage: $0 start|stop|restart|reload|status" ;; esac