#!/bin/sh
#
# This script is run to install this Ganymede schema kit into a server installation
# directory. The only thing we count on to run this script is that /bin/sh works.
#
# Get enough information from the user to be able to find Perl 5 and
# run scripts/installKit.pl.  We'll set a bunch of environment variables
# for installKit.pl to use to do its thing.
#
# Release: $Name: userKit_103 $
# Version: $Revision: 1.2 $
# Last Mod Date: $Date: 2001/06/02 01:39:46 $
#
###############################################################################

echo "Ganymede userKit installation script"

# 
# Figure out how to do an echo without trailing newline
#

case "`echo 'x\c'`" in
'x\c')  echo="echo -n"   nnl= ;;       # BSD 
x)      echo="echo"      nnl="\c" ;;   # Sys V
*)      echo "$0 quitting: Can't set up echo." 1>&2; exit 1 ;;
esac

# Find the source files, if location was not specified.

# Try the directory containing this script, then its parent.

prog=$0

GROOTDIR=`echo $prog|sed 's%/[^/][^/]*$%%'`
# if the program name is the same as the srcdir name, we have no path
# set.. must be .
test "x$GROOTDIR" = "x$prog" && GROOTDIR=.
if test ! -d $GROOTDIR/src/classes; then
  echo "configure: error: can not find sources in $rootdir" 1>&2; exit 1;
fi
export GROOTDIR

# Find perl (GPERL).. we need version 5.003 or later. If we can't find
# it on our own, ask the user

guessperl=`which perl5`

 if test ! -r "$guessperl"; then
  guessperl=`which perl`
 fi

 if `$guessperl $GROOTDIR/scripts/versiontest.pl > /dev/null 2>&1`; then
	GPERL=$guessperl
    else
	$echo "Where is perl 5 installed? [$guessperl] ${nnl}" 

	read userperl

	if  test ! -z "$userperl"; then
	    GPERL=$userperl
	else
	    GPERL=$guessperl
	fi
 fi

export GPERL

$GPERL $GROOTDIR/scripts/installKit.pl
