4 # Copyright 1998 - 2004 Double Precision, Inc. See COPYING for
5 # distribution information.
7 # Generic wrapper for makedat.
9 # Usage: makedat.sh -src=src -file=file -tmp=tmpfile -hup=hupfile [ -cidr ]
11 # Create [file] from [src]. [src] can be either a plain text file, or a
12 # directory. [tmpfile] is used. if [hupfile] is specified and it exists,
13 # this file contains a PID, which is SIGHUPed.
15 # -cidr - [src] contains a list of IP netblocks. Expand entries in [src]
16 # that use CIDR or start-end notation using the Net::CIDR Perl
17 # module. Download the Net::CIDR module from
18 # http://www.cpan.org/authors/id/M/MR/MRSAM/
21 exec_prefix="@exec_prefix@";
29 echo "Usage: $0 -src=src -file=file -tmp=tmpfile -hup=hupfile [-cidr]" >&2
43 srcfile=`echo "$1" | sed 's/-src=//'`;
47 tmpfile=`echo "$1" | sed 's/-tmp=//'`;
51 dstfile=`echo "$1" | sed 's/-file=//'`;
55 hupfile=`echo "$1" | sed 's/-hup=//'`;
64 if test "$dstfile" = ""
69 if test "$srcfile" = ""
74 if test "$tmpfile" = ""
84 if test "$srcfile" != "CVS"
88 test -f $f || continue
93 cat "$srcfile" || return
102 eval "use Net::CIDR;";
106 unless ( $Net::CIDR::VERSION &&
107 /^([a-fA-F0-9:\.]+[\-\/][a-fA-F0-9:\.]+)\s+(.*)$/)
113 my ($net, $line)=($1, $2);
115 foreach ( Net::CIDR::cidr2octets(
116 Net::CIDR::range2cidr($net)))
127 get_access | docidr | @makedatprogpath@ - "$tmpfile" "$dstfile" || exit 1
129 if test "$hupfile" != ""
133 kill -HUP `cat "$hupfile"`