X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=bin%2Fbackup-script-wrapper;h=7da3208657c056b51f6abf27bf7670e6e952d55a;hb=3ed5497b057076f284ba71f975f8e0a5a16085c1;hp=61ef2434ead9561073dc775666e309e620722e8a;hpb=5cd16660ffb9be6bdde897397828c6e8f793a9f6;p=backup-script.git diff --git a/bin/backup-script-wrapper b/bin/backup-script-wrapper index 61ef243..7da3208 100755 --- a/bin/backup-script-wrapper +++ b/bin/backup-script-wrapper @@ -1,7 +1,7 @@ #!/bin/sh # # backup-script system for cloning systems using rsync -# Copyright (c)2008-2013 Alexander Barton, alex@barton.de +# Copyright (c)2008-2015 Alexander Barton, alex@barton.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -10,19 +10,41 @@ # Please read the file COPYING, README and AUTHORS for more information. # -MAILTO="logcheck" +if [ -z "$MAILTO" ]; then + if id "logcheck" >/dev/null 2>&1; then + MAILTO="logcheck" + elif fgrep "logcheck:" /etc/aliases >/dev/null 2>&1; then + MAILTO="logcheck" + else + MAILTO="root" + fi +fi NAME="backup-script" HOST=`hostname` -TMP="/tmp/$NAME.$$" +TMP=`mktemp /tmp/$NAME.XXXXXXXX` || exit 11 +LOGFILE="/var/log/backup-script.log" PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" export PATH -`dirname "$0"`/backup-script $* >>$TMP 2>&1 +exec >"$TMP" 2>&1 -cat $TMP | mail -s "$HOST: $NAME results" "$MAILTO" +echo "$NAME Report" +echo +echo " - Host: `hostname -f`" +echo " - User: `id -un`" +echo -rm -f $TMP +if [ -w "$LOGFILE" ]; then + "$(dirname "$0")/backup-script" "$@" | tee -a "$LOGFILE" +else + "$(dirname "$0")/backup-script" "$@" + echo "(Can't write logfile: \"$LOGFILE\"!)" +fi + +cat "$TMP" | mail -s "$HOST: $NAME results" "$MAILTO" + +rm -f "$TMP" # -eof-