|
|
|
#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
|
|
|
|
##
|
|
|
|
## rc.rsync -- Run-Commands
|
|
|
|
##
|
|
|
|
|
|
|
|
%config
|
|
|
|
rsync_enable="$openpkg_rc_def"
|
|
|
|
rsync_daemon="no"
|
|
|
|
rsync_flags=""
|
|
|
|
rsync_bind="127.0.0.1"
|
|
|
|
rsync_port="873"
|
|
|
|
rsync_nicelevel="10"
|
|
|
|
rsync_log_prolog="true"
|
|
|
|
rsync_log_epilog="true"
|
|
|
|
rsync_log_numfiles="10"
|
|
|
|
rsync_log_minsize="1M"
|
|
|
|
rsync_log_complevel="9"
|
|
|
|
|
|
|
|
%common
|
|
|
|
rsync_cfgfile="@l_prefix@/etc/rsync/rsync.conf"
|
|
|
|
rsync_logfile="@l_prefix@/var/rsync/rsync.log"
|
|
|
|
rsync_pidfile="@l_prefix@/var/rsync/rsync.pid"
|
|
|
|
rsync_signal () {
|
|
|
|
[ -f $rsync_pidfile ] && kill -$1 `cat $rsync_pidfile`
|
|
|
|
}
|
|
|
|
|
|
|
|
%status -u @l_susr@ -o
|
|
|
|
rsync_usable="unknown"
|
|
|
|
rsync_active="no"
|
|
|
|
rcService rsync enable yes && \
|
|
|
|
rsync_signal 0 && rsync_active="yes"
|
|
|
|
echo "rsync_enable=\"$rsync_enable\""
|
|
|
|
echo "rsync_usable=\"$rsync_usable\""
|
|
|
|
echo "rsync_active=\"$rsync_active\""
|
|
|
|
|
|
|
|
%start -u @l_susr@
|
|
|
|
rcService rsync enable yes || exit 0
|
|
|
|
rcService rsync active yes && exit 0
|
|
|
|
rcVarIsYes rsync_daemon || exit 0
|
|
|
|
flags="$rsync_flags"
|
|
|
|
echo $flags | grep -- --address >/dev/null
|
|
|
|
if [ $? -ne 0 -a ".$rsync_bind" != . ]; then
|
|
|
|
flags="$flags --address=$rsync_bind"
|
|
|
|
fi
|
|
|
|
echo $flags | grep -- --port >/dev/null
|
|
|
|
if [ $? -ne 0 -a ".$rsync_port" != . ]; then
|
|
|
|
flags="$flags --port=$rsync_port"
|
|
|
|
fi
|
|
|
|
nice -n $rsync_nicelevel @l_prefix@/bin/rsync $flags \
|
|
|
|
--daemon --config=$rsync_cfgfile
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
%stop -u @l_susr@
|
|
|
|
rcService rsync enable yes || exit 0
|
|
|
|
rcService rsync active no && exit 0
|
|
|
|
rcVarIsYes rsync_daemon || exit 0
|
|
|
|
rsync_signal TERM
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
%restart -u @l_susr@
|
|
|
|
rcService rsync enable yes || exit 0
|
|
|
|
rcService rsync active no && exit 0
|
|
|
|
rcVarIsYes rsync_daemon || exit 0
|
|
|
|
rc rsync stop start
|
|
|
|
|
|
|
|
%daily -u @l_susr@
|
|
|
|
rcService rsync enable yes || exit 0
|
|
|
|
rcVarIsYes rsync_daemon || exit 0
|
|
|
|
shtool rotate -f \
|
|
|
|
-n ${rsync_log_numfiles} -s ${rsync_log_minsize} -d \
|
|
|
|
-z ${rsync_log_complevel} -m 644 -o @l_susr@ -g @l_mgrp@ \
|
|
|
|
-P "${rsync_log_prolog}" \
|
|
|
|
-E "${rsync_log_epilog}; rc rsync restart" \
|
|
|
|
$rsync_logfile
|
|
|
|
|
|
|
|
%env
|
|
|
|
rcService rsync enable yes || exit 0
|
|
|
|
if [ -f "@l_prefix@/bin/ssh" ]; then
|
|
|
|
RSYNC_RSH="@l_prefix@/bin/ssh"
|
|
|
|
export RSYNC_RSH
|
|
|
|
fi
|
|
|
|
|