#!/bin/sh
#<copyright>
# ----------------------------------------------------------
# Sun Proprietary/Confidential Code
# Copyright 2001, Sun Microsystems, Inc. All rights reserved.
# ----------------------------------------------------------
#</copyright>


found=N
#/usr/perl5/5.00503/bin/perl
for p in "/usr/bin/perl" "/bin/perl" "/usr/local/bin/perl" "/opt/bin/perl" 
do
  if test $found = "N"; then
    if test -x $p; then
      perl=$p
      v=`$p -e '$x=$]; print $x*1000'`
      if test "0$v" -ge "05005" ; then
        found="Y"
      fi
    fi
  fi
done

if test $found = "N" ; then
  LOOP=Y
  echo "Cannot find a version of perl that is greater then 5.005"
  echo ""
  while test "$LOOP" = "Y"
  do
   echo "Enter a path to perl or quit [q]: \c"
   read perl 
   if test "$perl" = "q" 
   then
     echo " "
     echo " ******************* ERROR *************************************"
     echo " No version of perl greater then 5.005 could be found. "
     echo " ******************* HELP **************************************"
     echo " If only the Perl binaries need to be acquired, be sure to select"
     echo " the appropriate operating system."
     echo " The Perl source is generic for the individual operating system"
     echo " types and will have to be compiled."
     echo " The following URL can assist with getting Perl 5.005 or better."
     echo " http://www.perl.com/pub/language/info/software.html"
     echo " ***************************************************************"
     exit 1;
   fi
   if test "$perl" = ""
   then
      echo "Warning: You must enter a perl path!"
      echo ""
  
   elif test -x $perl
   then
      v=`$perl -e 'print $]'`;
      if test "0$v" -ge "05.00500" ; then
        LOOP=N
      else
        echo "This perl '$perl' is too old ($v) !"
      fi
   else
      echo "The path '$perl' cannot be executed!"
      echo ""
   fi
  done
fi

ln -s $perl /opt/SUNWstade/bin/perl >/dev/null 2>&1
ln -s $perl /opt/SUNWstadh/bin/perl >/dev/null 2>&1

pkginfo SUNWstadh > /dev/null 2>&1

if [ $? -eq 0 ]
then
  cd /opt/SUNWstadh/dhbin
  $perl /opt/SUNWstadh/dhbin/ras_install.exe $*

elif test -d "/opt/SUNWstade/svebin"
then
  cd /opt/SUNWstade/svebin
  $perl /opt/SUNWstade/svebin/ras_install.exe $*

else
  $perl /opt/SUNWstade/bin/fix_perl_path $perl
  cd /opt/SUNWstade/bin
  $perl /opt/SUNWstade/bin/ras_install.exe $*
fi
