From: Stefan Huber Date: Mon, 29 Oct 2012 10:45:55 +0000 (+0100) Subject: nsd-update: make a usable script out of it X-Git-Url: https://git.sthu.org/?p=shutils.git;a=commitdiff_plain;h=f8f4b8fe0e71f39d211e2f6ff7d692a14d2173d8 nsd-update: make a usable script out of it --- 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"