X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=dynamic-ip-update.sh;h=336aaf3583e16b42e527832d67ad1e414a45ac24;hb=0b6d44c7f3d567e0a26138509c8a24cb57c69b50;hp=a2da871b722f8b1f408ced0bed04aa71f39f0722;hpb=e893484a0470843582699dc41fe9d69388c63c02;p=distro-setup diff --git a/dynamic-ip-update.sh b/dynamic-ip-update.sh index a2da871..336aaf3 100755 --- a/dynamic-ip-update.sh +++ b/dynamic-ip-update.sh @@ -1,32 +1,47 @@ -#!/bin/bash -l - - -# note: in practice, I've not seen my ip address change under comcast -# for over a year. If the internet hadn't mislead me, I wouldn't have -# bothered. - - - - -# based on: https://www.namecheap.com/support/knowledgebase/article.aspx/36/11/how-do-i-start-using-dynamic-dns - -# go to advanced dns, enable the little slider checkbox for dynamic dns, -# add dnynamic dns records for @ and * (not sure * will work, but eh), -# with the initial ip you want. remove any other host records, for example -# the initial default ones. copy the dynamic dns password to /p/dynamic-ip-pass. - -# other articles I found usefull previously, but not the last time -# http://mwholt.blogspot.com/2013/09/how-to-set-up-dynamic-dns-in-5-minutes.html -# https://www.namecheap.com/support/knowledgebase/article.aspx/583/11/how-do-i-configure-ddclient - -ip=`curl -s4 echoip.com` -curl -sS "https://dynamicdns.park-your-domain.com/update?host=@&domain=$HOME_DOMAIN&password=$(cat /p/dynamic-ip-pass)&ip=$ip" > /dev/null +#!/bin/bash + +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR + + +cur="$(host -4 b8.nz iankelling.org | sed -rn 's/.*has address (.*)/\1/p;T;q')" +ip=$(curl -s4 https://iankelling.org/cgi/pubip) + +# note, a simpler way to do this would be to ssh and use +# "${SSH_CLIENT%% *} +# to update bind if needed. + +if [[ $cur != $ip ]]; then + nsupdate -k /p/c/machine_specific/li/filesystem/etc/bind/Kb8.nz.*.private <$f <> /etc/hosts -# EOF +# myunison -ob li +# ssh li conflink +# ssh li ser restart bind9