#!/bin/bash CONF=etc/postgresql.conf PG_CTL=`which pg_ctl 2>/dev/null` set -e pwd . $APPSH_BASEDIR/.app/lib/app-conf PG_CTL_OPTIONS="`get_conf $APPSH_BASEDIR $APPSH_NAME $APPSH_INSTANCE postgresql.pg_ctl_options`" if [ -z "$PG_CTL" ] then echo "Could not find pg_ctl. Is your env.PATH correctly set?". exit 1 fi if [ -z "$DATA" ] then DATA=../../../data fi if [ ! -d $DATA ] then echo "Missing data dir: $DATA" exit 1 fi if [ -z "$LOG" ] then LOG=../../../log fi if [ ! -d $LOG ] then echo "Missing log dir: $LOG, creating" mkdir -p $LOG fi LOG=$LOG/postgresql.log if [ ! -r $CONF ] then echo "Missing config file: $CONF" exit 1 fi # TODO: figure out how if pg_ctl exits with sane exit codes. x=`dirname $CONF` CONF=`cd $x; pwd`/`basename $CONF` DATA=`cd $DATA; pwd` x=`dirname $LOG` LOG=`cd $x; pwd`/`basename $LOG` case "$APPSH_METHOD" in start) echo "Starting postgresql" exec $PG_CTL start \ -D "$DATA" \ -o "$PG_CTL_OPTIONS -c config_file=$CONF" \ -l $LOG & ;; stop) echo "Stopping postgresql" exec $PG_CTL stop \ -D "$DATA" \ -o "$PG_CTL_OPTIONS -c config_file=$CONF" ;; *) echo "Unknown method: $APPSH_METHOD" exit 0 ;; esac