remaster/src/func/on_exit

35 lines
862 B
Plaintext
Raw Normal View History

#!/bin/bash
#remaster lib
2018-05-07 00:56:46 +00:00
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }
#on_exit [error_level]
function on_exit() {
#send log and errorlevel[success/errorr xy]
if [ "$1" != "0" ]; then
log_mail_subject="$log_mail_subject [ERROR]"
else
log_mail_subject="$log_mail_subject [Success]"
fi
#Mail Body:
for mail_aim in `echo "$log_mail_aim" | tr "," " "`; do
{
echo "$log_mail_subject"
echo $'####################################################################################\n\n'
cat "$log_file"
} | sendemail -s "$log_mail_smtp" -f "$log_mail_source" -t "$mail_aim" -u "$log_mail_subject" -o tls=no
done
[ "$1" != "0" ] && {
chroot_umount$distro "$chroot_path" 2> /dev/null
workspace_erase "$iso_extr_dir/" "$chroot_path/" 2> /dev/null
}
exit $1
}
2018-05-10 15:13:19 +00:00
2018-05-10 22:04:02 +00:00
#this func is standalone executable
2018-05-10 15:13:19 +00:00
[ -n "$1" ] && {
2018-05-10 22:04:02 +00:00
on_exit $@
2018-05-10 15:13:19 +00:00
}