alert_ifttt.sh 965 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # LinuxGSM alert_ifttt.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Sends IFTTT alert.
  6. local modulename="ALERT"
  7. local commandaction="Alert"
  8. local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
  9. json=$(cat <<EOF
  10. {
  11. "value1": "${selfname}",
  12. "value2": "${alertsubject}",
  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 -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
  19. if [ "${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