#!/bin/sh
# -------------------------------------------------------------------
#     update
# 
#     Simple bourne shell script which should be executed
#        1) within your copy of the msgs directory after updating the
#           newstext
#        2) within the real msgs directory after you have su'd to
#           micro
# 
#     In the first case, this script executes the appropriate
#     cvs update command after updating the date in the connect.txt
#     and newstext
# 
#     In the second case, this script updates the real msgs directory
#     with cvs and mkindx news.
# 
#     Written By TYao                 Date:  04/14/92
# -------------------------------------------------------------------

#     :  com is the name of the script

com=$0                                

#     :  dir is the path of the script location

dir=`pwd`

#     :  real_dir is the path of the real directory

real_dir='/mit2/muse/msgs'

#     :  Set paths to cvs and mkindx programs

cvs='/usr/local/bin/cvs'
mkindx='./mkindx'   

#     :  check to see where you are

if [ $dir = $real_dir ]
then
#     :  :  you must be in the real directory, so assume you are su'd
#           as micro

   echo "Within real msgs directory..."

#     :  :  Update cvs

   $cvs update

#     :  :  Update indices for news and help

   make

#     :  :  Done
 
   echo "Changes complete."

elif [ -f connect.txt ]
then                                   
#     :  :  you must be in a copy directory
#
   echo "Within copy directory..."

#     :  :  Initialize update date for inclusion in connect.txt and newstext

   update=`date`
   echo "Update date = $update"

#     :  :  If connect.tmp exists, remove it.

   if [ -f connect.tmp ]
   then
      rm connect.tmp
   fi

#     :  :  If newstext.tmp exists, remove it.

   if [ -f newstext.tmp ]
   then
      rm newstext.tmp
   fi

#     :  :  Update newstext.txt date

   cat newstext | sed -e "s/NEWS LAST UPDATED: .*$/NEWS LAST UPDATED: $update /g" > newstext.tmp
   mv -f newstext.tmp newstext

#     :  :  Update connect.txt date

   cat connect.txt | sed -e "s/Last online news update: .* MUSE/Last online news update: $update  MUSE/" > connect.tmp
   mv -f connect.tmp connect.txt

#     :  :  Commit connect.txt and newstext

   $cvs commit 

#     :  :  You are done with this part

   echo "cd to /mit2/muse/msgs, type: update"

else
#
  echo "Not within a msgs directory.  Exiting."
  exit
#
fi
