#!/bin/sh

cmd()
{
    echo "$@"
    eval '"$@"'
    [ $? -ne 0 ] && echo "CMD - error detected in '$@'" >&2 && exit 2
}

checkanswer()
{
    echo
    echo "Do you wish to continue?  (yes/no) "
    echo    
    read answer
    answer=${answer:-null}
    while [ $answer != "yes" -a $answer != "no" -a $answer != "y" -a $answer != "n" ]
    do
	echo Please answer 'yes' or 'no'.
	read answer
        answer=${answer:-null}
    done
    
    if [ $answer != "yes" -a $answer != "y" ]
    then
	echo
	echo "SANergy install was not performed."
	echo
	exit 0
    fi
}

bootnotice() 
{
    #echo "Current conditions require this uninstall script to "
    #echo "reboot the machine after completion."
    #checkanswer
    #needboot=1
    echo "Installing from a accelerated window in not allowed"
    echo "Unset the environment variable then try to install"
    exit 0
}


osnotice()
{
    echo
    echo "****************** SANergy installer *******************"
    echo
    echo "The installer detected os type "`uname`". Is this correct?"
    checkanswer
}

doregstrthing()
{
    file=$1
    x=4;
    while [ $x -gt 0 ]
    do
	if [ -f $file ]
	then
	    cp $file $2
 	    break
	fi
	x=`expr $x - 1`
	file="../"$file
    done
}

checkroot()
{
  if [ "$@" != "root" ]
  then
    echo
    echo "User "$user" you must login as root to run this script."
    echo
    exit 1
  fi
}


setupaixaio() {
    chdev -l aio0 -P $*
    if [ $? = 0 ]
    then
	echo "Changes will become effective at next system restart"
    fi
}

checkaixaio() {
    grep "Available" $@ >> /dev/null 
    if [ $? -ne 0 ]
    then
	echo "Changing aio0 from Defined to Available"
	setupaixaio -a autoconfig='available'
	echo
        echo "After the restart run the SANergy installer again."
        echo "The system will restart now to complete the AIO setup. "
        checkanswer
	reboot
    fi
}

askNls(){
    echo
    echo "Do you want to install National Language Support for SANergy?"
    echo "Prior to answering yes, be sure that you have the Language Pack CD available?  (yes/no) "
    echo    
    read answer
    answer=${answer:-null}
    while [ $answer != "yes" -a $answer != "no" -a $answer != "y" -a $answer != "n" ]
    do
	echo Please answer 'yes' or 'no'.
	read answer
        answer=${answer:-null}
    done
    
    if [ $answer != "no" -a $answer != "n" ]
    then
	echo
	echo "Installation for SANergy CD 1 is complete."
	echo "Please insert the SANergy Language Pack CD 2 in your CD-ROM drive,then"
	echo "change to the CD directory and type ./install"
	echo
	exit 0
    fi
}

copyright(){
    year=`date "+%Y"`
    echo
    echo "          Tivoli SANergy (TM)"
    echo "This software is protected by U.S. patent 5,950,203"
    echo
    echo "        5698-SFS"
    echo "  (C) Copyright IBM Corporation 1995, 2004."
    echo "	  All rights reserved."

    echo
    echo "Please refer to the license.txt file in the appropriate language directory "
    echo "under $1/nls/ for complete details."
}

# ****** start here

ostype=`uname`
needboot=0
done=0
overinstall=0
where=`pwd`
regstr="registration.txt"


if [ ! -f $where/install ] 
then    
    echo
    echo "The install script was not found in "$where"."
    echo "You must be in the directory where the install script is, to run it."
    echo
    exit 1
fi 

#if [ ! -d /opt/SANergy ]
#then
#	if [ ! -d /usr/SANergy ]
#	then
		#echo This is a SANergy patch install.  You must have a previous
		#echo version of SANergy installed for this patch to work correctly.
		#echo Installation aborting... 
		#exit 1
#	fi
#fi

