Created
August 19, 2016 10:15
-
-
Save hongkongkiwi/ce42d13ad666053a77d333a779fc2ae3 to your computer and use it in GitHub Desktop.
DHCP MQTT Lease Publish on Asus Merlin router. Put the script wherever you want and put the dnsmasq.conf.add into /jffs/configs
This file contains 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 | |
if [ "$#" -ne 4 ]; then | |
echo "Illegal number of parameters" | |
exit 1 | |
fi | |
MQTT_CAFILE="/mnt/sda1/ssl/ca.crt" | |
MQTT_SERVER="<SERVER_HERE>" | |
MQTT_PORT="8883" | |
BASE_TOPIC="network/dhcp" | |
BIND_ADDR="192.168.250.1" | |
CLIENT_CERT="/mnt/sda1/ssl/client.crt" | |
CLIENT_KEY="/mnt/sda1/ssl/client.key" | |
MOSQUITTO="/opt/bin/mosquitto_pub" | |
op="${1:-op}" | |
mac="${2:-mac}" | |
ip="${3:-ip}" | |
hostname="${4}" | |
tstamp="`date '+%Y-%m-%d %H:%M:%S'`" | |
topic="${BASE_TOPIC}/${mac}" | |
payload="${op} ${ip} ${mac} ${tstamp} (${hostname})" | |
"${MOSQUITTO}" --quiet -A "${BIND_ADDR}" \ | |
-h "${MQTT_SERVER}" -p ${MQTT_PORT} \ | |
-t "${topic}" -m "${payload}" -r \ | |
--cafile "${MQTT_CAFILE}" --cert "${CLIENT_CERT}" --key "${CLIENT_KEY}" | |
exit $? |
This file contains 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
dhcp-script=/mnt/sda1/helpers/dhcp_lease_mqtt_publish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment