plugin-gotify/entrypoint.sh

21 lines
578 B
Bash
Raw Normal View History

2022-01-10 12:33:06 +00:00
#!/bin/sh
2022-01-10 12:46:24 +00:00
2022-01-10 12:51:50 +00:00
if [ -z ${PLUGIN_GOTIFY_URL} ]; then
echo "PLUGIN_GOTIFY_URL is not set";
exit 1
fi
if [ -z ${PLUGIN_GOTIFY_TOKEN} ]; then
echo "PLUGIN_GOTIFY_TOKEN is not set";
exit 1
fi
2022-01-10 15:54:00 +00:00
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
2022-01-10 14:05:05 +00:00
fi
2022-01-10 15:54:00 +00:00
cat "$OUTPUT_FILE" | jq .