various
parent
1b9994d09d
commit
93d123d8e8
|
@ -127,22 +127,22 @@ function invoke_script() {
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
exec 3>&1
|
exec 3>&1
|
||||||
|
|
||||||
script_error_log="$(create_tmp_file)"
|
script_error_log_path="$(create_tmp_file)"
|
||||||
script_output=$("$backup_scripts_dir/$backup_script_filename" 2>$script_error_log | tee /dev/fd/3)
|
script_output=$("$backup_scripts_dir/$backup_script_filename" 2>$script_error_log_path | tee /dev/fd/3)
|
||||||
|
script_result="$?"
|
||||||
|
script_log_path="$(create_log "$script_output")"
|
||||||
|
|
||||||
if [[ -f "$script_error_log" ]]; then
|
if [[ -f "$script_error_log_path" ]]; then
|
||||||
cat "$script_error_log"
|
cat "$script_error_log_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$?" == 0 ]]; then
|
if [[ "$script_result" == 0 ]]; then
|
||||||
trigger_notify "success" "Backup script succeeded: $backup_script_name" "..."
|
trigger_notify "success" "Backup script succeeded: $backup_script_name" "$script_log_path"
|
||||||
else
|
else
|
||||||
trigger_notify "error" "Backup script failed: $backup_script_name" "$(cat "$script_error_log")"
|
trigger_notify "error" "Backup script failed: $backup_script_name" "$(cat "$script_error_log_path")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$script_error_log"
|
rm -f "$script_error_log_path"
|
||||||
|
|
||||||
#rm -f "$script_error_log"
|
|
||||||
|
|
||||||
set +o pipefail
|
set +o pipefail
|
||||||
exec 3>&-
|
exec 3>&-
|
||||||
|
@ -151,10 +151,14 @@ function invoke_script() {
|
||||||
function trigger_notify() {
|
function trigger_notify() {
|
||||||
level="$1"
|
level="$1"
|
||||||
title="$2"
|
title="$2"
|
||||||
output="$(echo "$3" | sed -r "s/\x1B\[[0-9;]*[JKmsu]//g")"
|
message="$(echo "$3" | sed -r "s/\x1B\[[0-9;]*[JKmsu]//g")"
|
||||||
|
log_path="$4"
|
||||||
notify_prog="/usr/local/bin/sh.zio.notify"
|
notify_prog="/usr/local/bin/sh.zio.notify"
|
||||||
|
|
||||||
log_path="$(create_log "$output")"
|
if [[ $log_path == "" ]]; then
|
||||||
|
log_path="$message"
|
||||||
|
message=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! -f "$notify_prog" ]]; then
|
if [[ ! -f "$notify_prog" ]]; then
|
||||||
say warning "'$notify_prog' not found. Not sending notification"
|
say warning "'$notify_prog' not found. Not sending notification"
|
||||||
|
@ -162,9 +166,8 @@ function trigger_notify() {
|
||||||
"$notify_prog" \
|
"$notify_prog" \
|
||||||
--file "$log_path" \
|
--file "$log_path" \
|
||||||
--level "$level" \
|
--level "$level" \
|
||||||
|
--message '```\\n'"${message//$'\n'/'\\n'}"'\\n```' \
|
||||||
--title "$title"
|
--title "$title"
|
||||||
|
|
||||||
#--message '```\\n'"${output//$'\n'/'\\n'}"'\\n```' \
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue