dhcp-script=/etc/detect_new_device.sh
- https://wiki.openwrt.org/doc/howto/smtp.client
- https://fixmynix.com/send-mail-command-line-linux-openwrt/
- http://lifehacker.com/5506326/how-can-i-send-an-email-via-text-message
#!/bin/sh
# script to detect new dhcp lease
if [ "$1" == "add" ]; then
echo "New device on `uci get system.@system[0].hostname`.`uci get dhcp.@dnsmasq[0].domain` $* `date`" | tee -a /tmp/dhcpmasq.log | sed s/:/%3A/g | sendmail [email protected]
fi
When a new device is added, dnsmasq calls detect_new_device.sh with arguments add mac_addr ip_addr devicename. We check if the device is new (if the dhcp lease hasn't expired, it calls with old), then logs and emails (which eventually is a text message) the information.
My own version, using mstmp
/root/detect_new_device.shTEST