alert_pushbullet.sh 1.0 KB

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # LinuxGSM alert_pushbullet.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Sends Pushbullet Messenger alert.
  6. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  7. json=$(cat <<EOF
  8. {
  9. "channel_tag": "${channeltag}",
  10. "type": "note",
  11. "title": "${alertemoji} ${alertsubject} ${alertemoji}",
  12. "body": "Server name\n${servername}\n\nMessage\n${alertbody}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}"
  13. }
  14. EOF
  15. )
  16. fn_print_dots "Sending Pushbullet alert"
  17. pushbulletsend=$(curl --connect-timeout 10 -sSL -u """${pushbullettoken}"":" -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.pushbullet.com/v2/pushes" | grep "error_code")
  18. if [ -n "${pushbulletsend}" ]; then
  19. fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"
  20. fn_script_log_fatal "Sending Pushbullet alert: ${pushbulletsend}"
  21. else
  22. fn_print_ok_nl "Sending Pushbullet alert"
  23. fn_script_log_pass "Sent Pushbullet alert"
  24. fi