#!/bin/bash # Postgres control script for Mac OS X v1.0 by Will Green # Start and stop Postgres easily # Taken from http://flux.org.uk/howto/postgres/macosx # This code is dedicated to the public domain by Will Green. Anyone is # free to copy, modify, publish, use, compile, sell, or distribute # this code, either in source code form or as a compiled binary, for # any purpose, commercial or non-commercial, and by any means. # To use: # change the value of PGDATA (below) to match your database data directory # rename: mv pg.txt pg.sh # make executable: chmod 755 pg.sh export PGDATA=~/postgres # sets the path to the database data directory start() { echo -n "Starting Postgres: " pg_ctl start -l $PGDATA/postgres.log return } stop() { echo -n "Shutting down Postgres: " pg_ctl stop -l $PGDATA/postgres.log return } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo "Usage: {start|stop|restart}" exit 1 ;; esac exit $?