4
0

alert_gotify.sh 975 B

123456789101112131415161718192021222324252627282930
  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. module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. json=$(
  9. cat << EOF
  10. {
  11. "title": "${alertemoji} ${alertsubject} ${alertemoji}",
  12. "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}",
  13. "priority": 5
  14. }
  15. EOF
  16. )
  17. fn_print_dots "Sending Gotify alert"
  18. gotifysend=$(curl --connect-timeout 10 -sSL "${gotifywebhook}/message"?token="${gotifytoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)")
  19. if [ -n "${gotifysend}" ]; then
  20. fn_print_ok_nl "Sending Gotify alert"
  21. fn_script_log_pass "Sending Gotify alert"
  22. else
  23. fn_print_fail_nl "Sending Gotify alert: ${gotifysend}"
  24. fn_script_log_fatal "Sending Gotify alert: ${gotifysend}"
  25. fi