alert_pushover.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # LinuxGSM alert_pushover.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Sends Pushover alert.
  6. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  7. fn_print_dots "Sending Pushover alert"
  8. # Different alerts are given different priorities and notification sounds.
  9. if [ "${alertsound}" == "1" ]; then
  10. alertsound=""
  11. alertpriority="0"
  12. elif [ "${alertsound}" == "2" ]; then
  13. # restarted.
  14. alertsound="siren"
  15. alertpriority="1"
  16. else
  17. alertsound=""
  18. alertpriority="0"
  19. fi
  20. 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)
  21. if [ -n "${pushoversend}" ]; then
  22. fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
  23. fn_script_log_fatal "Sending Pushover alert: ${pushoversend}"
  24. else
  25. fn_print_ok_nl "Sending Pushover alert"
  26. fn_script_log_pass "Sent Pushover alert"
  27. fi