alert_pushbullet.sh 1.1 KB

123456789101112131415161718192021222324252627282930
  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${alertip}:${port}\n\nMore info\n${alerturl}"
  15. }
  16. EOF
  17. )
  18. fn_print_dots "Sending Pushbullet alert"
  19. pushbulletsend=$(${curlpath} -sSL -u """${pushbullettoken}"":" -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.pushbullet.com/v2/pushes" | grep "error_code")
  20. if [ -n "${pushbulletsend}" ]; then
  21. fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"
  22. fn_script_log_fatal "Sending Pushbullet alert: ${pushbulletsend}"
  23. else
  24. fn_print_ok_nl "Sending Pushbullet alert"
  25. fn_script_log_pass "Sent Pushbullet alert"
  26. fi