#! /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 # pidfile: /var/run/postmaster.pid # PG_HOME=/scratch/oct/pgsql PG_DATA=$PG_HOME/data PG_USER=postgre # 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 $PG_HOME/bin/postmaster ] || exit 0 # This script is slightly unusual in that the name of the daemon (postmaster) # is not the same as the name of the subsystem (postgresql) # See how we were called. case "$1" in start) echo -n "Starting postgresql: " su - $PG_USER -c "$PG_HOME/bin/postmaster -S -D $PG_DATA" RETVAL=$? sleep 1 if [ $RETVAL -eq 0 ]; then touch /var/lock/subsys/postgresql cp $PG_DATA/postmaster.pid /var/run success "postmaster startup" else failure "postmaster startup" fi echo ;; stop) echo -n "Stopping postgresql: " killproc postmaster rm -f /var/run/postmaster.pid rm -f /var/lock/subsys/postgresql echo ;; status) status postmaster ;; restart) $0 stop $0 start ;; *) echo "Usage: postgresql {start|stop|status|restart}" exit 1 esac exit 0