From f0d2746b7134a934eb5d8f39d21c0be980f7cb76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Mon, 10 Jan 2022 16:54:00 +0100 Subject: [PATCH] Improve output --- entrypoint.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5987ee3..e37041a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,4 @@ #!/bin/sh -# TODO: Verify that variables are set properly if [ -z ${PLUGIN_GOTIFY_URL} ]; then echo "PLUGIN_GOTIFY_URL is not set"; @@ -11,10 +10,12 @@ if [ -z ${PLUGIN_GOTIFY_TOKEN} ]; then exit 1 fi -res=$(curl -s "${PLUGIN_GOTIFY_URL}/message?token=${PLUGIN_GOTIFY_TOKEN}" -F "title=${PLUGIN_TITLE}" -F "message=${PLUGIN_MESSAGE}" -F "priority=5") -if [ "$?" -ne "0" ]; then - echo "Failed to send message" - exit "$?" +OUTPUT_FILE=$(mktemp) +STATUS_CODE=$(curl -s --output "$OUTPUT_FILE" --write-out "%{http_code}" "${PLUGIN_GOTIFY_URL}/message?token=${PLUGIN_GOTIFY_TOKEN}" -F "title=${PLUGIN_TITLE}" -F "message=${PLUGIN_MESSAGE}" -F "priority=5") +if [ "$STATUS_CODE" -ne "200" ]; then + echo "Failed to send message:" + cat "$OUTPUT_FILE" | jq . + exit 1 fi -echo "$res" | jq . \ No newline at end of file +cat "$OUTPUT_FILE" | jq . \ No newline at end of file