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