Forked from jwalanta/OpenWrt detect new device and send text message.md
Last active
February 3, 2021 01:56
-
-
Save roadtripguy/b2ee7761c0f0f51700dd7640bb681bc9 to your computer and use it in GitHub Desktop.
Detect new network devices connecting to OpenWrt and send text message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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