1#! @SHELL@ 2# 3# $Id: makedat.in,v 1.5 2004/05/09 17:47:04 mrsam Exp $ 4# 5# Copyright 1998 - 2004 Double Precision, Inc. See COPYING for 6# distribution information. 7# 8# Generic wrapper for makedat. 9# 10# Usage: makedat.sh -src=src -file=file -tmp=tmpfile -hup=hupfile [ -cidr ] 11# 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. 15# 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/ 20 21prefix="@prefix@"; 22exec_prefix="@exec_prefix@"; 23 24srcfile="" 25dstfile="" 26tmpfile="" 27hupfile="" 28 29usage() { 30 echo "Usage: $0 -src=src -file=file -tmp=tmpfile -hup=hupfile [-cidr]" >&2 31 exit 1 32} 33 34cidr="" 35 36while test $# -gt 0 37do 38 case $1 in 39 -cidr) 40 cidr=1 41 shift 42 ;; 43 -src=*) 44 srcfile=`echo "$1" | sed 's/-src=//'`; 45 shift 46 ;; 47 -tmp=*) 48 tmpfile=`echo "$1" | sed 's/-tmp=//'`; 49 shift 50 ;; 51 -file=*) 52 dstfile=`echo "$1" | sed 's/-file=//'`; 53 shift 54 ;; 55 -hup=*) 56 hupfile=`echo "$1" | sed 's/-hup=//'`; 57 shift 58 ;; 59 *) 60 usage 61 ;; 62 esac 63done 64 65if test "$dstfile" = "" 66then 67 usage 68fi 69 70if test "$srcfile" = "" 71then 72 usage 73fi 74 75if test "$tmpfile" = "" 76then 77 usage 78fi 79 80 81get_access() { 82 83 if test -d "$srcfile" 84 then 85 if test "$srcfile" != "CVS" 86 then 87 for f in "$srcfile"/* 88 do 89 test -f $f || continue 90 cat "$f" || return 91 done 92 fi 93 else 94 cat "$srcfile" || return 95 fi 96 echo "." 97} 98 99docidr() { 100 if test "$cidr" = 1 101 then 102 @PERL@ -e ' 103 eval "use Net::CIDR;"; 104 105 while (<>) 106 { 107 unless ( $Net::CIDR::VERSION && 108 /^([a-fA-F0-9:\.]+[\-\/][a-fA-F0-9:\.]+)\s+(.*)$/) 109 { 110 print; 111 next; 112 } 113 114 my ($net, $line)=($1, $2); 115 116 foreach ( Net::CIDR::cidr2octets( 117 Net::CIDR::range2cidr($net))) 118 { 119 print "$_\t$line\n"; 120 } 121 } 122 ' 123 else 124 @CAT@ 125 fi 126} 127 128get_access | docidr | @makedatprogpath@ - "$tmpfile" "$dstfile" || exit 1 129 130if test "$hupfile" != "" 131then 132 if test -f $hupfile 133 then 134 kill -HUP `cat "$hupfile"` 135 fi 136fi 137