#!/bin/sh # # PostgreSQL startup/shutdown script PGUSER=postgres SCRIPTDIR=/usr/local/staff/scripts SU=/usr/athena/bin/su PGSQLDIR=/mpkg/postgresql/7.3/bin export PGSQLDIR PGDBHOME=/misc0/postgresql export PGDBHOME PATH=/sbin:/usr/sbin:/usr/bin:$PGSQLDIR export PATH LOG=$PGDBHOME/startup.log export LOG touch $LOG chown $PGUSER $LOG chmod a+r $LOG case "$1" in 'start') echo "$0: starting up" >> $LOG date >> $LOG rm -f /tmp/.s.PGSQL.5432 $SU -K $PGUSER -c 'sh -c "$PGSQLDIR/pg_ctl -D $PGDBHOME -o -i start >> $LOG 2>&1 &"' ;; 'local') echo "$0: starting up local" >> $LOG date >> $LOG rm -f /tmp/.s.PGSQL.5432 $SU -K $PGUSER -c 'sh -c "$PGSQLDIR/pg_ctl -D $PGDBHOME start >> $LOG 2>&1 &"' ;; 'stop') echo "$0: shutting down" >> $LOG date >> $LOG $SU -K $PGUSER -c 'sh -c "$PGSQLDIR/pg_ctl -D $PGDBHOME stop >> $LOG 2>&1 &"' ;; 'restart') echo "$0: restarting" >> $LOG date >> $LOG $SU -K $PGUSER -c 'sh -c "$PGSQLDIR/pg_ctl -D $PGDBHOME -o -i restart >> $LOG 2>&1 &"' ;; 'dump') echo "$0: dumping database" >> $LOG date >> $LOG $SCRIPTDIR/postgresql-backup ;; 'init') echo "$0: initializing" >> $LOG date >> $LOG $SU -K $PGUSER -c 'sh -c "$PGSQLDIR/initdb -D $PGDBHOME >> $LOG 2>&1 &"' ;; 'status') $PGSQLDIR/pg_ctl -D $PGDBHOME status ;; *) echo "usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0