Changeset 8599 for 2.0


Ignore:
Timestamp:
Oct 31, 2010, 3:26:55 AM (14 years ago)
Author:
rick
Message:
  • More standard: all now uses a dot at the end.
  • Better reload: not every time, but only when done checking.
  • More robust: it failed on empty files for example.
  • Code cleanup: removed stale newlines and added/moved variables around.
Location:
2.0/nanobsd/nanobsd/files/usr/local
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 2.0/nanobsd/nanobsd/files/usr/local/etc/mararc

    r8101 r8599  
    1010#csv2["example.com."] = "db.example.com"
    1111
    12 csv2["wleiden.net."] = "db.wleiden.net"
     12csv2["wleiden.net."] = "db.wleiden.net."
    1313csv2["16.172.in-addr.arpa."] = "db.16.172.in-addr.arpa."
    1414csv2["17.172.in-addr.arpa."] = "db.17.172.in-addr.arpa."
  • 2.0/nanobsd/nanobsd/files/usr/local/sbin/fetchzone.sh

    • Property svn:keywords set to Id
    r8101 r8599  
    11#!/bin/sh
     2# $Id$
     3#
     4# Wireless Leiden specific configuration to fetch DNS zones
     5# used by MaraDNS
     6#
    27
    3 # Set some vars
    4 ZONES="wleiden.net 16.172.in-addr.arpa. 17.172.in-addr.arpa.
     8# Updates of $ZONES we are going to fetch from the $SERVER every $IDLE seconds
     9ZONES="wleiden.net. 16.172.in-addr.arpa. 17.172.in-addr.arpa.
    51018.172.in-addr.arpa. 19.172.in-addr.arpa. 20.172.in-addr.arpa.
    61121.172.in-addr.arpa. 22.172.in-addr.arpa. 23.172.in-addr.arpa.
     
    81327.172.in-addr.arpa. 28.172.in-addr.arpa. 29.172.in-addr.arpa.
    91430.172.in-addr.arpa. 31.172.in-addr.arpa."
     15SERVER=172.16.4.46
     16IDLE=3600
    1017
    11 SERVER=195.169.86.131
    12 APP=/usr/local/bin/fetchzone
    1318LOGFILE=/var/log/fetchzone.log
    1419PIDFILE=/var/run/fetchzone.pid
    15 IDLE=3600
     20### END OF USER CONFIGURABLE VARIABLES ###
     21
    1622
    1723# Create logging service
     
    2329PID=$$
    2430echo ${PID} > ${PIDFILE}
    25 
    26 # Tell logfile that I am starting
    2731log "[INFO] Fetchzone starting with PID: $PID"
    2832
    29 # Make sure I never die
     33# Make me a deamon script
    3034while [ true ]; do
    3135
     36  CHANGED_ZONES=""
    3237  # Run through multiple zones
    33   for ZONE in ${ZONES}
    34   do
    35 
     38  for ZONE in ${ZONES}; do
    3639    # (re) Set some extra vars
    37     TMPFILE=/tmp/dns-${ZONE}.tmp
     40    TMPFILE=/tmp/dns-tmp-${ZONE}
    3841    REALFILE=/usr/local/etc/maradns/db.${ZONE}
    3942    # Execute Fetchzone
    40     ${APP} ${ZONE} ${SERVER} > ${TMPFILE}
     43    /usr/local/bin/fetchzone ${ZONE} ${SERVER} > ${TMPFILE}
    4144 
    4245    # Did Fetchzone exit unhappy
    43     if [ $? -eq 0 ]; then
    44  
    45       # Are there any changes?
    46       COMM=`comm -23 ${TMPFILE} ${REALFILE} 2>&1`
    47       if [ -n "$COMM" ]; then
    48  
    49         # If there are any changes copy tmp to realfile
    50         log "[INFO] Changes found"
    51         cp ${TMPFILE} ${REALFILE}
    52  
    53         # Maradns requires a restart to load new zonefile
    54         /usr/local/etc/rc.d/maradns restart
    55  
    56       fi
    57     else
    58  
     46    if [ $? -ne 0 ]; then
    5947      # Something went wrong lets log it
    60       log "[ERROR] Errors found in fetchzone query"
     48      log "[ERROR] [$ZONE] Errors found in fetchzone query"
     49      continue
    6150    fi
    6251
     52    # Are there any changes, we need to put active?
     53    diff -Nq ${TMPFILE} ${REALFILE}
     54    if [ $? -eq 1 ]; then
     55      log "[INFO] [$ZONE] Changes found"
     56      cp ${TMPFILE} ${REALFILE}
     57      CHANGED_ZONES="$CHANGED_ZONES $ZONE"
     58    fi
    6359  done
    6460
    65   # Lets go to sleep
     61  # Maradns requires a restart to load new zonefile
     62  if [ -n "$CHANGED_ZONES" ]; then
     63    log "[INFO] `/usr/local/etc/rc.d/maradns restart`"
     64  fi
     65
     66  # Next run in $IDLE seconds
    6667  sleep ${IDLE}
    6768done
Note: See TracChangeset for help on using the changeset viewer.