From: short <> Date: Tue, 24 Jul 2001 18:31:39 +0000 (+0000) Subject: Script for auto-update of "kratochvil.vellum.cz" DNS zone from UPC client X-Git-Tag: rh71~33 X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=commitdiff_plain;h=723b98f5494c23fe7bcf021ef4024887c24e4122;hp=c7fbc7aacba1ebfdbeba10553ebec18cb4031df7 Script for auto-update of "kratochvil.vellum.cz" DNS zone from UPC client --- diff --git a/bin/kratochvil.vellum.cz-update b/bin/kratochvil.vellum.cz-update new file mode 100755 index 0000000..c32a5b4 --- /dev/null +++ b/bin/kratochvil.vellum.cz-update @@ -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