#osnotice
############################# IRIX ############################# 
if [ "$ostype" = "IRIX" ] || [ "$ostype" = "IRIX64" ]
then
  user=`whoami`
  checkroot $user
  homedir="/usr/SANergy"

  testenv=`env | grep _RLD_LIST`
  if [ -n "$testenv" ]
  then
	bootnotice
  fi

  if [ -f /usr/SANergy/uninstall ]
  then
    awk -F. '{ print $1 }' /usr/SANergy/version.txt > /tmp/newfile
    oldversion=`cat /tmp/newfile`
    rm /tmp/newfile
    overinstall=1
    cp /usr/SANergy/SANergyconfig.txt /tmp
    if [ -f /usr/SANergy/devices.txt ]
    then
	cp /usr/SANergy/devices.txt /tmp
    fi
    /usr/SANergy/uninstall
    if [ -d /usr/SANergy ]
    then 
       exit 1
    fi
  fi

  if [ -d sgi ]
  then
    cmd inst -A -f sgi/sanergy
    done=1
    if [ $overinstall -eq 1 ]
    then	
	awk -F. '{ print $1 }' /usr/SANergy/version.txt > /tmp/newfile
	newversion=`cat /tmp/newfile`
	rm /tmp/newfile
	if [ $newversion -ge 2 -o $newversion -eq $oldversion ]
	then
	    cp /tmp/SANergyconfig.txt /usr/SANergy/.
	    if [ -f /tmp/devices.txt ]
	    then
		cp /tmp/devices.txt /usr/SANergy
	    fi
	fi
	rm /tmp/SANergyconfig.txt
    fi
 
    cd $where
    #doregstrthing $regstr $homedir
    cd /

    if [ ! -d $homedir/lib ]
    then
      mkdir $homedir/lib
    fi
    mv -f $homedir/sancvt.so $homedir/lib/.
    mv -f $homedir/sancvt32.so $homedir/lib/.
    mv -f $homedir/sancvt64.so $homedir/lib/.

    copyright $homedir

    /etc/rc2.d/S97sanergy start
    /usr/SANergy/config &
  else 
    echo "Could not find a sgi directory off of "$where"."
  fi

