Start/Stop/Restart PostgreSQL 8.3
Installed PostgreSQL 8.3 with MacPorts (Snow Leopard). This script wirl make it easy to start/stop/reload your local PostgreSQL server:
#!/bin/bash
echo "You need sudo rights to perform this action ..."
plist="/Library/LaunchDaemons/org.macports.postgresql83-server.plist"
launchctl=$(which launchctl) # if needed, set this to an absolute path
if [[ -z "$1" ]]; then
echo "Usage $(basename $0) start|stop|reload"
exit 1
fi
mode="load"
if [[ "$1" == "start" ]]; then mode="load";
elif [[ "$1" == "stop" ]]; then mode="unload";
elif [[ "$1" == "reload" ]]; then mode="reload";
else
echo "Unknown mode '$1'";
exit 2;
fi
if [[ "$mode" == "reload" ]]; then
exit $(sudo $launchctl unload -w "$plist" && \
sudo $launchctl load -w "$plist")
fi
sudo $launchctl "$mode" -w "$plist"