X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=nsd-update;h=fb5f6d2395b9281fd920d360ebfd1a1f2958a0cd;hb=f8f4b8fe0e71f39d211e2f6ff7d692a14d2173d8;hp=da701bec9d276da609047b6e0dc6c6ad6ec07bfa;hpb=de9baa8d38be22402570535d68f731a499c9b857;p=shutils.git diff --git a/nsd-update b/nsd-update old mode 100644 new mode 100755 index da701be..fb5f6d2 --- a/nsd-update +++ b/nsd-update @@ -1,2 +1,31 @@ #!/bin/sh -su shuber -c "ssh sthu.org \"echo $pubip > /tmp/euklid.ip\"" + +watchfile=/tmp/$(hostname).ip + +while true; do + case $1 in + -h|--help) + echo "$0 [--watchfile=$watchfile] " + exit 0 + ;; + --watchfile) + watchfile=$2 + shift + ;; + *) break ;; + esac + shift +done + +server=$1 +pubip=$(/usr/local/bin/printPublicIp) + +if ! echo "$pubip" | egrep -q "^([0-9]+\\.)+[0-9]+$" ; then + echo "Wrong IP address format" + exit 1 +fi + +echo "Notify $server that $(hostname) has address ${pubip}." + +. $HOME/.profile-sshagent +ssh $server "echo $pubip > /tmp/euklid.ip"