Created
September 12, 2012 16:25
-
-
Save mitchellh/3707876 to your computer and use it in GitHub Desktop.
init file for pg clusters on Ubuntu
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
#!/bin/sh | |
set -e | |
### BEGIN INIT INFO | |
# Provides: postgresql-cluster-<%= @cluster_name %> | |
# Required-Start: $local_fs $remote_fs $network $time | |
# Required-Stop: $local_fs $remote_fs $network $time | |
# Should-Start: $syslog | |
# Should-Stop: $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: PostgreSQL Cluster: <%= @cluster_name %> | |
### END INIT INFO | |
CLUSTER=<%= @cluster_name %> | |
OWNER=<%= @owner %> | |
VERSION=<%= @version %> | |
case "$1" in | |
start|stop|restart|reload) | |
su -c "pg_ctlcluster ${VERSION} ${CLUSTER} $1" $OWNER | |
;; | |
status) | |
pg_lsclusters -h | awk "BEGIN {rc=0}; \$2 == \"${CLUSTER}\" && \$4 == \"down\" {rc=3}; END {exit rc}" | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|reload|status}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment