alert_ifttt.sh 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # LinuxGSM alert_ifttt.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Sends IFTTT alert.
  7. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. json=$(
  9. cat << EOF
  10. {
  11. "value1": "${selfname}",
  12. "value2": "${alertemoji} ${alertsubject} ${alertemoji}",
  13. "value3": "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}"
  14. }
  15. EOF
  16. )
  17. fn_print_dots "Sending IFTTT alert"
  18. iftttsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
  19. if [ -n "${iftttsend}" ]; then
  20. fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}"
  21. fn_script_log_fatal "Sending IFTTT alert: ${pushbulletsend}"
  22. else
  23. fn_print_ok_nl "Sending IFTTT alert"
  24. fn_script_log_pass "Sent IFTTT alert"
  25. fi