Created
April 20, 2020 18:09
-
-
Save newhinton/a53541611f181863384652726ee049eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MSGIDAPPENDIX="appid" | |
TOKEN="apptoken" | |
DELTOKEN="clienttoken" | |
URL="url to gotify" | |
TITLE=$1 | |
MESSAGE=$2 | |
PRIO=$3 | |
APPENDIX=$4 | |
MSGIDAPPENDIX=$MSGIDAPPENDIX$APPENDIX | |
touch $MSGIDAPPENDIX.msg.txt | |
touch $MSGIDAPPENDIX.id.txt | |
MSG=$(<$MSGIDAPPENDIX.msg.txt) | |
ID=$(<$MSGIDAPPENDIX.id.txt) | |
if [ -z "$ID" ]; then | |
# if id is not set, simply create message | |
CURLMSG=$(curl -s "$URL/message?token=$TOKEN" -F "title=$TITLE" -F "message=$MESSAGE" -F "priority=$PRIO") | |
ID=$(echo $CURLMSG | jq -r '.id') | |
MSG=$(echo $CURLMSG | jq -r '.message') | |
echo $ID > $MSGIDAPPENDIX.id.txt | |
echo $MSG > $MSGIDAPPENDIX.msg.txt | |
exit | |
fi | |
# Delete the old message | |
curl -s "$URL/message/$ID" -X DELETE -H "X-Gotify-Key: $DELTOKEN" | |
NEWMSG="$MSG | |
$MESSAGE" | |
CURLMSG=$(curl -s "$URL/message?token=$TOKEN" -F "title=$TITLE" -F "message=$NEWMSG" -F "priority=$PRIO") | |
ID=$(echo $CURLMSG | jq -r '.id') | |
echo $ID > $MSGIDAPPENDIX.id.txt | |
echo $NEWMSG > $MSGIDAPPENDIX.msg.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment