X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=nsd%2Fnsd-dynipwatch;h=068702bbffd133a27dc9dde6f7b350ecca317eb7;hb=58dbef0f4c9b483070f21df665e86ed63f7388ad;hp=bfdb8407bad273f34f3cf78b7d3e5038be28a69d;hpb=7bc50756b64ad2e0ecf4ff343b34cab1a453c5e4;p=shutils.git diff --git a/nsd/nsd-dynipwatch b/nsd/nsd-dynipwatch index bfdb840..068702b 100755 --- a/nsd/nsd-dynipwatch +++ b/nsd/nsd-dynipwatch @@ -36,18 +36,10 @@ function setAddrInZonefile # sed -i -e "s_^\\($1\\s.*A\\s.*\\s\\)\\([0-9]\\+\\.\\)\\+[0-9]\\+_\\1$3_g" "$2" } -function getSerialFromZonefile # -{ - awk '/; serial/{print$1}' "$1" -} - -function setSerialInZonefile # -{ - sed -i -e "s_^\\(.*\\s\\)[0-9]\+\\(\\s\\+; serial.*\\)_\\1$2\\2_g" "$1" -} function run() { + touch ${watchfile} while true; do inotifywait -q -t 30 -e close_write "${watchfile}" > /dev/null ret=$? @@ -63,11 +55,11 @@ function run() fi if ! [ "${oldip}" = "${newip}" ]; then - serial=`getSerialFromZonefile "${zonefile}"` - serial=$(( $serial + 1)) - echo " Update IP address. New serial ${serial}." + echo " Update IP address. Increment serial." setAddrInZonefile "${host}" "${zonefile}" "${newip}" - setSerialInZonefile "${zonefile}" "${serial}" + nsd-incrserial "${zonefile}" + + /etc/nsd3/signzone.sh sthu.org nsdc rebuild && nsdc reload && nsdc notify fi done