diff options
author | Nicolas Reynolds <fauno@kiwwwi.com.ar> | 2012-02-29 02:31:43 -0300 |
---|---|---|
committer | Nicolas Reynolds <fauno@kiwwwi.com.ar> | 2012-02-29 02:31:43 -0300 |
commit | e87b42b0f90e1a4d8b255f1dab945f2f3bb13cdc (patch) | |
tree | e36d5720f76b5db9dd5f97260108607023d7d2e7 /extra/postgresql/postgresql.rcd | |
parent | c0e37a8f32f335c12352f23cdc73113099e057ec (diff) | |
parent | 32b05a621cb20af1bd4b7cd6f5609b7512bb20f1 (diff) |
Merge branch 'master' of ssh://vparabola/home/parabola/abslibre-pre-mips64el
Conflicts:
extra/avfs/PKGBUILD
extra/gtk2/PKGBUILD
extra/hercules/PKGBUILD
multilib/lib32-libcap/PKGBUILD
multilib/lib32-qt/PKGBUILD
Diffstat (limited to 'extra/postgresql/postgresql.rcd')
-rwxr-xr-x | extra/postgresql/postgresql.rcd | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/extra/postgresql/postgresql.rcd b/extra/postgresql/postgresql.rcd new file mode 100755 index 000000000..f3600b30b --- /dev/null +++ b/extra/postgresql/postgresql.rcd @@ -0,0 +1,79 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions +. /etc/conf.d/postgresql + +# Default PGROOT if it wasn't defined in the conf.d file +PGROOT=${PGROOT:-/var/lib/postgres} +PGLOG=${PGLOG:-/var/log/postgresql.log} +PGCTL_BIN=/usr/bin/pg_ctl +PGCTL_ARGS=(-D "$PGROOT/data" -l "$PGLOG" -s -w) +[[ $PGOPTS ]] && PGCTL_ARGS+=(-o "$PGOPTS") + +postgres_init() { + # initialization + if [[ ! -d "$PGROOT/data" ]]; then + mkdir -p "$PGROOT/data" && chown -R postgres:postgres "$PGROOT" + su - postgres -c "/usr/bin/initdb $INITOPTS -D '$PGROOT/data'" + fi + if [[ ! -e "$PGLOG" ]]; then + touch "$PGLOG" + chown postgres "$PGLOG" + fi +} + +do_postgres() { + su - postgres -c "'$PGCTL_BIN' $(printf '%q ' "${PGCTL_ARGS[@]}" "$@")" +} + +case $1 in + start) + postgres_init + stat_busy "Starting PostgreSQL" + if do_postgres start; then + add_daemon postgresql + stat_done + else + stat_fail + exit 1 + fi + ;; + stop) + stat_busy "Stopping PostgreSQL" + if do_postgres stop -m fast; then + rm_daemon postgresql + stat_done + else + stat_fail + exit 1 + fi + ;; + reload) + stat_busy "Reloading PostgreSQL" + if do_postgres reload; then + stat_done + else + stat_fail + exit 1 + fi + ;; + restart) + postgres_init + stat_busy "Restarting PostgreSQL" + if do_postgres restart -m fast; then + add_daemon postgresql + stat_done + else + stat_fail + exit 1 + fi + ;; + status) + stat_busy "Checking PostgreSQL status"; + ck_status postgresql + ;; + *) + echo "usage: $0 {start|stop|reload|restart|status}" + exit 1 +esac |