#! /bin/csh -f
#
#  rest_sedit: SEDIT installation script
#

if (  -e ./sedit_restore.Z ) then

  echo "uncompress ./sedit_restore.Z"
        uncompress ./sedit_restore.Z

  if ( $status != 0 ) then
    echo "***** Warning: unsuccessful instalation"
    exit 1
  endif

else

   if (  -e ./sedit_restore.gz ) then
     echo ".... Unpacking"

     if (  -e ./rest.bin/gunzip.Z ) then
       uncompress ./rest.bin/gunzip.Z
       if ( $status != 0 ) then
         echo "***** Warning: unsuccessful instalation"
         exit 1
       endif
     endif

     ./rest.bin/gunzip ./sedit_restore.gz
     if ( $status != 0 ) then
       echo "***** Warning: unsuccessful instalation"
       exit 1
     endif
   endif

endif

if ( ! -e ./sedit_restore ) then
  echo "Missing file ./sedit_restore"
  exit 1
endif

restore -qf ./sedit_restore

if ( $status == 0 ) then
  rm -f ./sedit_restore
  if ( -e ./rest.bin ) then
    rm -r -f ./rest.bin
  endif
  echo "SEDIT successfully installed"
  exit 0
endif

echo "***** Warning: unsuccessful installation"
