4
0

alert_pushover.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # LinuxGSM alert_pushover.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Sends Pushover alert.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. fn_print_dots "Sending Pushover alert"
  9. # Different alerts are given different priorities and notification sounds.
  10. if [ "${alertsound}" == "1" ]; then
  11. alertsound=""
  12. alertpriority="0"
  13. elif [ "${alertsound}" == "2" ]; then
  14. # restarted.
  15. alertsound="siren"
  16. alertpriority="1"
  17. else
  18. alertsound=""
  19. alertpriority="0"
  20. fi
  21. pushoversend=$(curl --connect-timeout 10 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alertsubject} ${alertemoji}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Message</b><br>${alertbody}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br><a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a><br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a>" "https://api.pushover.net/1/messages.json" | grep errors)
  22. if [ -n "${pushoversend}" ]; then
  23. fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
  24. fn_script_log_fatal "Sending Pushover alert: ${pushoversend}"
  25. else
  26. fn_print_ok_nl "Sending Pushover alert"
  27. fn_script_log_pass "Sent Pushover alert"
  28. fi