Last active
February 27, 2019 17:08
-
-
Save buruzaemon/5351379 to your computer and use it in GitHub Desktop.
Sample Postgresql start/stop script for Cygwin
This file contains hidden or 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
#!/usr/bin/bash | |
CYGWIN=server | |
CYGSERVER=/usr/sbin/cygserver | |
PGDATA=/var/psql/data | |
PGCTL=/usr/sbin/pg_ctl | |
PGLOG=/var/psql/log/postgresql.log | |
usage() { | |
echo "USAGE: pg (start|stop|restart|reload|status)" | |
echo | |
} | |
start() { | |
echo "starting postgresql..." | |
$CYGSERVER -E & 2>&1 | |
sleep 3 | |
$PGCTL start -D $PGDATA -l $PGLOG | |
echo | |
} | |
stop() { | |
echo "stopping postgresql..." | |
$PGCTL stop -D $PGDATA -m smart | |
$CYGSERVER -S 2>&1 | |
sleep 3 | |
echo | |
} | |
restart() { | |
echo "restarting postgresql..." | |
$PGCTL restart -D $PGDATA -m smart | |
echo | |
} | |
reload() { | |
echo "reloading postgresql..." | |
$PGCTL reload -D $PGDATA | |
echo | |
} | |
status() { | |
$PGCTL status -D $PGDATA | |
} | |
if [ -n "$1" ] | |
then | |
case $1 in | |
start) | |
start | |
exit 0 | |
;; | |
stop) | |
stop | |
exit 0 | |
;; | |
restart) | |
restart | |
exit 0 | |
;; | |
reload) | |
reload | |
exit 0 | |
;; | |
status) | |
status | |
exit 0 | |
;; | |
*) | |
usage | |
exit 1 | |
;; | |
esac | |
else | |
usage | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this script under
$HOME/bin
, and make sure that$HOME/bin
is on your$PATH
.