Skip to content

Instantly share code, notes, and snippets.

@Brandawg93
Created November 23, 2023 22:46
Show Gist options
  • Save Brandawg93/95b9a7908f5d16ece441e44f04d14e85 to your computer and use it in GitHub Desktop.
Save Brandawg93/95b9a7908f5d16ece441e44f04d14e85 to your computer and use it in GitHub Desktop.
Send new device notification to pushover.net
#!/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