#! /bin/sh
#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2001 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#


flag=1
while [ $flag -le 10 ]
do
   if [ "$SKILLED" = "+" ]
   then
     $KIXCLS
   fi
   echo "                       Set RTS Install Directory             $DATEVAR"
   echo " "
   echo "--------------------------------------------------------------------------------"
   echo "Enter the parent directory of the RTS Install directory "
   read WORKDIR
   if [ "a$WORKDIR" = "a" ]
   then
      WORKDIR="./InstalledRTSFS"
   fi

   WORKDIR=`eval echo $WORKDIR`/InstalledRTSFS
   rm -f /tmp/config.current
   touch /tmp/config.current

   if [ ! -d $WORKDIR ]
   then
      echo "# Warning: the RTS install directory $WORKDIR does not exist.  Create it ?"
      echo $N "# Enter [Y]es or [N]o $C"
      read yn
   else
      echo $WORKDIR >/tmp/workdir
      echo "# RTS install directory is $WORKDIR"
      echo "# Copying required files to the RTS install directory. Please wait."
      cp ./* $WORKDIR
      chmod +w $WORKDIR/*
      echo "Type return to continue"
      read risp
      exit
   fi

   case $yn in
     Y|y) mkdir -p $WORKDIR
          COND=$?
          if [ $COND -eq 0 ] 
          then
            echo "# RTS install directory is $WORKDIR"
            echo "# Copying required files to the RTS install directory. Please wait."
            cp ./* $WORKDIR
            chmod +w $WORKDIR/*
            echo $WORKDIR >/tmp/workdir
            echo "Type return to continue"
            read risp
            flag=11
          else
            echo "#"
            echo "# ERROR: Setting up the RTS install directory. Type return to continue"
            echo "#"
            read risp
            flag=2
          fi
          ;;
     N|n) 
          echo "# Warning: RTS install directory not created."
          echo "Type return to continue"
          read risp
          ;;
     *)   echo "#"
          echo "# ERROR: $yn is invalid option."
          echo "#"
          echo "Type return to continue"
          read risp
          flag=2
          ;;
   esac
done
