#!/bin/csh
############################################################################
# Copyright (C) 1999 Adiron, LLC.  All Rights Reserved.
#
# This script is a fast install for an ORBAsec SL2 distribution
#
############################################################################

#
# What Architecture are we on.
#
switch (`uname -s`)
   case Linux:
        switch (`uname -m`)
        case i*86:
            set ARCH=linux-x86/npac/home/globus/akarsu/ORBAsec/install
            breaksw
        default:
            set ARCH=linux-`uname -m`
            breaksw
        endsw
        breaksw
   case SunOS:
        set ARCH=solaris-`uname -m`
        breaksw
   default:
        set ARCH=unknown
	breaksw
endsw

echo Your architecture is $ARCH

set flavor=none
set install_krb=0
if (-e GSSKRB-VERSION) then
   set VERSION=`cat GSSKRB-VERSION`
   if (! -e Jgsskrb5-$VERSION-adiron-$ARCH.tar.gz) then
      echo "No Adiron Kerberos for your architecture!"
      if (! -e Jgsskrb5-$VERSION-sandia-$ARCH.tar.gz) then
         echo "No Sandia Kerberos for your architecture!"
      else
         set install_krb=1
      endif
   else
      set install_krb=1
   endif
   echo "1.."
   if ($install_krb) then
     echo "You have two choices of Kerberos for ORBAsec to install"
     echo "Adiron is the base version you need."
     echo "Sandia has enhancements to work with DCE1.1 Security Servers"
     echo -n "Sandia or Adiron? [Adiron] "
     set ans=$<
     if ( "$ans" == "Adiron" || "$ans" == "" || "$ans" == "adiron" ) then
       echo We will install Adiron Kerberos.
       set flavor=adiron
     else if ("$ans" == "Sandia" || "$ans" == "sandia") then
       echo We will install Sandia Kerberos.
       set flavor=sandia
     else
       echo Wrong answer. Please Start again
       exit 1
     endif
   else
       echo No Kerberos installation for your architecture.
       echo You may have to build it yourself and add it later.
       echo We will go ahead with the ORBAsec SL2 installation anyay.
   endif
endif

set ans="no"
while ("$ans" != "yes" && "$ans" != "y" && "$ans" != "Y")
  set ORBASEC=/opt/orbasec
  echo -n "Where would you like to install ORBAsec SL2? [$ORBASEC] "
  set ORBASECans=$<
  if ( "$ORBASECans" == "" ) set ORBASECans=$ORBASEC

  echo -n "Install in $ORBASECans? [Y/n] [^C to cancel] "
  set ans=$<
end
set ORBASEC=$ORBASECans

echo Installing in $ORBASEC

if ( ! -d $ORBASEC) then
     echo "Creating $ORBASEC"
     mkdir -p $ORBASEC
endif
if ( ! -d $ORBASEC) then
     echo "Cannot access $ORBASEC"
     exit 1
endif

foreach i (SL2-*.tar.gz)
   echo Installing $i
   rm -rf $ORBASEC/LOAD
   mkdir $ORBASEC/LOAD
   gunzip $i | (cd $ORBASEC/LOAD; tar xvf -)
   cp -r $ORBASEC/LOAD/*/* $ORBASEC
   rm -rf $ORBASEC/LOAD
end

cp Orbasec-*.pdf.gz $ORBASEC/doc/Orbasec.pdf

if ( $install_krb || $flavor != "none" ) then
   echo Installing Kerberos
   cat Jgsskrb5-$VERSION-$flavor-$ARCH.tar.gz | (cd $ORBASEC; tar xvf -)
endif

echo ORBAsec SL2 installed in $ORBASEC
exit 0


