email log results & remove failed #85 & #86

This commit is contained in:
Clinton Hall 2013-03-10 17:16:43 -07:00
commit 3231db90df

View file

@ -173,7 +173,21 @@ replaceVarBy() {
do_exit() { do_exit() {
if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: Executing function 'do_exit' with argument $1" ; fi if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: Executing function 'do_exit' with argument $1" ; fi
nzbStatus=0 nzbStatus=0
if [ "$1" -ne "$POSTPROCESS_SUCCESS" ]; then nzbStatus=1 ; fi if [ "$1" -ne "$POSTPROCESS_SUCCESS" ]; then
if [ "$Delete_Failed" = "yes" ]; then
rm * >/dev/null 2>&1
cd ..
rmdir $NZBPP_DIRECTORY
else
mkdir $Failed_Directory
mv * $Failed_Directory >/dev/null 2>&1
cd ..
rmdir $NZBPP_DIRECTORY
NZBPP_DIRECTORY=$Failed_Directory
cd $NZBPP_DIRECTORY
fi
nzbStatus=1
fi
script=none script=none
nzbToMedia $nzbStatus nzbToMedia $nzbStatus
echo "[DETAIL] after calling nzbToMedia" echo "[DETAIL] after calling nzbToMedia"
@ -193,6 +207,10 @@ do_exit() {
Email_Subject="${REPLACEDRESULT}" Email_Subject="${REPLACEDRESULT}"
replaceVarBy "${Email_Message}" "<status>" "completed" replaceVarBy "${Email_Message}" "<status>" "completed"
Email_Message="${REPLACEDRESULT}" Email_Message="${REPLACEDRESULT}"
if [ "${Add_Log}" = "yes" ]; then
Email_Message=$Email_Message"\nLog Result\n"
while read line; do Email_Message=$Email_Message"$line\n"; done < tmp.log
fi
$sendEmail -f "$Email_From" -t "$Email_To" -s "$Email_Server" $User -u "$Email_Subject" -m "$Email_Message" $sendEmail -f "$Email_From" -t "$Email_To" -s "$Email_Server" $User -u "$Email_Subject" -m "$Email_Message"
fi; done fi; done
for item in $Email_failed; do for item in $Email_failed; do
@ -203,13 +221,17 @@ do_exit() {
Email_Subject="${REPLACEDRESULT}" Email_Subject="${REPLACEDRESULT}"
replaceVarBy "${Email_Message}" "<status>" "failed" replaceVarBy "${Email_Message}" "<status>" "failed"
Email_Message="${REPLACEDRESULT}" Email_Message="${REPLACEDRESULT}"
if [ "${Add_Log}" = "yes" ]; then
Email_Message=$Email_Message"\nLog Result\n"
while read line; do Email_Message=$Email_Message"$line\n"; done < tmp.log
fi
$sendEmail -f "$Email_From" -t "$Email_To" -s "$Email_Server" $User -u "$Email_Subject" -m "$Email_Message" $sendEmail -f "$Email_From" -t "$Email_To" -s "$Email_Server" $User -u "$Email_Subject" -m "$Email_Message"
fi; done fi; done
exit $1 exit $1
} }
# the main routine. ## not indented to ensure easy compare to original nzbget script.
main() {
# Check if the script is called from nzbget # Check if the script is called from nzbget
if [ "$NZBPP_DIRECTORY" = "" -o "$NZBOP_CONFIGFILE" = "" ]; then if [ "$NZBPP_DIRECTORY" = "" -o "$NZBOP_CONFIGFILE" = "" ]; then
echo "*** NZBGet post-process script ***" echo "*** NZBGet post-process script ***"
@ -500,3 +522,7 @@ fi
# All OK, requesting cleaning up of download queue # All OK, requesting cleaning up of download queue
do_exit $POSTPROCESS_SUCCESS do_exit $POSTPROCESS_SUCCESS
}
#call the main routine with output to stdout and tmp.log (should over-write on each call)
main | tee tmp.log