############################# AIX ############################# 
elif [ "$ostype" = "AIX" ]
then

  user=`whoami`
  checkroot $user
  homedir="/usr/SANergy"

  if [ -f /usr/SANergy/uninstall ]
  then
    overinstall=1
    if [ -f /usr/SANergy/SANergyconfig.txt ]
    then
	cp /usr/SANergy/SANergyconfig.txt /tmp
    fi
    if [ -f /usr/SANergy/devices.txt ]
    then
	cp /usr/SANergy/devices.txt /tmp
    fi
    /usr/SANergy/uninstall
    if [ -d /usr/SANergy ]
    then 
       exit 1
    fi
  fi

  #AIO CHECK
  #langsave=$LANG
  #LANG=C
  #tempfile=/tmp/tempclw 
  #cmd echo "Checking systems AIO device... "
  #cmd lsdev -C -c aio > $tempfile
  #checkaixaio $tempfile
  #unlink $tempfile
  #cmd echo "Check complete."
  #LANG=$langsave

  if [ -d aix ]
  then
    if [ -d /tmp/saninstall ]
    then
	rm -rf /tmp/saninstall
    fi
    mkdir /tmp/saninstall
    cp aix/* /tmp/saninstall/.
    cd /tmp/saninstall

#   productname=$(ls *_aix* | awk '
#	    BEGIN {
#		getline s
#		size = split(s,a,"_")
#		print a[1]
#	    }'
#    )
    productname="sanergyfsf"

    cmd installp -acgNQqwX -d /tmp/saninstall $productname.rte
    cd /
    rm -rf /tmp/saninstall
    done=1
    if [ $overinstall -eq 1 ]
    then	
	if [ -f /tmp/SANergyconfig.txt ]
	then
	    mv /tmp/SANergyconfig.txt $homedir
	fi
	if [ -f /tmp/devices.txt ]
	then
	    mv /tmp/devices.txt $homedir
	fi
    fi

    cd $where
    #doregstrthing $regstr $homedir
    cd /

    if [ ! -d $homedir/lib ]
    then
      mkdir $homedir/lib
    fi

    /etc/rc.sanergy
  else 
    echo "Could not find a aix directory off of "$where"."
  fi

############################# SUN ############################# 
elif [ "$ostype" = "SunOS" ]
then

  user=`/usr/ucb/whoami`
  checkroot $user
  homedir="/opt/SANergy"
  OS_REV=`uname -r`

  if [ -f /opt/SANergy/uninstall ]
  then
    overinstall=1
    if [ -f /opt/SANergy/SANergyconfig.txt ]
    then
        cp /opt/SANergy/SANergyconfig.txt /tmp
    fi
    if [ -f /opt/SANergy/devices.txt ]
    then
	cp /opt/SANergy/devices.txt /tmp
    fi
    /opt/SANergy/uninstall
    if [ -d /opt/SANergy ]
    then 
       exit 1
    fi
  fi

  if [ -d solaris ]
  then

#    cd solaris
#    productname=$(ls *_sol* | awk '
#	    BEGIN {
#		getline s
#		size = split(s,a,"_")
#		print a[1]
#	    }'
#    )
#    cd ..
    productname="sanergyfsf"

    cmd pkgadd -d solaris/$productname"_sol"$OS_REV*
    done=1
    if [ $overinstall -eq 1 ]
    then	
	if [ -f /tmp/SANergyconfig.txt ]
	then
	    mv /tmp/SANergyconfig.txt $homedir
	fi
	if [ -f /tmp/devices.txt ]
	then
	    mv /tmp/devices.txt $homedir
	fi
    fi

    cd $where
    #doregstrthing $regstr $homedir

  else 
    echo "Could not find a solaris directory off of "$where"."
  fi

############################# TRU64 ############################# 
elif [ $ostype = "OSF1" ] 
then

  osrev=`uname -r`
  majorrev=`echo $osrev | sed 's/\..*//g'`  # something like V4 or V5

  user=`whoami`
  checkroot $user
  homedir="/usr/SANergy"

  testenv=`env | grep _RLD_LIST`
  if [ -n "$testenv" ]
  then
      bootnotice
  fi

  if [ -f /usr/SANergy/uninstall ]
  then
    #echo
    #echo "SANergy is currently installed."
    #echo "Please run /usr/SANergy/uninstall and then run the installer again. "
    #echo
    #echo "Installation cancelled"
    #exit 1
    overinstall=1
    awk -F. '{ print $1 }' /usr/SANergy/version.txt > /tmp/newfile
    oldversion=`cat /tmp/newfile`
    rm /tmp/newfile
    cp /usr/SANergy/SANergyconfig.txt /tmp
    if [ -f /usr/SANergy/devices.txt ]
    then
	cp /usr/SANergy/devices.txt /tmp
    fi
    #cp /usr/SANergy/SANergykey.txt /tmp
    /usr/SANergy/uninstall
    if [ -d /usr/SANergy ]
    then 
       exit 1
    fi
  fi

  if [ -d tru64 ]
  then
   # testenv=`env | grep _RLD_LIST`
   # if [ -n "$testenv" ]
   # then
   #	unset _RLD_LIST
   # fi
    mkdir /tmp/saninstall
    cp tru64/sanergy_tru64$majorrev* /tmp/saninstall/.
    cd /tmp/saninstall
    tar xf sanergy*.tar
    setld -l . SFSSFS*
    cd /
    rm -r /tmp/saninstall
    done=1
    if [ $overinstall -eq 1 ]
    then	
	awk -F. '{ print $1 }' /usr/SANergy/version.txt > /tmp/newfile
	newversion=`cat /tmp/newfile`
	rm /tmp/newfile
	if [ $newversion -ge 2 -o $newversion -eq $oldversion ]
	then
	    cp /tmp/SANergyconfig.txt /usr/SANergy/.
	    if [ -f /tmp/devices.txt ]
	    then
		cp /tmp/devices.txt /usr/SANergy
	    fi
	    #cp /tmp/SANergykey.txt /usr/SANergy/.
	fi
	rm /tmp/SANergyconfig.txt
	#rm /tmp/SANergykey.txt
    fi

    if [ ! -d $homedir/nls ]
    then
      mkdir $homedir/nls	
    fi
      
    cd $homedir/nls
    tar xf ../nls.tar
    tar xf codeset.tar
    rm -f codeset.tar
    rm -f ../nls.tar
    
    cd $where
    doregstrthing $regstr $homedir
    cd /

    if [ ! -d $homedir/lib ]
    then
      mkdir $homedir/lib
    fi
    mv -f $homedir/sancvt.so $homedir/lib/sancvt.so

    askNls

    copyright $homedir

    /sbin/init.d/sanergy start
    /usr/SANergy/config &
    echo "Starting /usr/SANergy/config ..."

  else 
    echo "Could not find a tru64 directory off of "$where"."
  fi

