Script for auto-update of "kratochvil.vellum.cz" DNS zone from UPC client
authorshort <>
Tue, 24 Jul 2001 18:31:39 +0000 (18:31 +0000)
committershort <>
Tue, 24 Jul 2001 18:31:39 +0000 (18:31 +0000)
bin/kratochvil.vellum.cz-update [new file with mode: 0755]

diff --git a/bin/kratochvil.vellum.cz-update b/bin/kratochvil.vellum.cz-update
new file mode 100755 (executable)
index 0000000..c32a5b4
--- /dev/null
@@ -0,0 +1,25 @@
+#! /bin/sh
+
+lockfile="/home/short/bin/kratochvil.vellum.cz-update.lock"
+kratochvil_IP="`echo "$SSH_CLIENT"|cut -d ' ' -f 1`"
+kratochvil_IP_back="`echo "$kratochvil_IP"|sed 's/\./\\\\./g'`"
+named_dir="/etc/named"
+cf_file="$named_dir/cf/kratochvil.vellum.cz"
+
+if [ -f "$lockfile" ];then lockmsg=true;else lockmsg=false;fi
+if $lockmsg;then echo -n "$0: Locking \"$lockfile\"...";fi
+lockfile -l 60 "$lockfile"
+trap 'rm -f "$lockfile"' EXIT
+if $lockmsg;then echo " done.";fi
+
+if grep -q '^  `'"$kratochvil_IP_back'"'$' "$cf_file";then
+       echo "$0: Nothing to do, $kratochvil_IP already present."
+       exit 0
+       fi
+
+echo "$0: Updating new IP $kratochvil_IP..."
+echo -e '%s#\(^  `\)[0-9.]*\('"'"'\)$#\\1'"$kratochvil_IP"'\\2#\nw'|ed -s "$cf_file"
+make -C "$named_dir" --assume-new="ver/.version"
+/home/short/secure/ndc-reload-short
+echo "$0: Update done."
+exit 0