#
# Copyright (c) 1999-2000 Easysoft Ltd. All rights reserved.
#
# This script does the introductory work for an install e.g. display license
# notice and ask if the installer accepts it.
#
# Calling format:
#
# install_intro text_notice_file 
#
# returns:
#
# 0 = success
# 1 = invalid command line
# 2 = environment variable not defined
# 3 = file not found
# 99 = installation aborted at user request
#
# $Id: install_intro,v 1.1 2000/03/17 16:37:16 martin Exp $
#
# $Log: install_intro,v $
# Revision 1.1  2000/03/17 16:37:16  martin
# Initial revision
#
#
if [ "$ECHO" = "" ];then
  echo "error - ECHO not defined, expect it to be exported"
  exit 2
fi
#
# Check command line
#
cmdline_error=""
if [ $# -ne 1 ];then
  cmdlinestr="Missing text notice file argument"
  cmdline_error="1"
else
  NOTICEFILE="$1"
  if [ ! -r "$NOTICEFILE" ];then
    $ECHO "File $TESTEXISTS not found or unreadable"
    exit 3
  fi
fi
#
# If command line error
#
if [ "$cmdline_error" = "1" ];then
  $ECHO "Invalid command line, $cmdlinestr"
  $ECHO "Usage:"
  $ECHO "install_intro text_notice_file"
  exit 1
fi
#
# Display the notice file
#
cat $NOTICEFILE
#
# Make sure the installer agrees to the licensing terms
#
answer=hoho
while [ "$answer" != "q" -a "$answer" != "no" -a "$answer" != "yes" ]
do
  $ECHO "Do you accept the license? (q=quit to read license, yes, no): \c"
  read answer
  if [ "$answer" = "q" ];then
    $ECHO "Installation terminated at user request"
    exit 99
  elif [ "$answer" = "yes" ];then
    $ECHO "License accepted by user"
  elif [ "$answer" = "no" ];then
    $ECHO "License not accepted by user - installation terminated"
    exit 99
  else
   $ECHO "You must answer \"yes\", \"no\" or (q)uit"
  fi
done
exit 0