Just a couple of ideas: check the exit status of any command inside the script and if the status is not 0 just
touch a file with a unique name (for example ${0}_abort, where $0 is expanded by the shell with the name of the script itself). Also embed all the code in a if condition like this:
Code:
#!/bin/bash
if [ ! -f /path/to/${0}_abort]
then
<the whole script code here>
fi
In this way, the code will be execute if and only if the file ${0}_abort does not exist, that is only if the previous run was successful. In case of failure and manual reset, don't forget to delete the ${0}_abort file to let the script run again the next time.
Moreover, be sure to redirect the standard error of each command to a file, then at the end of the script you can check if that file is not empty and send an e-mail to your personal address:
Code:
if [ $(stat -c %s /path/to/errorfile) -ne 0 ]
then
/usr/bin/sendmail your.address@domain.com <<-EOF
Subject: Error in script $0
$(cat /path/to/errorfile)
EOF
fi