various
This commit is contained in:
parent
2948a24fe8
commit
d218f3b102
3 changed files with 48 additions and 23 deletions
|
@ -127,14 +127,17 @@ function invoke_script() {
|
|||
set -o pipefail
|
||||
exec 3>&1
|
||||
|
||||
script_output=$("$backup_scripts_dir/$backup_script_filename" 2>&1 | tee /dev/fd/3)
|
||||
script_error_log="$(create_tmp_file)"
|
||||
script_output=$("$backup_scripts_dir/$backup_script_filename" 2>$script_error_log | tee /dev/fd/3)
|
||||
|
||||
if [[ "$?" == 0 ]]; then
|
||||
trigger_notify "success" "Backup script succeeded: $backup_script_name" "$script_output"
|
||||
trigger_notify "success" "Backup script succeeded: $backup_script_name" "..."
|
||||
else
|
||||
trigger_notify "error" "Backup script failed: $backup_script_name" "$script_output"
|
||||
trigger_notify "error" "Backup script failed: $backup_script_name" "$(cat "$script_error_log")"
|
||||
fi
|
||||
|
||||
rm -f"$script_error_log"
|
||||
|
||||
set +o pipefail
|
||||
exec 3>&-
|
||||
}
|
||||
|
@ -145,13 +148,17 @@ function trigger_notify() {
|
|||
output="$(echo "$3" | sed -r "s/\x1B\[[0-9;]*[JKmsu]//g")"
|
||||
notify_prog="/usr/local/bin/sh.zio.notify"
|
||||
|
||||
log_path="$(create_log "$output")"
|
||||
|
||||
if [[ ! -f "$notify_prog" ]]; then
|
||||
say warning "'$notify_prog' not found. Not sending notification"
|
||||
else
|
||||
"$notify_prog" \
|
||||
--file "$log_path" \
|
||||
--level "$level" \
|
||||
--message '```\\n'"${output//$'\n'/'\\n'}"'\\n```' \
|
||||
--title "$title"
|
||||
|
||||
#--message '```\\n'"${output//$'\n'/'\\n'}"'\\n```' \
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue