]> git.sthu.org Git - shutils.git/commitdiff
nsd-update: make a usable script out of it
authorStefan Huber <shuber2@gmx.at>
Mon, 29 Oct 2012 10:45:55 +0000 (11:45 +0100)
committerStefan Huber <shuber2@gmx.at>
Mon, 29 Oct 2012 10:45:55 +0000 (11:45 +0100)
nsd-update [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index da701be..fb5f6d2
@@ -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] <server>"
+                        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"