alert_pushbullet.sh 1.1 KB

12345678910111213141516171819202122232425262728293031
  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. local commandname="ALERT"
  7. local commandaction="Alert"
  8. local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. json=$(cat <<EOF
  10. {
  11. "channel_tag": "${channeltag}",
  12. "type": "note",
  13. "title": "${alertemoji} ${alertsubject} ${alertemoji}",
  14. "body": "Message\n${alertbody}\n\nGame\n${gamename}\n\nServer name\n${servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${ip}:${port}\n\nMore info\n${alerturl}"
  15. }
  16. EOF
  17. )
  18. fn_print_dots "Sending Pushbullet alert"
  19. sleep 0.5
  20. pushbulletsend=$(${curlpath} -sSL -u """${pushbullettoken}"":" -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.pushbullet.com/v2/pushes" | grep "error_code")
  21. if [ -n "${pushbulletsend}" ]; then
  22. fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"
  23. fn_script_log_fatal "Sending Pushbullet alert: ${pushbulletsend}"
  24. else
  25. fn_print_ok_nl "Sending Pushbullet alert"
  26. fn_script_log_pass "Sent Pushbullet alert"
  27. fi