alert_ifttt.sh 985 B

123456789101112131415161718192021222324252627282930
  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 commandname="ALERT"
  7. local commandaction="Alert"
  8. local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. json=$(cat <<EOF
  10. {
  11. "value1": "${servicename}",
  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${ip}:${port}\n\nMore info\n${alerturl}"
  14. }
  15. EOF
  16. )
  17. fn_print_dots "Sending IFTTT alert"
  18. sleep 0.5
  19. iftttsend=$(${curlpath} -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
  20. if [ -n "${iftttsend}" ]; then
  21. fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}"
  22. fn_script_log_fatal "Sending IFTTT alert: ${pushbulletsend}"
  23. else
  24. fn_print_ok_nl "Sending IFTTT alert"
  25. fn_script_log_pass "Sent IFTTT alert"
  26. fi