Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save roadtripguy/b2ee7761c0f0f51700dd7640bb681bc9 to your computer and use it in GitHub Desktop.

Select an option

Save roadtripguy/b2ee7761c0f0f51700dd7640bb681bc9 to your computer and use it in GitHub Desktop.
Detect new network devices connecting to OpenWrt and send text message
#!/bin/sh
# script to detect new dhcp lease
# this will be called by dnsmasq everytime a new device is connected
# with the following arguments
# $1 = add | old
# $2 = mac address
# $3 = ip address
# $4 = device name
known_mac_addr="/etc/known_mac_addr"
# check if the mac is in known devices list
grep -q "$2" "$known_mac_addr"
unknown_mac_addr=$?
if [ "$1" == "add" ] && [ "$unknown_mac_addr" -ne 0 ]; then
# send to IFTTT
curl -d "value1=$2&value2=$3&value3=$4" -X POST [INSERT URL FROM IFTTT]
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment