#!/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 # Source function library . /etc/rc.d/init.d/functions # Get network config . /etc/sysconfig/network # Get service config [ -f /etc/sysconfig/postgresql ] && . /etc/sysconfig/postgresql # Check that networking is up. if [ "${NETWORKING}" = "no" ]; then echo "WARNING: Networking is down. Postgresql service can't be runed." exit 1 fi # Sanity check [ -f /tmp/.s.PGSQL.5432 ] || rm -f /tmp/.s.PGSQL.5432 # See how we were called. case "$1" in start) # Check if the service is already running? if [ ! -f /var/lock/subsys/postgresql ]; then show Starting postgresql busy su postgres -c "/usr/bin/postmaster -D /var/state/pgsql" if ps ax | grep -v grep | grep -q postmaster; then deltext;ok else deltext;fail fi else echo "Postgresql already is running" fi touch /var/lock/subsys/postgresql ;; stop) show Stopping postgresql service killproc postmaster sleep 2 rm -f /var/run/postmaster.pid rm -f /var/lock/subsys/postgresql ;; status) status postmaster ;; restart|reload) $0 stop $0 start ;; *) echo "Usage: postgresql {start|stop|status|restart|reload}" exit 1 esac exit 0