2019-12-18 21:56:16 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SCRIPT=$1
|
|
|
|
|
|
|
|
shift
|
|
|
|
|
2020-01-29 04:00:04 +01:00
|
|
|
$SCRIPT "$@" 2>&1 | tee /tmp/backup.log
|
|
|
|
ERR=$?
|
2019-12-18 21:56:16 +01:00
|
|
|
|
2020-01-29 04:00:04 +01:00
|
|
|
OUTPUT=$(cat /tmp/backup.log)
|
|
|
|
rm /tmp/backup.log
|
|
|
|
|
|
|
|
if [ $ERR -ne 0 ]; then
|
2019-12-18 21:56:16 +01:00
|
|
|
MAILTO=$(cat "$HOME/.admin_mail")
|
|
|
|
echo "Sending error mail"
|
|
|
|
echo -e "An error occured during the execution of $SCRIPT.\n\n$OUTPUT" | mailx -s "$(hostname) $SCRIPT failure" "$MAILTO"
|
|
|
|
echo "Sent"
|
|
|
|
exit 1
|
|
|
|
fi
|