#!/bin/sh
# 
# Copyright (c) 1994, Sun Microsystems, Inc.
#     All Rights Reserved
#
#
# request script - check to see if volmgt needs to be changed
#
#	@(#)request	1.2	26 Oct 1994


FILE_CHECK=/etc/.vold.wabi


NAWK=/usr/bin/nawk
GREP=/usr/bin/grep
CAT=/bin/cat
ECHO=/bin/echo
UNAME=/usr/bin/uname
PS=/usr/bin/ps
CKYORN=/usr/bin/ckyorn
SH=/usr/bin/sh

change_volmgt()
{
	#
	# change_volmgt() -
	#	check to see if /etc/vold.conf should change.
	#	return FALSE if there is no reason to change (e.g., no volmgt 
	#	    running)
	#	return TRUE if we should ask user to change
	#


	#
	# if this is already fixed, don't even continue
	#
		
	if [ -f $FILE_CHECK ]
	then
		$ECHO FALSE
		return
	fi	

	#
	# Define system BASEDIR
	#

	SYSBASEDIR=`echo ${BASEDIR} | awk -F// '{ print $2 }'`
	if [ "$SYSBASEDIR" = "a" ]
	then
	     SYSBASEDIR="/a"
	else
	     SYSBASEDIR=""
	fi


	#
	# only change 5.4 systems (should we do this?)
	#

	if [ "`$UNAME -r`" != "5.4" ]
	then
		$ECHO FALSE
		return
	fi

	#
	# only do this is they have a floppy
	#

	if [ ! -c /dev/rdiskette ]
	then
		$ECHO FALSE
		return
	fi

	# 
	# get the PID for vold
	#

	PID=`$PS -ef | $GREP /usr/sbin/vold | $GREP -v $GREP | $NAWK '{ print $2 }'`

	#
	# look to see if line exists in /etc/vold.conf
	#

	$CAT $SYSBASEDIR/etc/vold.conf | $NAWK '
	    BEGIN { FOUND = 0 } 
	    {
	    	if(($1 == "use") && ($2 == "floppy") && ($3 == "drive")) 
		    FOUND = 1
	    }
	    END { 
		exit (FOUND == 1)
	    } 
	'
	RET="$?"

	if [ "$RET" = "1" ]
	then
		$ECHO TRUE	# if we have found the line to change
	else
		$ECHO FALSE
	fi
}

# main

if [ "`$UNAME -r`" != "5.4" ]
then
	$ECHO ""
	$ECHO ""
	$ECHO ""
        $ECHO "*************************************************"
        $ECHO "*                                               *"
        $ECHO "*  THIS SOFTWARE WILL ONLY WORK ON SOLARIS 2.4  *"
        $ECHO "*                                               *"
        $ECHO "*    To obtain a copy for other versions of     *"
        $ECHO "*    Solaris, please contact your local Sun     *"
        $ECHO "*                 Representative                *"
        $ECHO "*                                               *"
        $ECHO "*************************************************"
        $ECHO ""
        $ECHO ""
        $ECHO ""
        exit 1
fi

# display the Ts and Cs

$ECHO 
(
echo "                         IMPORTANT NOTICE"
echo ""
echo "SUNSOFT IS WILLING TO LICENSE THE SOFTWARE TO YOU ONLY UPON THE"
echo "CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE"
echo "AGREEMENT.  READ THE TERMS AND CONDITIONS OF THIS LICENSE CAREFULLY"
echo "BEFORE DOWNLOADING THE SOFTWARE PACKAGE.  BY DOWNLOADING THE SOFTWARE"
echo "PACKAGE, YOU AGREE TO TO THE TERMS AND CONDITIONS OF THIS AGREEMENT."
echo "IF YOU ARE NOT WILLING TO BE BOUND BY THIS AGREEMENT, DO NOT CONTINUE."
echo ""
echo ""
echo "1. LICENSE TO USE.  Customer is granted a non-exclusive and"
echo "non-transferable license ("License") for the use of the Wabi 2.0"
echo "software in machine-readable form, together with accompanying"
echo "documentation ("Software") for each end-user license for Solaris"
echo "2.4 software."
echo ""
echo "2. LICENSE TO DEVELOP.  In the event that Customer desires to develop"
echo "software programs which incorporate portions of Software ("Developed"
echo "Programs"), the following provisions apply, to the extent applicable:"
echo "Developed Programs are to be OPEN LOOK(c) compliant and have an"
echo "application programming interface that is the same as that of Software;"
echo "fonts within Software are to remain associated with their toolkit or"
echo "server; Developed Programs may be used and distributed, but only on"
echo "computer equipment licensed to utilize Solaris operating system"
echo "software, unless an additional Developer's License Agreement has been"
echo "executed by SunSoft and Customer; Customer is not licensed to develop"
echo "print applications or print using fonts in F3(tm) format, unless"
echo "Customer has secured a license for NeWSprint(tm); and Customer"
echo "agreement to indemnify, hold harmless and defend SunSoft from and"
echo "against any claims or suits, including attorneys' fees, which arise or"
echo "result from distribution or use of Developed Programs."
echo ""
echo "3. RESTRICTIONS.  This License is effective for 60 days unless it is"
echo "terminated earlier.  Software is copyrighted and title to all copies is"
echo "retained by SunSoft and/or its licensors.  Customer shall not make"
echo "copies of Software, other than a single copy of Software for archival"
echo "purposed and, if applicable, Customer may, for its internal use only,"
echo "print the number of copies of on-line documentation for which the"
echo "applicable feed has been paid, in which event all proprietary right"
echo "notices on Software shall be reproduced and applied.  Except as"
echo "specifically authorized in Paragraph 2 above, Customer shall not"
echo "modify, decompile, disassemble, decrypt, extract, or otherwise reverse"
echo "engineer Software.  Software is not designed or licensed for use in"
echo "on-line control equipment in hazardous environments such as operation"
echo "of nuclear facilities, aircraft navigation or control, or direct life"
echo "support machines."
echo ""
echo "4. CONFIDENTIALITY.  Software is confidential and proprietary"
echo "information of SunSoft and/or its licensors.  Customer agrees to take"
echo "adequate steps to protect Software from unauthorized disclosure or"
echo "use."
echo ""
echo "5. DISCLAIMER OF WARRANTY.  SOFTWARE IS PROVIDED AS IS.  ALL EXPRESS" 
echo "OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY"
echo "IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,"
echo "OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED."
echo ""
echo "6. LIMITATION OF LIABILITY.  IN NO EVENT WILL SUNSOFT BE LIABLE FOR ANY"
echo "LOST REVENUE, PROFIT OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL,"
echo "INCIDENTAL OR PUNITIVE DAMAGES HOWEVER CAUSED AND REGARDLESS OF THEORY"
echo "OF LIABILITY ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,"
echo "EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.  In no"
echo "event shall SunSoft's liability to Customer, whether in contract, tort"
echo "(including negligence), or otherwise, exceed the license fee charged by"
echo "SunSoft for Software."
echo ""
echo "7. TERMINATION.  This License is effective until terminated.  Customer"
echo "may terminate this License at any time by destroying all copies of"
echo "Software including any documentation.  This License will terminate"
echo "immediately without notice from SunSoft if Customer fails to comply"
echo "with any provision of this License.  Upon termination, Customer must"
echo "destroy all copies of Software."
echo ""
echo "8. EXPORT REGULATION Software, including technical data, is subject to"
echo "U.S. export control laws, including the U.S. Export Administration Act"
echo "and its associated regulations, and may be subject to export or import"
echo "regulations in other countries.  Customer agrees to comply strictly"
echo "with all such regulations and acknowledges that it has the"
echo "responsibility to obtain licenses to export, re-export, or import"
echo "Software."
echo ""
echo "9. U.S. GOVERNMENT RESTRICTED RIGHTS.  If Customer is acquiring"
echo "Software including accompanying documentation on behalf of the U.S."
echo "Government, the following provisions apply.  If Software is supplied to"
echo "the Department of Defense ("DOD"), Software is subject to "Restricted"
echo "Rights", as that term is defined in the DOD Supplement to the Federal"
echo "Acquisition Regulations ("DFAR") in paragraph 252.227-7013(c) (1).  If"
echo "Software is supplied to any unit or agency of the United States"
echo "Government other than DOD, the Government's rights in Software will be"
echo "as defined in paragraph 52.227-19(c) (2) of the Federal Acquisition"
echo "Regulations ("FAR").  Use, duplication, reproduction or disclosure by"
echo "the Government is subject to such restrictions or successor"
echo "provisions.  Contractor/Manufacturer is: SunSoft, Inc., 2550 Garcia"
echo "Ave, Mountain View, CA 94043."
echo ""
echo "10. GOVERNING LAW.  This Agreement is made under, shall be governed by"
echo "and construed in accordance with the laws of the State of California,"
echo "U.S.A, excluding its choice of law provisions."
echo ""
echo "11. INTEGRATION.  This Agreement is the entire agreement between"
echo "Customer and SunSoft relating to Software and: (i) supersedes all prior"
echo "or contemporaneous oral or written communications, proposals and"
echo "representations with respect to its subject matter; and (ii) prevails"
echo "over any conflicting or additions terms or any quote, order,"
echo "acknowledgement, or similar communication between the parties during"
echo "the term of this Agreement.  No modification to the Agreement will be"
echo "binding, unless in writing and signed by a duly authorized"
echo "prepresentative of each party."
echo ""
echo ""
echo "The Software contained herein is licensed to you under the terms of a"
echo "License Agreement stated above.  Please read it.  By downloading this"
echo "software you are accepting and agreeing to such terms.  If you do not"
echo "accept these terms do not download this software."
echo ""
echo ""
)|more 2</dev/tty >/dev/tty

ANS=`$CKYORN -d n -p "Do you accept these terms and conditions? "`||exit 3
case $ANS in 
    y* | Y* )
	break;;
   *)
	exit 3;;
esac

RET="`change_volmgt`"
if [ "$RET" = "TRUE" ]
then
	$ECHO
	$ECHO
	$ECHO "To use your diskette drive under Wabi, we recommend that you"
	$ECHO "disable Volume Manager's control of the diskette drive."
	$ECHO
	$ECHO "Would you like this done now?\c"
	ANS=`$CKYORN -d y -d "change /etc/vold.conf"`||exit 3
	case $ANS in 
	    q* | Q* )
		exit 3;;
	    y* | Y* )
		FIX_FLOPPY=TRUE;
		break;;
	    *)
		$ECHO
		$ECHO "If you need to use your diskette drive with Wabi, you can always"
		$ECHO "disable Volume Manager's control of the drive later. To do this,"
		$ECHO "enter the following command as superuser:"
		$ECHO "	$BASEDIR/SUNWwabi/bin/vold.switch -disable"
		$ECHO
		$ECHO "See the Wabi 2.0 Release Notes for more detailed information."
		$ECHO
		FIX_FLOPPY=FALSE;
		break;;
 	esac
	$ECHO
fi

cat >$1 <<!
FIX_FLOPPY='$FIX_FLOPPY'
!

exit 0
