From f8f4b8fe0e71f39d211e2f6ff7d692a14d2173d8 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Mon, 29 Oct 2012 11:45:55 +0100 Subject: [PATCH] nsd-update: make a usable script out of it --- nsd-update | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) mode change 100644 => 100755 nsd-update 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" -- 2.39.5