alert_gotify.sh 973 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # LinuxGSM alert_gotify.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Sends Gotify alert.
  7. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. json=$(cat <<EOF
  9. {
  10. "title": "${alertemoji} ${alertsubject} ${alertemoji}",
  11. "message": "Server name\n${servername}\n\nMessage\n${alertbody}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}",
  12. "priority": 5
  13. }
  14. EOF
  15. )
  16. fn_print_dots "Sending Gotify alert"
  17. gotifysend=$(curl --connect-timeout 10 -sSL "${gotifywebhook}/message"?token="${gotifytoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)")
  18. if [ -n "${gotifysend}" ]; then
  19. fn_print_ok_nl "Sending Gotify alert"
  20. fn_script_log_pass "Sending Gotify alert"
  21. else
  22. fn_print_fail_nl "Sending Gotify alert: ${gotifysend}"
  23. fn_script_log_fatal "Sending Gotify alert: ${gotifysend}"
  24. fi