-
-
Save nhooyr/71d9b0ccdb3e8d3255bc to your computer and use it in GitHub Desktop.
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
#!/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 |
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
[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