Skip to content

Instantly share code, notes, and snippets.

@nhooyr
Created January 6, 2016 11:50
Show Gist options
  • Save nhooyr/71d9b0ccdb3e8d3255bc to your computer and use it in GitHub Desktop.
Save nhooyr/71d9b0ccdb3e8d3255bc to your computer and use it in GitHub Desktop.
#!/usr/local/bin/zsh
set -e
ip=$(ip addr show wlan0 | ag -o 'inet \K\d+\.\d+\.\d+\.\d+')
TRAPZERR() {
print "failure, ip was $ip"
}
if [[ $ip == "192.168.0.11" ]]; then
ip=$(/usr/local/etc/dotfiles/bin/publicIP)
fi
print "before read"
if [[ -f ~/scratch/ip ]] && [[ $(cat ~/scratch/ip) == $ip ]]; then
print "No need to update\n"
else
ssh ezekiel "psql -U postgres -d powerdns -c \"UPDATE records SET content = '$ip' where name = 'nepu.aubble.com';\""
print -n $ip > ~/scratch/ip
fi
[Unit]
Description=Dynamic dns update
Requires=network-online.target
After=network-online.target TunneLS.service
[Service]
User=nhooyr
ExecStart=/usr/local/bin/ddns
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment