#!/bin/sh

################################################################################
# This script runs first during the package installation process and is
# able to interact with the user. Currently it only requires the user to
# accept the EULA before continuing with installation.
#
# Available Variables:
#
# INST_DATADIR = parent directory of the package folder
# PKGINST      = package name
#
# Code42 Software Inc, Minneapolis, MN
# http://www.code42.com/
# 
# Copyright (c) 2008 Code42 Software, All Rights Reserved
################################################################################

echo ""
echo "Welcome to CrashPlan."
echo ""
echo "You must review and agree to the EULA before installation."
echo ""
echo "Press enter to read the EULA. "
read ENTER

# EULA Time
cat ${INST_DATADIR}/${PKGINST}/root/opt/sfw/crashplan/doc/EULA

# check for agreement
agreed=0
while [ "${agreed}" = "0" ] ; do
	echo ""
	echo "Do you accept and agree to be bound by the EULA? (yes/no) "
	read reply
	case ${reply} in
		[yY] | [yY][eE][sS])
			agreed=1
			;;
		[nN] | [nN][oO])
			echo ""
			echo "If you do not agree to the license then CrashPlan may not be installed. Exiting.";
			echo ""
			exit 1
			;;
	esac
done

exit 0
