cd /usr/local/ifmail
sitesdir=/usr/local/gup/sites
t=/tmp/PAM$$
cdir=`pwd`
#cd $sitesdir
#list=`ls | grep 'f[0-9]*\.n[0-9]*'`
#list="f20.n464 p1.f10.n464 f57.n464 f1967.n464"
list="f20.n464"
echo list: $list
cd $cdir
for i in $list
do
  echo Making list for $i
  cp $sitesdir/$i/groups $t
  rm -f Areas.$i
  if fgrep -q '*' $t
  then
    echo Grepping with wildcards...
    fgrep '*' $t |
    grep -f - /usr/local/ifmail/Areas | awk '{ print $1 }' > Areas.$i
  fi
  if fgrep -q -v '*' $t
  then
    echo Grepping other...
    fgrep -v '*' $t |
    awk '{
      if(substr($1,0,5)=="fido.") print toupper(substr($1,6))
      else print toupper($1)
    }' >> Areas.$i
  fi
  sort < Areas.$i | uniq > $t
  mv $t Areas.$i
  echo >> Areas.$i
  echo Areas.$i created
  chown fnet.fnet Areas.$i
done

