From f8b18dafeb8fc656483f0afadf7b67138d7e9c3b Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Sat, 27 Sep 2008 16:03:10 +0200 Subject: ftpsync Add a (rewritten) ftpsync script together with an config file example. Signed-off-by: Joerg Jaspert --- etc/common | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'etc/common') diff --git a/etc/common b/etc/common index ee2bd92..699481b 100644 --- a/etc/common +++ b/etc/common @@ -29,3 +29,24 @@ signal () { # Finally call ssh ssh $SSH_OPTIONS -i "$5" -o"user $3" -$4 "$2" sleep 1 >> ${LOG}/$1.log 2>&1 & } + + +# log something (basically echo it together with a timestamp) +# +# Set $PROGRAM to a string to have it added to the output. +log () { + if [ -z ${PROGRAM} ]; then + echo "$(date +"%b %d %H:%M:%S") $(hostname -s) [$$] $@" + else + echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${PROGRAM}[$$]: $@" + fi +} + +# log the message using log() but then also send a mail +# to the address configured in MAILTO (if non-empty) +error () { + log "$@" + if [ -z ${MAILTO} ]; then + echo "$@" | mail -e -s "$PROGRAM ERROR ($(hostname -s)) [$$]" ${MAILTO} + fi +} -- cgit v1.2.3