Skip to content

Instantly share code, notes, and snippets.

@m-p-3
Last active February 26, 2020 14:46
Show Gist options
  • Save m-p-3/2444020521a83a56ab3a6784053d4528 to your computer and use it in GitHub Desktop.
Save m-p-3/2444020521a83a56ab3a6784053d4528 to your computer and use it in GitHub Desktop.
Send hostname and IP address of a system through IFTTT as a notification when the system is up (Debian/Ubuntu/Raspbian)

Instructions

Trigger: Webhooks, Receive a web request
Event Name: ip_addr

Action: Notifications, Send a rich notification from the IFTTT app
Title: {{Value1}}
Message: {{Value2}}
Link URL:
Image URL:

Press Create Action
Applet title: If webhooks "ip_addr" is received, then send a rich notification (value1=hostname, value2=hostname -I)

You can then create the script file (see ifttt_ipaddr.sh), I personally create it in /usr/local/scripts
And proceed with the SystemD service file (in /etc/systemd/service) to make it run at boot when the network service is ready (see ifttt_ipaddr.service).
Once the service file is created, you can enable it using the command sudo systemctl enable ifttt_ipaddr.service

[Unit]
Description=IFTTT ipaddr Webhook
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/local/scripts/ifttt_ipaddr.sh
[Install]
WantedBy=multi-user.target
#!/bin/bash
IFTTT_KEY=""
#You can find your API key at https://ifttt.com/maker_webhooks/settings (ie: XXXXXxXXXXxXXx-XXxXXX)
IFTTT_TRIGGER="ip_addr"
IFTTT_VALUE1=`hostname`
IFTTT_VALUE2=`hostname -I`
/usr/bin/curl -H "Content-Type: application/json" -X POST -d '{"value1":"'"${IFTTT_VALUE1}"'","value2":"'"${IFTTT_VALUE2}"'"}' https://maker.ifttt.com/trigger/$IFTTT_TRIGGER/with/key/$IFTTT_KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment