#! /bin/csh -f
#
# PLEASE READ: items you will have to change
# for *your* news group begin with (+++)
# File to post the digest to the world
# P. Fishwick/ Univ. of Florida/1988
#
# (+++) Specify home directory for news group
# (+++) This is where all files should be stored
set digestdir=~/sim
# (+++) Specify directory for archives to be stored
# (+++) archives are in the format vXnY
# (+++) standing for Volume X, Number Y
set archivedir=bikini:~ftp/pub/simdigest
# Set up files to use for posting
set BigSeparator=$digestdir/separator1
set SmallSeparator=$digestdir/separator2
set Blank=$digestdir/blank
set Issue=$digestdir/issue
set Issue_Temp=$digestdir/issuetemp
set LastIssue=$digestdir/last.issue
set Format=$digestdir/format
set Header1=$digestdir/header1
set Header2=$digestdir/header2
set Header3=$digestdir/header3
set ContentsHeader=$digestdir/contents.header
set Contents=$digestdir/contents
set Contents_Temp=$digestdir/contentstemp
set IndexFile=$digestdir/index 
set Trailer=$digestdir/trailer
set Temp=$digestdir/temp
set TempHeader1=$digestdir/tempheader1
set VolIss = $digestdir/voliss
set VolFile = $digestdir/volume
set IssFile = $digestdir/issuenum
set Topic = $digestdir/topic
#
set Cat_Gen = $digestdir/gen
set Cat_Q = $digestdir/q
set Cat_RE = $digestdir/re
set Cat_REV = $digestdir/rev
set Cat_SOFT = $digestdir/soft
set Cat_TR = $digestdir/tr
set Cat_Call = $digestdir/call
set Cat_Dept = $digestdir/dept
#
# category files
#
echo "Subject: [GENERAL INFORMATION]" > $Cat_Gen.h
echo "Subject: [REGARDING PAST QUESTIONS]" > $Cat_RE.h
echo "Subject: [NEW QUESTIONS]" > $Cat_Q.h
echo "Subject: [REVIEWS]" > $Cat_REV.h
echo "Subject: [SOFTWARE]" > $Cat_SOFT.h
echo "Subject: [PUBLICATIONS]" > $Cat_TR.h
echo "Subject: [CALL FOR PAPERS/PARTICIPATION]" > $Cat_Call.h
echo "Subject: [DEPARTMENTS]" > $Cat_Dept.h
#
# Check Mail Server
#
echo Checking Mail Server...
rsh bikini echo Check OK
#
# create the issue from the category files
#
echo " " > $Issue
cat $Issue $BigSeparator > $Issue_Temp
mv $Issue_Temp $Issue
if (-e $Cat_Gen) then
 cat $Issue $Cat_Gen.h $SmallSeparator $Blank $Cat_Gen > $Issue_Temp
 mv $Issue_Temp $Issue
endif
if (-e $Cat_Q) then
 cat $Issue $Blank $Cat_Q.h $SmallSeparator $Blank $Cat_Q > $Issue_Temp
 mv $Issue_Temp $Issue
endif
if (-e $Cat_RE) then
 cat $Issue $Blank $Cat_RE.h $SmallSeparator $Blank $Cat_RE > $Issue_Temp
 mv $Issue_Temp $Issue
endif
if (-e $Cat_REV) then
 cat $Issue $Blank $Cat_REV.h $SmallSeparator $Blank $Cat_REV > $Issue_Temp
 mv $Issue_Temp $Issue
endif
if (-e $Cat_SOFT) then
 cat $Issue $Blank $Cat_SOFT.h $SmallSeparator $Blank $Cat_SOFT > $Issue_Temp
 mv $Issue_Temp $Issue
endif
if (-e $Cat_TR) then
 cat $Issue $Blank $Cat_TR.h $SmallSeparator $Blank $Cat_TR > $Issue_Temp
 mv $Issue_Temp $Issue
endif
if (-e $Cat_Call) then
 cat $Issue $Blank $Cat_Call.h $SmallSeparator $Blank $Cat_Call > $Issue_Temp
 mv $Issue_Temp $Issue
endif
if (-e $Cat_Dept) then
 cat $Issue $Blank $Cat_Dept.h $SmallSeparator $Blank $Cat_Dept > $Issue_Temp
 mv $Issue_Temp $Issue
endif
cp $Issue $Issue_Temp
#
  set volume = `cat $VolFile`
  set issuenum = `cat $IssFile`
  set issuenum = `expr $issuenum + 1`
# (+++) note: default digest numbering:  volume starts at 1
# (+++) and runs to infinity, while issue number starts at 1
# (+++) and goes to 10, then begins at 1 again as it bumps
# (+++) the volume number up one.
  if ($issuenum == 11) then
    set issuenum = 1
    set volume = `expr $volume + 1`
  endif
# update new volume and issue numbers
  echo $volume > $VolFile
  echo $issuenum > $IssFile
  echo "Volume: $volume, Issue: $issuenum, `date`" > $VolIss
# Insert Volume and Issue #'s in header file for USENET
  sed -e s/volumenum/$volume/ -e s/issuenum/$issuenum/ $Header1 > $TempHeader1
# Add vol/iss. info and contents to index file
#
# create the table of contents from the category files
#
echo "[GENERAL INFORMATION]" > $Cat_Gen.h
echo "[REGARDING PAST QUESTIONS]" > $Cat_RE.h
echo "[NEW QUESTIONS]" > $Cat_Q.h
echo "[REVIEWS]" > $Cat_REV.h
echo "[SOFTWARE]" > $Cat_SOFT.h
echo "[PUBLICATIONS]" > $Cat_TR.h
echo "[CALL FOR PAPERS/PARTICIPATION]" > $Cat_Call.h
echo "[DEPARTMENTS]" > $Cat_Dept.h
#
echo " " > $Contents
if (-e $Cat_Gen) then
 cat $Contents $Cat_Gen.h $Cat_Gen.c > $Contents_Temp
 mv $Contents_Temp $Contents
endif
if (-e $Cat_Q) then
 cat $Contents $Cat_Q.h $Cat_Q.c > $Contents_Temp
 mv $Contents_Temp $Contents
endif
if (-e $Cat_RE) then
 cat $Contents $Cat_RE.h $Cat_RE.c > $Contents_Temp
 mv $Contents_Temp $Contents
endif
if (-e $Cat_REV) then
 cat $Contents $Cat_REV.h $Cat_REV.c > $Contents_Temp
 mv $Contents_Temp $Contents
endif
if (-e $Cat_SOFT) then
 cat $Contents $Cat_SOFT.h $Cat_SOFT.c > $Contents_Temp
 mv $Contents_Temp $Contents
endif
if (-e $Cat_TR) then
 cat $Contents $Cat_TR.h $Cat_TR.c > $Contents_Temp
 mv $Contents_Temp $Contents
endif
if (-e $Cat_Call) then
 cat $Contents $Cat_Call.h $Cat_Call.c > $Contents_Temp
 mv $Contents_Temp $Contents
endif
if (-e $Cat_Dept) then
 cat $Contents $Cat_Dept.h $Cat_Dept.c > $Contents_Temp
 mv $Contents_Temp $Contents
endif
# update index file with this volume/issue
cat $IndexFile $Blank $VolIss $Blank $Contents $Blank > $Temp
mv $Temp $IndexFile
# end of volume,issue updating
#---------------------------------------------
#
# (+++) *** ship digest to USENET community ***
# (+++) NOTE: remove this section of code if you do not currently have
# (+++) a valid newsgroup (see 'standards' documents).
#
#---------------------------------------------
 echo "DIGEST sent to USENET"
 cat $TempHeader1 $VolIss $ContentsHeader $Contents $Header3 \
     $Issue_Temp $Trailer > $Temp
 mv $Temp $Issue
# Create an Archive File for this Issue
 set archive = `echo "v"$volume"n"$issuenum`
# (+++) remove following line if you are not supportin archives
 rcp $Issue $archivedir/$archive
 cp $Issue $digestdir/archive/$archive
 rcp $IndexFile $archivedir

# (+++) note: this is the key line to ship digest to USENET
 cat $Issue | rsh bikini /usr/lib/news/inews -h
#---------------------------------------------
#
# (+++) *** ship digest to NETMAIL community ***
# (+++) NOTE: remove this section of code if you do not currently have
# (+++) or want a separate mailing list for people who cannot get
# (+++) access to USENET
#
#---------------------------------------------
  echo "DIGEST sent to NETMAIL"
  cat $Header2 $VolIss $ContentsHeader $Contents $Header3 \
      $Issue_Temp $Trailer > $Temp
  mv $Temp $Issue
# (+++) send over current distribution list TO MAILER MACHINE
# (+++) note: you will only want to do this IF your mailer machine
# (+++) is different than the machine on which you prepare your
# (+++) digest and ship your digest.
  cp $digestdir/distribution /cis/bikini0/fish/simgroup/distribution
# (+++) change to reflect your digest name
  set subject=`echo 'SIMULATION DIGEST V'$volume' N'$issuenum`
# (+++) note: this is the key line to ship digest to a mailing list
  mail -s "$subject" simulation-maillist@ufl.edu < $Issue
#
# remove temporary files in preparation for next digest issue
#
  rm -f $Contents $Topic $TempHeader1 $Issue_Temp $VolIss
  rm -f $Cat_Q $Cat_Gen $Cat_TR $Cat_RE $Cat_REV $Cat_SOFT
  rm -f $Cat_Call $Cat_Dept
  rm -f $Cat_Q.c $Cat_Gen.c $Cat_TR.c $Cat_RE.c $Cat_REV.c $Cat_SOFT.c
  rm -f $Cat_Call.c $Cat_Dept.c
  rm -f $Cat_Q.h $Cat_Gen.h $Cat_TR.h $Cat_RE.h $Cat_REV.h $Cat_SOFT.h
  rm -f $Cat_Call.h $Cat_Dept.h
# save this issue for posterity
  mv $Issue $LastIssue
# reset Topic Number to zero
  echo "0" > $Topic  
  echo "DONE POSTING."