############################# DGUX  ############################# 
elif [ "$ostype" = "dgux" ]
then

  user=`whoami`
  checkroot $user
  homedir="/usr/opt/SANergy"
  
  testenv=`env | grep LD_PRELOAD`
  if [ -n "$testenv" ]
  then
      bootnotice
  fi

  if [ -f $homedir/uninstall ]
  then
    #echo
    #echo "SANergy is currently installed."
    #echo "Please run /usr/SANergy/uninstall and then run the installer again. "
    #echo
    #echo "Installation cancelled"
    #exit 1
    overinstall=1
    awk -F. '{ print $1 }' $homedir/version.txt > /tmp/newfile
    oldversion=`cat /tmp/newfile`
    rm /tmp/newfile
    cp $homedir/SANergyconfig.txt /tmp
    if [ -f $homedir/devices.txt ]
    then
	cp $homedir/devices.txt /tmp
    fi
    #cp $homedir/SANergykey.txt /tmp
    $homedir/uninstall
    if [ -d $homedir ]
    then 
       exit 1
    fi
  fi

  if [ -d dgux ]
  then
    #testenv=`env | grep LD_PRELOAD`
    #if [ -n "$testenv" ]
    #then
    #    unset LD_PRELOAD
    #fi
    echo "DGUX install"
    if [ ! -d $homedir ]
    then
      mkdir $homedir
    fi

    mkdir /tmp/saninstall
    cp dgux/sanergy_dgux* /tmp/saninstall/.
    cd /tmp/saninstall
    tar xf sanergy_dgux*
    ./install
    cd /
    rm -r /tmp/saninstall
    done=1
    if [ $overinstall -eq 1 ]
    then	
	awk -F. '{ print $1 }' /usr/opt/SANergy/version.txt > /tmp/newfile
	newversion=`cat /tmp/newfile`
	rm /tmp/newfile
	if [ $newversion -ge 2 -o $newversion -eq $oldversion ]
	then
	    cp /tmp/SANergyconfig.txt $homedir/.
	    if [ -f /tmp/devices.txt ]
	    then
		cp /tmp/devices.txt $homedir/.
	    fi
	    #cp /tmp/SANergykey.txt $homedir/.
	fi
	rm /tmp/SANergyconfig.txt
	#rm /tmp/SANergykey.txt
    fi
    
    if [ ! -d $homedir/nls ]
    then
      mkdir $homedir/nls	
    fi
  
    cd $homedir/nls 
    tar xf ../nls.tar
    tar xf codeset.tar
    rm -f codeset.tar
    cd ..
    rm -f nls.tar
     
    cd $where
    doregstrthing $regstr $homedir
    cd /

    if [ ! -d $homedir/lib ]
    then
      mkdir $homedir/lib
    fi
    mv -f $homedir/sancvt.so $homedir/lib/.
    
    askNls

    copyright $homedir

    /etc/rc3.d/S355.sanergy start
    #/usr/SANergy/config &
    #echo "Starting /usr/SANergy/config ..."

  else 
    echo "Could not find a dgux directory off of "$where"."
  fi

############################# Linux  ############################# 
elif [ "$ostype" = "Linux" ]
then

  user=`whoami`
  checkroot $user
  homedir="/usr/SANergy"
  kernelRev=`uname -r`
  linuxDir="linux"
  installmdc=1  
  productname="sanergyfsf_lin"
  testenv=`env | grep LD_PRELOAD`
  if [ -n "$testenv" ]
  then
    bootnotice
  fi

  # need to determine if the linux kernel is supported before we do anything
  # print error message and exit if we do not support the kernel 
  #cd $linuxDir  # switch to the linux directory

  #for DIR in san_lin*.tar
  #do 
  #  temp=`echo $DIR | sed 's/^san_lin//' | sed 's/_3.*.*$//'`
  #  kernelList="$kernelList $temp"
  #done

  #echo $kernelList | egrep -wq $kernelRev
  #if [ $? -ne 0 ]
  #then 
  #  echo "The SANergy MDC will not be installed.  This kernel is not supported."
  #  echo "Only the client will be installed."
  #  checkanswer
  #  installmdc=0
  #fi

  #cd ../       # switch back out of the linux directory

  if [ -f /usr/SANergy/uninstall ]
  then
    overinstall=1
    if [ -f /usr/SANergy/SANergyconfig.txt ]
    then
	cp /usr/SANergy/SANergyconfig.txt /tmp
    fi
    
    if [ -f /usr/SANergy/devices.txt ]
    then
	cp /usr/SANergy/devices.txt /tmp
    fi
    #cp /usr/SANergy/SANergykey.txt /tmp
    /usr/SANergy/uninstall
    if [ -d /usr/SANergy ]
    then 
      exit 1
    fi
  fi

  if [ -d $linuxDir ]
  then

    echo "Linux install"

    if [ ! -d /usr/SANergy ] 
    then
	mkdir -p /usr/SANergy
    fi
    if [ ! -d /usr/SANergy/lib ] 
    then
	mkdir -p /usr/SANergy/lib
    fi

    echo "installing files"

    if [ -d /etc/init.d ]
    then
      INIT_DIR=/etc/init.d
    else
      INIT_DIR=/etc/rc.d/init.d
    fi

    if [ $installmdc -eq 1 ]
    then
      cp $linuxDir/$productname$kernelRev"_"*.tar /usr/SANergy
      cd /usr/SANergy
      tar xf $productname$kernelRev"_"*.tar
      mv -f libext2mdc.so /usr/SANergy/lib
      #mv -f sancvt.so /usr/SANergy/lib/.
      LINUXVER=`uname -r` 
      mkdir -p /lib/modules/$LINUXVER/misc
   #   echo $LINUXVER | grep -q 'smp$'  
   #   if [ $? -eq 0 ] 
   #   then
   #     mv -f sanergysmp.o /lib/modules/$LINUXVER/misc/sanergy.o
   #   else
        mv -f sanergy.o /lib/modules/$LINUXVER/misc/sanergy.o
   #   fi
      mv -f sanergyfs.o /lib/modules/$LINUXVER/misc/sanergyfs.o
      rm -f $productname$kernelRev"_"*.tar
      else
      cp $linuxDir/$productname*.tar /usr/SANergy
      cd /usr/SANergy
      tar xf $productname*.tar
    
    #  mv -f libSANergy.so /lib
      mv -f libext2mdc.so /usr/SANergy/lib
    #  mv -f sancvt.so /usr/SANergy/lib/.

     # mv -f sanergylinuxnomdc $INIT_DIR
     # ln -sf $INIT_DIR/sanergylinuxnomdc /etc/rc.d/rc5.d/S87sanergy
    #  rm -f "san_lin"*.tar
    fi

    done=1
    if [ $overinstall -eq 1 ]
    then
	if [ -f /tmp/SANergyconfig.txt ]
	then
          cp /tmp/SANergyconfig.txt /usr/SANergy/.
	  rm /tmp/SANergyconfig.txt
	fi

	if [ -f /tmp/devices.txt ]
	then
          cp /tmp/devices.txt /usr/SANergy
	fi
    fi


    cd $homedir
#    mkdir nls
#    cd nls 
#    tar xf ../nls.tar
#    tar xf codeset.tar
#    rm -f codeset.tar
#    cd ..
#    rm -f nls.tar


    cd $where
    doregstrthing $regstr $homedir
    cd /

#    askNls    

    copyright $homedir
 
    cp /usr/SANergy/start.sh /etc/init.d/sanergy
    #ln -s /etc/init.d/sanergy /etc/rc3.d/S97sanergy 
    #ln -s /etc/init.d/sanergy /etc/rc4.d/S97sanergy 
    #ln -s /etc/init.d/sanergy /etc/rc5.d/S97sanergy 
    #ln -s /etc/init.d/sanergy /etc/rc6.d/S97sanergy

    /etc/init.d/sanergy start
  else 
    echo "Could not find a linux directory off of "$where" that matches kernel "$kernelRev"."
  fi


############################# HP-UX  ############################# 
elif [ "$ostype" = "HP-UX" ]
then

  user=`whoami`
  checkroot $user
  homedir="/opt/SANergy"
  
  if [ -f /opt/SANergy/uninstall ]
  then
    #echo
    #echo "SANergy is currently installed."
    #echo "Please run /opt/SANergy/uninstall and then run the installer again. "
    #echo
    #echo "Installation cancelled"
    #exit 1
    overinstall=1
    awk -F\[_.\] '{ print $2 }' $homedir/version.txt > /tmp/newfile
    oldversion=`cat /tmp/newfile`
    rm /tmp/newfile
