michael@300: #!@l_prefix@/bin/openpkg rc michael@300: ## michael@300: ## rc.postgresql -- Run-Commands michael@300: ## michael@300: michael@300: %config michael@300: postgresql_enable="$openpkg_rc_def" michael@300: postgresql_flags="" michael@300: postgresql_datadir="@l_prefix@/var/postgresql/db" michael@300: postgresql_rundir="@l_prefix@/var/postgresql/run" michael@300: postgresql_shut_mode="fast" michael@300: postgresql_socket_inet="127.0.0.1" michael@300: postgresql_socket_unix="@l_prefix@/var/postgresql/run" michael@300: postgresql_log_prolog="true" michael@300: postgresql_log_epilog="true" michael@300: postgresql_log_numfiles="10" michael@300: postgresql_log_minsize="1M" michael@300: postgresql_log_complevel="9" michael@300: postgresql_slony1="no" michael@300: michael@300: %common michael@300: postgresql_opts="-h $postgresql_socket_inet -k $postgresql_socket_unix" michael@300: postgresql_opts="$postgresql_opts $postgresql_flags" michael@300: postgresql_logfile="$postgresql_rundir/postgresql.log" michael@300: postgresql_pidfile="$postgresql_datadir/postgresql.pid" michael@300: postgresql_slony1_pidfile="$postgresql_rundir/slon.pid" michael@300: postgresql_slony1_start () { michael@300: ( . @l_prefix@/etc/postgresql/slony1.conf michael@300: nohup @l_prefix@/bin/slon \ michael@300: -d "$SLON_SYNC_LOGLEVEL" -g "$SLON_SYNC_GROUPSIZE" \ michael@300: -s "$SLON_SYNC_INTERVAL" -t "$SLON_SYNC_TIMEOUT" \ michael@300: "$SLON_CLUSTER_NAME" \ michael@300: user="$SLON_CONNECT_USER" password="$SLON_CONNECT_PASS" \ michael@300: dbname="$SLON_CONNECT_DBNAME" host="$SLON_CONNECT_HOST" michael@300: /dev/null 2>&1 & michael@300: echo $! >$postgresql_slony1_pidfile michael@300: ) >/dev/null 2>&1 michael@300: } michael@300: postgresql_slony1_stop () { michael@300: if [ -f $postgresql_slony1_pidfile ]; then michael@300: kill -TERM `cat $postgresql_slony1_pidfile` michael@300: rm -f $postgresql_slony1_pidfile michael@300: fi michael@300: } michael@300: postgresql_ctl () { michael@300: if [ -s $postgresql_pidfile ]; then michael@300: kill -0 `head -1 $postgresql_pidfile` >/dev/null 2>&1 michael@300: if [ $? -ne 0 ]; then michael@300: rm -f $postgresql_pidfile >/dev/null 2>&1 || true michael@300: rm -f $postgresql_rundir/.s* >/dev/null 2>&1 || true michael@300: fi michael@300: fi michael@300: cmd="$1"; shift michael@300: @l_prefix@/bin/pg_ctl $cmd \ michael@300: -l $postgresql_logfile \ michael@300: -D $postgresql_datadir \ michael@300: ${1+"$@"} michael@300: } michael@300: michael@300: %status -u @l_rusr@ -o michael@300: postgresql_usable="unknown" michael@300: postgresql_active="no" michael@300: rcService postgresql enable yes && \ michael@300: postgresql_ctl status >/dev/null && \ michael@300: postgresql_active="yes" michael@300: echo "postgresql_enable=\"$postgresql_enable\"" michael@300: echo "postgresql_usable=\"$postgresql_usable\"" michael@300: echo "postgresql_active=\"$postgresql_active\"" michael@300: michael@300: %start -p 400 -u @l_rusr@ michael@300: rcService postgresql enable yes || exit 0 michael@300: rcService postgresql active yes && exit 0 michael@300: postgresql_ctl start -o "$postgresql_opts" michael@300: if rcVarIsYes postgresql_slony1; then michael@300: postgresql_slony1_start michael@300: fi michael@300: michael@300: %stop -p 600 -u @l_rusr@ michael@300: rcService postgresql enable yes || exit 0 michael@300: rcService postgresql active no && exit 0 michael@300: postgresql_ctl stop -m "$postgresql_shut_mode" michael@300: if rcVarIsYes postgresql_slony1; then michael@300: postgresql_slony1_stop michael@300: fi michael@300: michael@300: %restart -p 400 -u @l_rusr@ michael@300: rcService postgresql enable yes || exit 0 michael@300: rcService postgresql active no && exit 0 michael@300: postgresql_ctl restart -o "$postgresql_opts" -m "$postgresql_shut_mode" michael@300: if rcVarIsYes postgresql_slony1; then michael@300: postgresql_slony1_stop michael@300: postgresql_slony1_start michael@300: fi michael@300: michael@300: %reload -p 400 -u @l_rusr@ michael@300: rcService postgresql enable yes || exit 0 michael@300: rcService postgresql active no && exit 0 michael@300: postgresql_ctl reload michael@300: michael@300: %daily -u @l_rusr@ michael@300: rcService postgresql enable yes || exit 0 michael@300: shtool rotate -f \ michael@300: -n ${postgresql_log_numfiles} -s ${postgresql_log_minsize} -d -c \ michael@300: -z ${postgresql_log_complevel} -m 600 -o @l_rusr@ -g @l_rgrp@ \ michael@300: -P "$postgresql_log_prolog" \ michael@300: -E "$postgresql_log_epilog" \ michael@300: $postgresql_logfile michael@300: