#!/bin/ksh
#
# ident	"@(#)installer 1.4	01/07/11 SMI"
#
full_name=$0
prg_name=`/usr/bin/basename $full_name`
dir_name=`/usr/bin/dirname $full_name` 
host_name=`/usr/bin/uname -n`

CPU=`/usr/bin/uname -p`

a1=$1
a2=$2 
a3=$3 
a4=$4 
a5=$5 
a6=$6 
a7=$7 
a8=$8 
a9=$9  

install_dir=$(dirname $0)
cd $dir_name

#
# Login the user as a root user
# Use the "su" command to ask for password and run the installer 
#

set `/bin/id`
if [ $1 != "uid=0(root)" ]; then
  echo
  gettext "To install this software you must be the root user.\n"
  echo 
  gettext "Please enter this system's root user password\n"
  su root -c "./installer $a1 $a2 $a3 $a4 $a5 $a6 $a7 $a8 $a9";
  if [ $? -eq 1 ]; then
	gettext "Access denied\n"
  fi
  exit
fi

#
# User is now root.  
# Change directory to the .install area
#

cd $install_dir

adminfile=/tmp/admin$$
cat > $adminfile <<END
basedir=default
mail=
runlevel=nocheck
conflict=nocheck
setuid=nocheck
action=nocheck
partial=nocheck
instance=overwrite
idepend=nocheck
rdepend=nocheck
space=quit
END

# make sure that user accepts the license
/usr/bin/more COPYING
echo
ans=$(ckyorn -p "Do you accept these license terms? ~")
case "$ans" in
`gettext '[yY]*'`)	gettext "Thank-you.\n"
			;;
*)			gettext "License terms not accepted.\n"
			exit 2
			;;
esac

#if [ -f README ]; then
#    echo
#    ans=$(ckyorn -Q -p "There is a README file available, read it now? ~")
#    case "$ans" in
#    `gettext '[yY]*'`)	/usr/bin/more README
#			echo
#			;;
#    *)			echo
#			;;
#    esac
#fi

ans=$(ckyorn -p "Install the software now? ~")
case "$ans" in
`gettext '[yY]*'`)	gettext "Thank-you.  Please wait.\n"
			;;
*)			gettext "Terminated at user request.\n"
			exit 2
			;;
esac

# for now we just use a CLI installer
/usr/sbin/pkgadd -d Packages/$CPU  -a $adminfile GEDafed

rm $adminfile

# copy the afe.conf to kernel/drv 
cp afe.conf /kernel/drv
