#! /bin/sh
# @(#)install_showrev.sh	1.5 91/09/14 install_showrev 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 showrev install script.
#
# This script must be run as superuser
#

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

OPENWINVERSION_FILE=etc/NeWS/init.ps
TOOLTALKVERSION_PROG='bin/ttsession -v'

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 rerun this script.'
	exit 1
fi

if [ ! -d "$OPENWINHOME/etc/NeWS" ]
then
	echo 'Installation failed because the directory $OPENWINHOME/etc/NeWS'
	echo 'does not exist.'
	echo 'Please check $OPENWINHOME/etc/NeWS and rerun this script.'
	exit 1
fi

if [ ! -f "$OPENWINHOME/$OPENWINVERSION_FILE" ]
then
	echo 'Installation failed because the file $OPENWINHOME'/"$OPENWINVERSION_FILE"
	echo 'does not exist.'
	echo 'Please check $OPENWINHOME'/"$OPENWINVERSION_FILE"' and rerun this script.'
	exit 1
fi

if [ ! -d "/etc/install" ]
then
	echo 'Creating directory /etc/install.'
	mkdir /etc/install
	chmod 755 /etc/install
fi

echo "*************** Installing Openwindow Version Information"

if [ "" != "$LD_LIBRARY_PATH" ]
then
	LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$OPENWINHOME/lib"
else
	LD_LIBRARY_PATH="$OPENWINHOME/lib"
fi
export LD_LIBRARY_PATH

SED='s,.*/openwinversion *(\([0-9.]*.*\)) *def.*,OpenWindows: OW \1,p'

sed -n "$SED" "$OPENWINHOME/$OPENWINVERSION_FILE" > /etc/install/OWrelease
echo -n "ToolTalk "				 >> /etc/install/OWrelease
$OPENWINHOME/$TOOLTALKVERSION_PROG		 >> /etc/install/OWrelease

echo "*************** Done with Openwindows Version Information installation"

exit 0
