#! /sbin/sh
####################################################################
#	$Id: configure,v 1.5 2001/10/01 21:24:36 kurte Exp $
# 	Copyright (c) Digi, Digi International Inc.
#
#	Configuration script for Digi AccelePort Driver.
#	Copyright (c) 1988-98 Digi International Inc.
#
#	For HP-UX 10.X & 11.X
#
#	NOTE: It is expected that the swinstall program will call this
#             script after the postinstall has executed, or at the
#             direction of the user via "swconfig".
#				
####################################################################

PATH=$SW_PATH
export PATH

#
# ONLY manipulate the /stand/system file and the gettydefs if we
# were deferred.
#
# Also copy the operating system version specific files to the
# appropriate locations if necessary.
#
if [[ "x${SW_DEFERRED_KERNBLD}x" != "xx" ]]
then
	#
	# Manipulate the /stand/system file.
	#
	if [[ ! -f $SW_SYSTEM_FILE_PATH ]]
	then
		echo "ERROR:   Couldn't find the system file."
		exit 1
	fi

	cat $SW_SYSTEM_FILE_PATH | \
		awk '( $0 != "dgdxb" ) { print $0 }' | \
		awk '/^[^*]/ && zz==0 { zz=1 ; print "dgdxb" } { print $0 }' > \
		${SW_SYSTEM_FILE_PATH}.new.tmp.digi

	if [[ ! -f ${SW_SYSTEM_FILE_PATH}.new.tmp.digi ]]
	then
		echo "ERROR:   Couldn't create new system file."
		exit 1
	fi

	cp ${SW_SYSTEM_FILE_PATH}.new.tmp.digi ${SW_SYSTEM_FILE_PATH}
	if [[ $? -ne 0 ]]
	then
		echo "ERROR:   Couldn't replace system file."
		exit 1
	fi

	rm -f ${SW_SYSTEM_FILE_PATH}.new.tmp.digi

	#
	# Update the "gettydefs" file (to remove IXANY)
	#
	if	[ \! -f /etc/gettydefs.ixany ] &&
		grep ' IXANY ' /etc/gettydefs >/dev/null &&
		sed -e 's/ IXANY / /g' /etc/gettydefs >/etc/gettydefs.digi
	then
		mv /etc/gettydefs /etc/gettydefs.ixany
		mv /etc/gettydefs.digi /etc/gettydefs

		echo "The file /etc/gettydefs was edited to remove IXANY references."
		echo "The original /etc/gettydefs is saved in /etc/gettydefs.ixany."
	fi

	#
	# Copy OS version specific files to the appropriate places
	# I do very little sanity checking here, as the appropriate
	# checking should already have taken place in "checkinstall".
	#
	majrev=`uname -r | cut -f 2 -d '.'`
	minrev=`uname -r | cut -d '.' -f 3`
	numbits=`getconf KERNEL_BITS 2>&1`
	if [ $? -ne 0 ] ;then numbits=32 ;fi

	case ${majrev} in
		10)
			revstring="10.20"
			;;
		11)
			if [ ${minrev} -le 10 ] ; then
				case ${numbits} in
					32)
						revstring="11.00"
						;;
					64)
						revstring="11.00W"
						;;
					*)
						echo "MAJOR ERROR!  Unexpected" \
						     "number of bits ({numbits})"
						exit 1
						;;
				esac
				;;
			else

				case ${numbits} in
					32)
						revstring="11.11"
						;;
					64)
						revstring="11.11W"
						;;
					*)
						echo "MAJOR ERROR!  Unexpected" \
						     "number of bits ({numbits})"
						exit 1
						;;
				esac
				;;
			fi
		*)
			echo "MAJOR ERROR!  Couldn't find files for this" \
			     "revision of the operating system!"
			exit 1
			;;
	esac

	cp /etc/conf/digi/${revstring}/dgdxb.a	/usr/conf/lib/dgdxb.a
fi

exit 0
