Skip to content

Instantly share code, notes, and snippets.

@randName
Created May 25, 2018 14:18
Show Gist options
  • Save randName/cf2f924098af19e8d943ddcbca5a26a2 to your computer and use it in GitHub Desktop.
Save randName/cf2f924098af19e8d943ddcbca5a26a2 to your computer and use it in GitHub Desktop.
shell script for IFTTT Webhooks
#!/bin/sh
[ -z "$@" ] && echo "Usage: $( basename $0 ) MESSAGE" && exit 1
[ ! -f ~/.ifttt ] && echo "~/.ifttt not found" && exit 1
. ~/.ifttt
[ -z "$IFTTT_KEY" ] && echo "Please set your IFTTT key in ~/.ifttt" && exit 1
if [ -z "$EVENT" ]; then
EVENT="script"
fi
URL="https://maker.ifttt.com/trigger/$EVENT/with/key/$IFTTT_KEY"
DATA='{"value1":"'"$(hostname)"'","value2":"'"$(hostname -I)"'","value3":"'"$@"'"}'
RTN="$(curl -s -X POST -H "Content-Type: application/json" -d "$DATA" "$URL")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment