-
-
Save mz0/ce3130b5aff5a476c1e85a79b50f53c6 to your computer and use it in GitHub Desktop.
NetwokManager HE-dDNS hook
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 | |
#/etc/NetworkManager/dispatcher.d/ddns | |
arg1=$1 | |
arg2=$2 | |
DUMPS="/tmp/my Dispatch" | |
IF=enp5s0 | |
name=host1.example.net | |
. /home/mz0/.ssh/ddns-key # key=6KigGftdvYqEvTW | |
update() { | |
updateURL="https://dyn.dns.he.net/nic/update?hostname=${name}&password=${key}&myip=${1}" | |
curl -s -o /tmp/ddns-update.re -X GET $updateURL | |
cat /tmp/ddns-update.re >> $2 # TODO log file timestamp | |
echo >> ${2} | |
} | |
dumpvars() { | |
echo "arg1=$arg1" >> ${1} | |
echo "arg2=$arg2" >> ${1} | |
/usr/bin/env >> "$1" | |
} | |
echo '=========================================' >> $DUMPS | |
echo "$0 log" >> $DUMPS | |
echo -n "start " >> $DUMPS | |
date >> $DUMPS | |
dumpvars "$DUMPS" | |
if [ $DEVICE_IFACE = $IF ] && [ -n $DHCP4_IP_ADDRESS ] \ | |
&& [ NM_DISPATCHER_ACTION != dhcp6-change ] | |
then | |
# takes ca. 2 seconds; TODO spaw a sub-shell to not delay NM | |
update $DHCP4_IP_ADDRESS "$DUMPS" | |
fi | |
echo -n "finish " >> $DUMPS | |
date >> $DUMPS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO debug path with space
https://developer.gnome.org/NetworkManager/stable/NetworkManager.html