X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=bin%2Fbackup-script-wrapper;h=64c9d7d8fef8832d627547010d2c38943ecad0dc;hb=81c39f7ce18885e81e1145cf39ceb2c078d61178;hp=a2de1d797557c17722d885cca029f83f87fcfaed;hpb=4c781b16f46a4d51eba2ffedb9d71d5618cac6c5;p=backup-script.git diff --git a/bin/backup-script-wrapper b/bin/backup-script-wrapper index a2de1d7..64c9d7d 100755 --- a/bin/backup-script-wrapper +++ b/bin/backup-script-wrapper @@ -13,7 +13,7 @@ if [ -z "$MAILTO" ]; then if id "logcheck" >/dev/null 2>&1; then MAILTO="logcheck" - elif fgrep "logcheck:" /etc/aliases >/dev/null 2>&1; then + elif grep -F "logcheck:" /etc/aliases >/dev/null 2>&1; then MAILTO="logcheck" else MAILTO="root" @@ -23,31 +23,23 @@ fi NAME="backup-script" DELIMITER="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" -HOST=`hostname -f` +HOST=$(hostname -f) LOGFILE="/var/log/$NAME.log" -PIDFILE="/var/run/$NAME.pid" SUBJECT="$NAME results" -TMP=`mktemp /tmp/$NAME.XXXXXXXX` || exit 1 +TMP=$(mktemp /tmp/$NAME.XXXXXXXX) || exit 1 PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" export PATH -# check PID file ("lock file") -if [ -e "$PIDFILE" ]; then - echo "Lockfile \"$PIDFILE\" already exists." - echo "Is an other instance still running?" - echo - echo -n "Aborted: "; date - echo - exit 4 -fi - exec >"$TMP" 2>&1 echo "$NAME Report" echo -echo " - Host: `hostname -f`" -echo " - User: `id -un`" +echo " - Host: $(hostname -f)" +echo " - User: $(id -un)" +echo +echo "Command:" +echo "$0" "$@" echo if echo "$DELIMITER" >>"$LOGFILE" 2>/dev/null; then @@ -62,12 +54,13 @@ fi case "$r" in 0) + SUBJECT="$SUBJECT - success" ;; *) SUBJECT="$SUBJECT - with ERRORS!" esac -cat "$TMP" | mail -s "$HOST: $SUBJECT" "$MAILTO" +mail -s "$HOST: $SUBJECT" "$MAILTO" <"$TMP" rm -f "$TMP" exit $r