Changed error system to array variable and updated quit to report them.
This commit is contained in:
parent
bc0e19b26f
commit
01f4a3dc0c
15
backup.sh
15
backup.sh
@ -34,16 +34,20 @@ function quit {
|
|||||||
"(code: ${warnCode}) --${normal}" >> "$logFile"
|
"(code: ${warnCode}) --${normal}" >> "$logFile"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ -z "$1" ]; then
|
if [ -z "${exitError}" ]; then
|
||||||
# exit cleanly
|
# exit cleanly
|
||||||
echo -e "\e[1;35m${stamp} -- ${scriptName} completed" \
|
echo -e "\e[1;35m${stamp} -- ${scriptName} completed" \
|
||||||
"--${normal}" >> "$logFile"
|
"--${normal}" >> "$logFile"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
# log error code and exit with said code
|
# list generated errors and explanations then exit script with code 2
|
||||||
echo -e "${err}${stamp} -- [ERROR] ${errorExplain[$1]}" \
|
echo -e "${err}${scriptName} generated the following errors:" \
|
||||||
"(code: $1) --$normal" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
exit "$1"
|
for errCode in "${exitError[@]}"; do
|
||||||
|
echo -e "${err}-- [ERROR] ${errorExplain[$errCode]}" \
|
||||||
|
"(code: ${errCode}) --$normal" >> "$logFile"
|
||||||
|
done
|
||||||
|
exit 2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,6 +173,7 @@ unset BORG_RSH
|
|||||||
unset BORG_REPO
|
unset BORG_REPO
|
||||||
unset BORG_PASSPHRASE
|
unset BORG_PASSPHRASE
|
||||||
unset BORG_REMOTE_PATH
|
unset BORG_REMOTE_PATH
|
||||||
|
exitError=()
|
||||||
errorExplain=()
|
errorExplain=()
|
||||||
exitWarn=()
|
exitWarn=()
|
||||||
warningExplain=()
|
warningExplain=()
|
||||||
|
Loading…
Reference in New Issue
Block a user