Darrel O'Pry wrote:
Ok, well that approach is still taken with the updated script. I've attached one final version, that addresses some things that were missed before (sum was not effective since the filenames differed and were included). Also, it runs under sh instead of bash, so people don't need bash to run it. If this looks good to everyone, I'll release 0.9 today.
actually the fi is before the cat line, because hopefully there will be an old data.srv-$A since the wget failed and didn't mv the tmp to data.srv-$A. And I'd rather have out of data information from that server included in my data file than no information from that server.
.darrel.
Regards,
Bill
#!/bin/sh
# The FULL path to the index.php file for the VegaDNS server VEGADNS='http://127.0.0.1/vegadns-0.9b1/index.php' # NOTE: You can get updates from multiple VegaDNS servers if # desired. Simply separate them by spaces like so: # VEGADNS='http://server1/vegadns-x.x/index.php http://server2/vegadns-x.x/index.php' # Path to the tinydns directory TINYDNSDIR=/etc/tinydns CUR="$TINYDNSDIR/root/data" OLD="$TINYDNSDIR/root/data.old" NEW="$TINYDNSDIR/root/data.new" cp $CUR $OLD if [ -f "$NEW" ] ; then rm $NEW fi A=$[0] for VD in $VEGADNS ; do A=$[$A+1] if wget -q -O "$TINYDNSDIR/root/data.srv-$A" $VD?state=get_data ; then if [ -s "$TINYDNSDIR/root/data.srv-$A" ] ; then cat "$TINYDNSDIR/root/data.srv-$A" >>$NEW else echo "ERROR: $TINYDNSDIR/root/data.srv-$A does not have a size greater than zero" exit 1 fi else echo "ERROR: wget did not return 0 when accessing $VD?state=get_data" exit 1 fi if [ -f "$TINYDNSDIR/root/data.srv-$A" ] ; then rm "$TINYDNSDIR/root/data.srv-$A" fi done # Don't run make if the files havn't changed OLDSUM=$(sum $OLD | awk '{ print $1 " " $2}') NEWSUM=$(sum $NEW | awk '{ print $1 " " $2}') if [ "$OLDSUM" != "$NEWSUM" ]; then mv $NEW $CUR (cd $TINYDNSDIR/root ; make -s) else rm $NEW fi
