head	1.1;
access;
symbols;
locks; strict;
comment	@# @;


1.1
date	2004.03.05.00.01.08;	author jhawk;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#!/bin/sh
# for network in `awk '/^Address:/{print $4}' input`
# do
#    ilg=`echo $network| sed 's/-NET//' | tr '[A-Z]' '[a-z]'`
#    echo network: $network
#    echo ilg:	 $ilg
#    echo ""
# done
# 
#   

gawk < input '
/^Address/{
  network=$4;

  split($2,netnum,".");
  subnet[network]=netnum[1] "." netnum[2];

  ilg[network] = tolower(gensub(/-NET/, "", 1, network));
  acount = iacount = 0;
}
/^fsilg.active.iplist/{
  split($0,f,":");
  active[network] = active[network] (acount?"\n":"") f[2];
  acount++;
}
/^fsilg.inactive.iplist/{
  split($0,f,":");
  inactive[network] = inactive[network] (iacount?"\n":"") f[2];
  iacount++;
}
END{
  dq = sprintf("%c", 34);
  for (i in subnet) {
#    if (active[i]=="") active[i]="*NONE*";
#    if (inactive[i]=="") inactive[i]="*NONE*";

    print "network=" i;
    print "subnet=" subnet[i];
    print "ilg=" ilg[i];
    print "activehosts=" dq active[i] dq;
    print "inactivehosts=" dq inactive[i] dq;
    print "cat << EOF";		# cat << EOF | sendmail -t
    system("cat template-head");
    if (active[i]) system("cat template-a");
    if (inactive[i]) system("cat template-b");
    system("cat template-foot");
    print "EOF"
    print "echo ------------------------------------------------------------"
    print ""
  }
}'
@
