alert_pushover.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  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 commandname="ALERT"
  7. local commandaction="Alert"
  8. local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. fn_print_dots "Sending Pushover alert"
  10. sleep 0.5
  11. # Different alerts are given different priorities and notification sounds
  12. if [ "${alertsound}" == "1" ]; then
  13. alertsound=""
  14. alertpriority="0"
  15. elif [ "${alertsound}" == "2" ]; then
  16. # restarted
  17. alertsound="siren"
  18. alertpriority="1"
  19. else
  20. alertsound=""
  21. alertpriority="0"
  22. fi
  23. pushoversend=$(${curlpath} -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/${ip}:${port}'>${ip}:${port}</a><br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a>" "https://api.pushover.net/1/messages.json" | grep errors)
  24. if [ -n "${pushoversend}" ]; then
  25. fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
  26. fn_script_log_fatal "Sending Pushover alert: ${pushoversend}"
  27. else
  28. fn_print_ok_nl "Sending Pushover alert"
  29. fn_script_log_pass "Sent Pushover alert"
  30. fi