#    cp $homedir/SANergyconfig.txt /tmp
    if [ -f $homedir/devices.txt ]
    then
	cp $homedir/devices.txt /tmp
    fi
    #cp $homedir/SANergykey.txt /tmp
    $homedir/uninstall
    if [ -d $homedir ]
    then 
       exit 1
    fi
  fi

  if [ -d hpux ]
  then
    echo "HPUX install"
    ver=`uname -r`

    if [ ! -d $homedir ] 
    then
	mkdir -p $homedir
    fi
    if [ ! -d $homedir/lib ] 
    then
	mkdir -p $homedir/lib
    fi

    if [ $ver != "B.11.23" ]
    then 
      bits=`getconf KERNEL_BITS`
      cp hpux/sanergyfsf_hpux* $homedir/.
      cd $homedir
      tar xf sanergyfsf_hpux*
      rm -f *.tar
      #
      #
      # INSTALL THE DRIVER 
      #
      #
      MODULE=sanergyfsmod
      if [ $bits -eq 64 ]
      then
	  MODULE=sanergyfsmod64
      fi

      mkdir -p $homedir/build
      if [ -f $homedir/master ]
      then
	cp $homedir/$MODULE  $homedir/build/mod.o
	cp $homedir/master $homedir/build/master
	cp $homedir/system $homedir/build/system
      else
	echo "failed to find file $homedir/master. install failed."
	exit 1
      fi
      if [ $bits -eq 64 ]
      then
	 cp $homedir/SANergyconfig64 $homedir/SANergyconfig
      fi
      chmod 755 $homedir/build
   
      cd build
      echo Installing the driver $MODULE
      kminstall -a $MODULE
      echo Driver $MODULE is not installed
      echo Configuring the driver $MODULE
      (unset MAKEFLAGS ; export MAKEFLAGS ; unset MAKE ; export MAKE ; config -M $MODULE -u )
      cd ..
      echo Completed configuration of the driver $MODULE

      kmadmin -L $MODULE
      MAJOR=`kmadmin -Q sanergyfsmod64 | grep "Character Major" | cut -f 3`
      mknod /dev/sanergyfs c $MAJOR 0

      #
      # configure the driver to load at system start
      #
      if [ -f /etc/loadmods ]
      then
        grep -v $MODULE /etc/loadmods > /etc/loadmods
      fi

      echo $MODULE >> /etc/loadmods

    else  # B.11.23 version of hpux

      cp hpux/sanergyfsf_hpux_B.11.23* $homedir/.
      cd $homedir
      tar xf sanergyfsf_hpux_B.11.23*
      rm -f *.tar
      #
      #
      # INSTALL THE DRIVER 
      #
      #
      MODULE=sanergyfsmod
      mv $MODULE /usr/conf/mod/$MODULE
      sleep 2
      /usr/sbin/kcmodule -s $MODULE=loaded
      /usr/sbin/lsdev -hd $MODULE | head -n 1 | awk '{ rc=system("mknod /dev/sanergyfs c " $1 " 0"); exit rc; }'
      
    fi  # End of os rev check

    #
    #
    # INSTALL THE AUTOMATIC STARTUP SCRIPTS
    #
    #
    echo "Moving sanergyconf"
    mv -f sanergyconfhpux /etc/rc.config.d/sanergyconf
   
    echo "Moving sanergyhpux"
    mv -f sanergyhpux /sbin/init.d
    # remove old default

    if [ -f /sbin/rc2.d/S880sanergy ]
    then
	rm /sbin/rc2.d/S880sanergy  > /dev/null
    fi


    if [ ! -f /sbin/rc2.d/S880sanergy ]
    then
	ln -s /sbin/init.d/sanergyhpux /sbin/rc2.d/S880sanergy
    fi

    done=1

    if [ $overinstall -eq 1 ]
    then	
	awk -F\[_.\] '{ print $2 }' $homedir/version.txt > /tmp/newfile
	newversion=`cat /tmp/newfile`
	rm /tmp/newfile
	if [ $newversion -ge 2 -o $newversion -eq $oldversion ]
	then
#	    cp /tmp/SANergyconfig.txt $homedir/.
	    if [ -f /tmp/devices.txt ]
	    then
		cp /tmp/devices.txt $homedir/.
	    fi
	    #cp /tmp/SANergykey.txt $homedir/.
	fi
#	rm /tmp/SANergyconfig.txt
	#rm /tmp/SANergykey.txt
    fi
    
    if [ ! -d $homedir/nls ]
    then
      mkdir $homedir/nls	
    fi
  

    if [ ! -d $homedir/lib ]
    then
      mkdir $homedir/lib
    fi
    if [ -f $homedir/sancvt.so ]
    then
      mv -f $homedir/sancvt.so $homedir/lib/.
    fi
    
#    askNls

    copyright $homedir

    /sbin/init.d/sanergyhpux start

  else 
    echo "Could not find a hpux directory off of "$where"."
  fi

else
    echo $ostype" unsupported"
    exit 1
fi

if [ $done = 1 ]
then
    echo 
    echo "Refer to the users guide for further installation instructions. "
    echo
    echo "SANergy file installation complete."
    echo
    if [ $needboot = 1 ] 
    then
      echo "The system will now restart"
      checkanswer
    fi 
fi
