alert_pushbullet.sh 1.2 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} ${alerttitle} ${alertemoji}",
  13. "body": "Server name\n${servername}\n\nTrigger Message\n${alerttriggermessage}\n\nGame\n${gamename}\n\nMap\n${alertmap}\n\nCurrent Players\n${alertplayers}\n\nVersion\n${alertversion}\n\nCountry\n${country}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore Info\n${alertmoreinfourl}"
  14. }
  15. EOF
  16. )
  17. fn_print_dots "Sending Pushbullet alert"
  18. pushbulletsend=$(curl --connect-timeout 10 -sSL -H "Access-Token: ${pushbullettoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "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