1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
# -*- mode:sh -*-
# vim:syn=sh
BINDIR=$(dirname $(readlink -f "$0"))
BASEDIR=${BASEDIR:-"$(readlink -f $(dirname "$0")/..)"}
CONFDIRS=("${BASEDIR}/etc" ~/.config/ftpsync /etc/ftpsync)
LOCKDIR="${BASEDIR}/locks"
LOGDIR="${BASEDIR}/log"
function send_mail_new_version() {
# Check if there is a newer version of ftpsync. If so inform the admin, but not
# more than once every third day.
if [[ -r ${TO}/project/ftpsync/LATEST.VERSION ]]; then
LATEST=$(< "${TO}/project/ftpsync/LATEST.VERSION")
if [[ ${VERSION} =~ ^[0-9]+$ ]] && [[ ${LATEST} =~ ^[0-9]+$ ]] &&
[[ ${LATEST} -gt ${VERSION} ]]; then
if [[ -n ${MAILTO} ]]; then
interval=$((7 * 24 * 3600))
difference=$interval
if [[ -f ${LOGDIR}/ftpsync.newversion ]]; then
stamptime=$(< "${LOGDIR}/ftpsync.newversion")
unixtime=$(date +%s)
difference=$(( $unixtime - $stamptime ))
fi
if [[ ${difference} -ge $interval ]]; then
# Only warn every seventh day
mailf -s "[$(hostname -s)] Update for ftpsync available" -b "Hello admin,
i found that there is a new version of me available.
Me lonely ftpsync is currently version: ${VERSION}
New release of myself is available as: ${LATEST}
Me, myself and I - and the Debian mirroradmins - would be very grateful
if you could update me. You can find the latest version on your mirror,
check $(hostname -s):${TO}/project/ftpsync/ftpsync-${LATEST}.tar.gz
You can ensure the validity of that file by using sha512sum or md5sum
against the available checksum files secured with a signature from the
Debian FTPMaster signing key.
" ${MAILTO}
date +%s > "${LOGDIR}/ftpsync.newversion"
fi
fi
else
# Remove a possible stampfile
rm -f "${LOGDIR}/ftpsync.newversion"
fi
fi
}
|