From 6b744805fbf6540b156a2f2d9e836fdfa7f802bd Mon Sep 17 00:00:00 2001 From: Stefano Taillefert Date: Sun, 7 Apr 2024 17:27:36 +0200 Subject: [PATCH] Fix string parsing --- shepherd | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/shepherd b/shepherd index 4bc9e54..3965abd 100755 --- a/shepherd +++ b/shepherd @@ -49,12 +49,8 @@ authenticate_to_registries() { send_notification() { if [[ "$apprise_sidecar_url" != "" ]]; then - status=$(curl -s -X POST -H "Content-Type: application/json" --data "{\"title\": \"$1\", \"body\": \"$2\", \"notify_type\": \"$3\"}" "$apprise_sidecar_url") - if [[ $status = 0 ]]; then - logger "Sent notification" - else - logger "Failed sending notification!" - fi + status=$(curl --no-progress-meter -X POST -H "Content-Type: application/json" --data "{\"title\": \"$1\", \"body\": \"$2\", \"notify_type\": \"$3\"}" "$apprise_sidecar_url") + logger "Sending notification: $status" fi } @@ -108,7 +104,7 @@ update_services() { title="[Shepherd] Error updating service $name" body="$(date) Service $name Image $image does not exist or it is not available" - send_notification $title $body "failure" + send_notification "$title" "$body" "failure" else logger "Trying to update service $name with image $image" "true" @@ -129,7 +125,7 @@ update_services() { title="[Shepherd] Service $name update failed on $hostname" body="$(date) Service $name failed to update to $(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')" - send_notification $title $body "failure" + send_notification "$title" "$body" "failure" continue # continue with next service fi @@ -144,7 +140,7 @@ update_services() { title="[Shepherd] Service $name updated on $hostname" body="$(date) Service $name was updated from $previous_image to $current_image" - send_notification $title $body "success" + send_notification "$title" "$body" "success" if [[ "$image_autoclean_limit" != "" ]]; then logger "Cleaning up old docker images, leaving last $image_autoclean_limit"