alert_pushover.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. if [ -z "${alerturl}" ]; then
  22. pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
  23. else
  24. pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
  25. fi
  26. if [ -n "${pushoversend}" ]; then
  27. fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
  28. fn_script_log_fail "Sending Pushover alert: ${pushoversend}"
  29. else
  30. fn_print_ok_nl "Sending Pushover alert"
  31. fn_script_log_pass "Sent Pushover alert"
  32. fi