#!/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 if [ -f /etc/sysconfig/syslog ] ; then . /etc/sysconfig/syslog else ALLOW_TCP=no fi # 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 \ $([ "$ALLOW_TCP" = yes ] && echo "-i") \ $([ -n "$MAX_NUM_BACKENDS" ] && echo "-N $MAX_NUM_BACKENDS") \ $([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR") \ -o \ $([ "$POSTGRES_QUIET" = yes ] && echo "-Q") \ $([ "$POSTGRES_DIABLE_FSYNC" = yes ] && echo "-F") \ & 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