3 # $Id: makedat.in,v 1.5 2004/05/09 17:47:04 mrsam Exp $
5 # Copyright 1998 - 2004 Double Precision, Inc. See COPYING for
6 # distribution information.
8 # Generic wrapper for makedat.
10 # Usage: makedat.sh -src=src -file=file -tmp=tmpfile -hup=hupfile [ -cidr ]
12 # Create [file] from [src]. [src] can be either a plain text file, or a
13 # directory. [tmpfile] is used. if [hupfile] is specified and it exists,
14 # this file contains a PID, which is SIGHUPed.
16 # -cidr - [src] contains a list of IP netblocks. Expand entries in [src]
17 # that use CIDR or start-end notation using the Net::CIDR Perl
18 # module. Download the Net::CIDR module from
19 # http://www.cpan.org/authors/id/M/MR/MRSAM/
22 exec_prefix="@exec_prefix@";
30 echo "Usage: $0 -src=src -file=file -tmp=tmpfile -hup=hupfile [-cidr]" >&2
44 srcfile=`echo "$1" | sed 's/-src=//'`;
48 tmpfile=`echo "$1" | sed 's/-tmp=//'`;
52 dstfile=`echo "$1" | sed 's/-file=//'`;
56 hupfile=`echo "$1" | sed 's/-hup=//'`;
65 if test "$dstfile" = ""
70 if test "$srcfile" = ""
75 if test "$tmpfile" = ""
85 if test "$srcfile" != "CVS"
89 test -f $f || continue
94 cat "$srcfile" || return
103 eval "use Net::CIDR;";
107 unless ( $Net::CIDR::VERSION &&
108 /^([a-fA-F0-9:\.]+[\-\/][a-fA-F0-9:\.]+)\s+(.*)$/)
114 my ($net, $line)=($1, $2);
116 foreach ( Net::CIDR::cidr2octets(
117 Net::CIDR::range2cidr($net)))
128 get_access | docidr | @makedatprogpath@ - "$tmpfile" "$dstfile" || exit 1
130 if test "$hupfile" != ""
134 kill -HUP `cat "$hupfile"`