Created
July 10, 2014 13:58
-
-
Save midwire/372f14f593db4acf55e1 to your computer and use it in GitHub Desktop.
Postgres control script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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