Browse Source
first working version, gotify does not like emojis
pull/3509/head
jamie
4 years ago
No known key found for this signature in database
GPG Key ID: 98D3272368C9138
1 changed files with
2 additions and
34 deletions
-
lgsm/functions/alert_gotify.sh
|
|
@ -6,43 +6,11 @@ |
|
|
|
|
|
|
|
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" |
|
|
|
|
|
|
|
if ! command -v jq > /dev/null; then |
|
|
|
fn_print_fail_nl "Sending Gotify alert: jq is missing." |
|
|
|
fn_script_log_fatal "Sending Gotify alert: jq is missing." |
|
|
|
fi |
|
|
|
|
|
|
|
json=$(cat <<EOF |
|
|
|
{ |
|
|
|
"alias": "LinuxGSM", |
|
|
|
"text": "*${alertemoji} ${alertsubject} ${alertemoji}* \n *${servername}* \n ${alertbody} \n More info: ${alerturl}", |
|
|
|
"attachments": [ |
|
|
|
{ |
|
|
|
"fields": [ |
|
|
|
{ |
|
|
|
"short": true, |
|
|
|
"title": "Game:", |
|
|
|
"value": "${gamename}" |
|
|
|
}, |
|
|
|
{ |
|
|
|
"short": true, |
|
|
|
"title": "Server IP:", |
|
|
|
"value": "${alertip}:${port}" |
|
|
|
}, |
|
|
|
{ |
|
|
|
"short": true, |
|
|
|
"title": "Hostname:", |
|
|
|
"value": "${HOSTNAME}" |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
EOF |
|
|
|
) |
|
|
|
content=(message="${alertsubject}, ${servername}, ${alertbody}. More info: ${alerturl}") |
|
|
|
|
|
|
|
fn_print_dots "Sending Gotify alert" |
|
|
|
|
|
|
|
gotifysend=$(curl --connect-timeout 10 -sSL -H "{X-Gotify-Key: ${gotifytoken}}" -X POST -d "$(echo -n "$json" | jq -c .)" "${gotifywebhook}") |
|
|
|
gotifysend=$(curl "$gotifywebhook"?token="$gotifytoken" -F "title=LinuxGSM" -F "$content" -F "priority=5") |
|
|
|
|
|
|
|
if [ -n "${gotifysend}" ]; then |
|
|
|
fn_print_ok_nl "Sending Gotify alert" |
|
|
|