#! /bin/sh # postgresql This is the init script for starting up the PostgreSQL # server # # chkconfig: 345 85 15 # description: Starts and stops the PostgreSQL backend daemon that handles \ # all database requests. # processname: postmaster # # Source function library. . /etc/rc.d/init.d/functions # Get config. . /etc/sysconfig/network # Check that networking is up. # Pretty much need it for postmaster. [ ${NETWORKING} = "no" ] && exit 0 [ -f /usr/bin/postmaster ] || exit 0 # See how we were called. case "$1" in start) if ( ! ps ax | grep /usr/bin/post | grep -v grep > /dev/null); then rm -f /tmp/.s.PGSQL.* 2> /dev/null fi echo -n "Starting postgresql service: " su postgres -c '/usr/bin/postmaster -S -i -D/var/lib/pgsql' sleep 1 pid=`pidof postmaster` echo -n "postmaster [$pid]" touch /var/lock/subsys/postmaster echo ;; stop) echo -n "Stopping postgresql service: " killproc postmaster sleep 2 rm -f /var/lock/subsys/postmaster echo ;; status) status postmaster ;; restart) $0 stop $0 start ;; *) echo "Usage: postgres.init {start|stop|status|restart}" exit 1 esac exit 0