#!/bin/csh
#
# perform incremental backup of ys tree using incremental tar file:
# SLF 27-Oct-1993 (proto - will call / include in ys_install when tested)
# SLF 28-Oct-1993 (remove 't' qualifier from tar, rm increm when finished)
#
if (!($?ys)) then
   echo need to run Yohkoh startup or define ys, exiting
   exit
endif

set host=`hostname`
set ysver=`$ys/gen/script/get_ysversion`
cd $ys/swmaint/tar
set ftpinc = $ys/site/script/getinc.ftp
set ys_upmess = $ys/site/script/ys_upmess.mail
echo generating ftp transfer script
#### build ftp script
echo open 133.74.8.100 	 >  $ftpinc
echo user ftp $host	 >> $ftpinc
echo binary		 >> $ftpinc
echo cd pub/swmaint/tar	 >> $ftpinc
echo get incremX.$ysver.Z >> $ftpinc
echo bye		 >> $ftpinc
####
echo starting ftp transfer of incremX.$ysver.Z
ftp -in < $ftpinc 
if (!(-e incremX.$ysver.Z)) then
   echo "----- No Increm File Found; Initiating Full Upgrade ----" > $ys_upmess
   echo " " >> $ys_upmess
   echo "----- auto ftp script contents -----" >> $ys_upmess
   cat $ftpinc >> $ys_upmess
   Mail -s "Yohkoh SW - Incremental Upgrade Failed" software@isass0.solar.isas.ac.jp < $ys_upmess
   echo problem with ftp transfer, exiting
   exit
endif

echo uncompressing file increm.$ysver.Z
uncompress -f $ys/swmaint/tar/increm.$ysver.Z
echo starting tar extraction of increm.$ysver
cd $ys
tar -xf $ys/swmaint/tar/increm.$ysver 
unalias rm
rm -f $ys/swmaint/tar/increm.$ysver
echo upgrade complete
exit
