Added quit function
This commit is contained in:
parent
dc48cb1257
commit
4eee202c5e
17
backup.sh
17
backup.sh
@ -21,6 +21,23 @@ function scriptHelp {
|
|||||||
quit 98
|
quit 98
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### quit -- exit the script after logging any errors, warnings, etc. and
|
||||||
|
### cleaning up as necessary
|
||||||
|
function quit {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
# exit cleanly
|
||||||
|
echo -e "${bold}${green}${stamp} -- [SUCCESS] Script completed" \
|
||||||
|
"--$normal"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
# log error code and exit with said code
|
||||||
|
echo -e "${bold}${red}${stamp} -- [ERROR] Script exited with code $1" \
|
||||||
|
" --$normal"
|
||||||
|
echo -e "${red}${errorExplain[$1]}$normal"
|
||||||
|
exit "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
### End of Functions ###
|
### End of Functions ###
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user