alert_pushbullet.sh 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # LinuxGSM alert_pushbullet.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Sends Pushbullet Messenger alert.
  7. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. json=$(cat <<EOF
  9. {
  10. "channel_tag": "${channeltag}",
  11. "type": "note",
  12. "title": "${alertemoji} ${alertsubject} ${alertemoji}",
  13. "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}"
  14. }
  15. EOF
  16. )
  17. fn_print_dots "Sending Pushbullet alert"
  18. 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")
  19. if [ -n "${pushbulletsend}" ]; then
  20. fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"
  21. fn_script_log_fatal "Sending Pushbullet alert: ${pushbulletsend}"
  22. else
  23. fn_print_ok_nl "Sending Pushbullet alert"
  24. fn_script_log_pass "Sent Pushbullet alert"
  25. fi