#! /bin/sh
# @(#)install_openwin.sh	1.6 91/09/14 install_openwin SMI
#
#         Copyright (C) 1991  Sun Microsystems, Inc
#                   All rights reserved.
#           Notice of copyright on this source code
#           product does not indicate publication.
# 
# RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by 
# the U.S. Government is subject to restrictions as set forth 
# in subparagraph (c)(1)(ii) of the Rights in Technical Data
# and Computer Software Clause at DFARS 252.227-7013 (Oct. 1988) 
# and FAR 52.227-19 (c) (June 1987).
#
# Sun Microsystems, Inc.
# 2550 Garcia Avenue
# Mountain View, California 94043
#

#
# This is the OpenWindows master install script.
#
# This script installs OpenWindows on an end-user's machine, or a
# file server.  It assumes that OpenWindows has been loaded from cdrom
# and is mounted.  The environment variable OPENWINHOME must be set to
# the location of OpenWindows.
#
# This master script runs each of the individual install scripts.
# The individual scripts do things like update inetd.conf.
#
# This script must be run as superuser
#

PATH="/bin:/usr/ucb:/usr/bin:/etc"
export PATH

if [ "sun4" != `arch` ]
then
	echo "Installation failed - can only be run on sun4 systems."
	exit 1
fi

if [ "root" != `whoami` ]
then
	echo "Installation failed - must be run in super-user mode."
	exit 1
fi

if [ "" = "$OPENWINHOME" ]
then
	echo 'Installation failed because $OPENWINHOME is undefined.'
	echo 'Please set $OPENWINHOME and rerun this script.'
	exit 1
fi

if [ ! -d "$OPENWINHOME" ]
then
	echo 'Installation failed because $OPENWINHOME is set to'
	echo \""$OPENWINHOME"\" 'which is not a directory.'
	echo 'Please check $OPENWINHOME and and rerun this script.'
	exit 1
fi

if [ ! -x "$OPENWINHOME/bin/openwin" ]
then
	echo 'Installation failed because OpenWindows has not been properly'
	echo "installed into $OPENWINHOME"
	echo 'Please check this directory and $OPENWINHOME and and rerun'
	echo 'this script.'
	exit 1
fi

# Check with the user
while :
do
	echo ""
	echo The '$OPENWINHOME' "environment variable is set to '$OPENWINHOME'"
	echo -n 'Is this the copy of OpenWindows you want to install? [y|n] '
	read response
	case "$response" in
	y*)	break;;
	n*)	echo ""
		echo 'Please set $OPENWINHOME correctly and rerun this script'
		exit 1;;
	*)	echo ""
		echo 'Please answer "y" or "n"';;
	esac
done

PATH="$OPENWINHOME/bin:/bin:/usr/ucb:/usr/bin:/etc"
export PATH

# Now run each install script

echo "*************** Installing Calendar Manager"
echo
install_cmgr || echo "Calendar Manager install failed, continuing..."

echo "*************** Installing ToolTalk"
echo
install_tt || echo "ToolTalk install failed, continuing..."

echo "*************** Installing Modules"
echo
install_modules || echo "Modules install failed, continuing..."

echo "*************** Installing Version Identification"
echo
install_showrev || echo "Version identification install failed, continuing..."

echo
echo "*************** Done with Openwindows installation"

exit 0
