mirror: Added support for running command after mirror sync is completed.
This commit is contained in:
parent
9b243b66d7
commit
73e88d179a
3 changed files with 16 additions and 1 deletions
|
@ -85,6 +85,7 @@ trap "rm -f ${LOCKFILE}" INT TERM EXIT
|
||||||
echo $$ > ${LOCKFILE}
|
echo $$ > ${LOCKFILE}
|
||||||
|
|
||||||
for mirror in ${SYNC} ; do
|
for mirror in ${SYNC} ; do
|
||||||
|
POSTCMD=""
|
||||||
SRC=""
|
SRC=""
|
||||||
RSYNCOPTS=""
|
RSYNCOPTS=""
|
||||||
. ${CONFDIR}/${mirror}.conf
|
. ${CONFDIR}/${mirror}.conf
|
||||||
|
@ -98,6 +99,14 @@ for mirror in ${SYNC} ; do
|
||||||
rsync -aH -4 ${EXTRA_OPTS} --numeric-ids --delete --delete-after \
|
rsync -aH -4 ${EXTRA_OPTS} --numeric-ids --delete --delete-after \
|
||||||
--delay-updates --no-motd ${RSYNCOPTS} --log-file=${LOGFILE} \
|
--delay-updates --no-motd ${RSYNCOPTS} --log-file=${LOGFILE} \
|
||||||
${SRC} /srv/mirrors/${mirror}/
|
${SRC} /srv/mirrors/${mirror}/
|
||||||
|
if [ "${POSTCMD}" != "" ]; then
|
||||||
|
[ ${VERBOSE} -eq 1 ] && echo "Running post for ${mirror} ..."
|
||||||
|
echo "`date '+%Y/%m/%d %H:%M:%S'` [$$] Running post for ${mirror} ..." \
|
||||||
|
>> ${LOGFILE}
|
||||||
|
${POSTCMD} 2>&1 | awk \
|
||||||
|
"{ print strftime(\"%Y/%m/%d %H:%M:%S\") \" [$$] \" \$0 }" \
|
||||||
|
>> ${LOGFILE}
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -f ${LOCKFILE}
|
rm -f ${LOCKFILE}
|
||||||
|
|
|
@ -83,6 +83,9 @@ class mirror($datadir = "/srv/mirrors") {
|
||||||
# $source:
|
# $source:
|
||||||
# Rsync path from where to sync mirror
|
# Rsync path from where to sync mirror
|
||||||
#
|
#
|
||||||
|
# $postcmd:
|
||||||
|
# Run this command after sync is completed
|
||||||
|
#
|
||||||
# $rsync_options:
|
# $rsync_options:
|
||||||
# Extra options for rsync
|
# Extra options for rsync
|
||||||
#
|
#
|
||||||
|
@ -97,7 +100,7 @@ class mirror($datadir = "/srv/mirrors") {
|
||||||
# ],
|
# ],
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
define mirror::mirror($source, $rsync_options=[]) {
|
define mirror::mirror($source, $rsync_options=[], $postcmd=undef) {
|
||||||
|
|
||||||
require mirror
|
require mirror
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
SRC="<%= @source %>"
|
SRC="<%= @source %>"
|
||||||
RSYNCOPTS="<%= @rsync_options.join(' ') %>"
|
RSYNCOPTS="<%= @rsync_options.join(' ') %>"
|
||||||
|
<% if @postcmd -%>
|
||||||
|
POSTCMD="<%= @postcmd %>"
|
||||||
|
<% end -%>
|
||||||
|
|
Loading…
Add table
Reference in a new issue