mirror: Moved logging to own function and added log message when sync is complete to sync-mirrors script.
This commit is contained in:
parent
02574a3a37
commit
e4a9fd523f
1 changed files with 11 additions and 7 deletions
|
@ -9,6 +9,11 @@ usage() {
|
||||||
echo " `basename $0` -l" 1>&2
|
echo " `basename $0` -l" 1>&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logmsg() {
|
||||||
|
[ ${VERBOSE} -eq 1 ] && echo "$1"
|
||||||
|
echo "`date '+%Y/%m/%d %H:%M:%S'` [$$] $1" >> ${LOGFILE}
|
||||||
|
}
|
||||||
|
|
||||||
if [ -d ${CONFDIR} ]; then
|
if [ -d ${CONFDIR} ]; then
|
||||||
MIRRORLIST=`ls ${CONFDIR}/*.conf 2> /dev/null | while read f ; \
|
MIRRORLIST=`ls ${CONFDIR}/*.conf 2> /dev/null | while read f ; \
|
||||||
do basename $f | sed -e 's/\.conf$//' ; done`
|
do basename $f | sed -e 's/\.conf$//' ; done`
|
||||||
|
@ -93,22 +98,21 @@ for mirror in ${SYNC} ; do
|
||||||
echo "ERR: No SRC set for mirror ${mirror} ..." 1>&2
|
echo "ERR: No SRC set for mirror ${mirror} ..." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
[ ${VERBOSE} -eq 1 ] && echo "Starting ${mirror} sync ..."
|
logmsg "Starting ${mirror} sync ..."
|
||||||
echo "`date '+%Y/%m/%d %H:%M:%S'` [$$] Starting ${mirror} sync ..." \
|
|
||||||
>> ${LOGFILE}
|
|
||||||
rsync -aH -4 ${EXTRA_OPTS} --numeric-ids --delete --delete-delay \
|
rsync -aH -4 ${EXTRA_OPTS} --numeric-ids --delete --delete-delay \
|
||||||
--delay-updates --no-motd ${RSYNCOPTS} --log-file=${LOGFILE} \
|
--delay-updates --no-motd ${RSYNCOPTS} --log-file=${LOGFILE} \
|
||||||
--exclude=.~tmp~/ ${SRC} /srv/mirrors/${mirror}/
|
--exclude=.~tmp~/ ${SRC} /srv/mirrors/${mirror}/
|
||||||
if [ $? -ne 0 ]; then
|
STATUS=$?
|
||||||
|
if [ ${STATUS} -ne 0 ]; then
|
||||||
echo "WARN: Encountered errors on ${mirror} sync, see ${LOGFILE} for details" 1>&2
|
echo "WARN: Encountered errors on ${mirror} sync, see ${LOGFILE} for details" 1>&2
|
||||||
fi
|
fi
|
||||||
|
logmsg "Finished ${mirror} sync with exit status ${STATUS} ..."
|
||||||
if [ "${POSTCMD}" != "" ]; then
|
if [ "${POSTCMD}" != "" ]; then
|
||||||
[ ${VERBOSE} -eq 1 ] && echo "Running post for ${mirror} ..."
|
logmsg "Running post for ${mirror} ..."
|
||||||
echo "`date '+%Y/%m/%d %H:%M:%S'` [$$] Running post for ${mirror} ..." \
|
|
||||||
>> ${LOGFILE}
|
|
||||||
${POSTCMD} 2>&1 | awk \
|
${POSTCMD} 2>&1 | awk \
|
||||||
"{ print strftime(\"%Y/%m/%d %H:%M:%S\") \" [$$] \" \$0 }" \
|
"{ print strftime(\"%Y/%m/%d %H:%M:%S\") \" [$$] \" \$0 }" \
|
||||||
>> ${LOGFILE}
|
>> ${LOGFILE}
|
||||||
|
logmsg "Finished post for ${mirror} ..."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue