alert_pushover.sh 1.4 KB

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