Skip to content

Instantly share code, notes, and snippets.

@midwire
Created July 10, 2014 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save midwire/372f14f593db4acf55e1 to your computer and use it in GitHub Desktop.
Save midwire/372f14f593db4acf55e1 to your computer and use it in GitHub Desktop.
Postgres control script.
#!/bin/bash
cmd=$1
function init_postgres() {
initdb /usr/local/var/postgres
}
function start_postgres() {
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
}
function stop_postgres() {
pg_ctl -D /usr/local/var/postgres stop -s -m fast
}
case $cmd in
init )
init_postgres
;;
start )
start_postgres
;;
stop )
stop_postgres
;;
restart )
stop_postgres
start_postgres
;;
status )
pg_ctl status -D /usr/local/var/postgres
;;
* )
echo "Usage: $0 [init, status, start, stop, restart]"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment