diff --git a/mirror/files/sync-mirrors b/mirror/files/sync-mirrors index be66dd1..748179a 100755 --- a/mirror/files/sync-mirrors +++ b/mirror/files/sync-mirrors @@ -85,6 +85,7 @@ trap "rm -f ${LOCKFILE}" INT TERM EXIT echo $$ > ${LOCKFILE} for mirror in ${SYNC} ; do + POSTCMD="" SRC="" RSYNCOPTS="" . ${CONFDIR}/${mirror}.conf @@ -98,6 +99,14 @@ for mirror in ${SYNC} ; do rsync -aH -4 ${EXTRA_OPTS} --numeric-ids --delete --delete-after \ --delay-updates --no-motd ${RSYNCOPTS} --log-file=${LOGFILE} \ ${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 rm -f ${LOCKFILE} diff --git a/mirror/manifests/init.pp b/mirror/manifests/init.pp index 58a6e81..c254db5 100644 --- a/mirror/manifests/init.pp +++ b/mirror/manifests/init.pp @@ -83,6 +83,9 @@ class mirror($datadir = "/srv/mirrors") { # $source: # Rsync path from where to sync mirror # +# $postcmd: +# Run this command after sync is completed +# # $rsync_options: # 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 diff --git a/mirror/templates/mirror.conf.erb b/mirror/templates/mirror.conf.erb index 9e69429..548ed4b 100644 --- a/mirror/templates/mirror.conf.erb +++ b/mirror/templates/mirror.conf.erb @@ -1,2 +1,5 @@ SRC="<%= @source %>" RSYNCOPTS="<%= @rsync_options.join(' ') %>" +<% if @postcmd -%> +POSTCMD="<%= @postcmd %>" +<% end -%>