Created
November 23, 2023 22:46
-
-
Save Brandawg93/95b9a7908f5d16ece441e44f04d14e85 to your computer and use it in GitHub Desktop.
Send new device notification to pushover.net
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 | |
cat << "EOF" > /etc/hotplug.d/dhcp/90-newdev | |
[ "$ACTION" == "add" ] || exit 0 | |
# [ "$ACTION" == "add" -o "$ACTION" == "update" ] || exit 0 | |
known_macs="/etc/known_macs" | |
user_key="your-user-key" | |
api_key="your-api-key" | |
if ! /bin/grep -iq "$MACADDR" "$known_macs"; then | |
msg="New device detected: | |
MAC: $MACADDR | |
IP: $IPADDR | |
Hostname: $HOSTNAME" | |
echo "$MACADDR $IPADDR $HOSTNAME" >> /etc/known_macs | |
curl -s \ | |
--form-string "token=$api_key" \ | |
--form-string "user=$user_key" \ | |
--form-string "title=New Device" \ | |
--form-string "message=$msg" \ | |
https://api.pushover.net/1/messages.json | |
fi | |
exit 0 | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment