
# Filename: hwcfg
# 	Generate hardware configuration information
#
# Usage:
#	hwcfg -c num_cabinets [ -h hw_cfg_file ]
#
#	hw_cfg_file - 	ascii file containing h/w config info excluding
#			i/o devices
#
#	Default file = /u/paragon/boot/hwconfig.txt
#	
##############################################################################
#
#        INTEL CORPORATION PROPRIETARY INFORMATION
#
#  This software is supplied under the terms of a license
#  agreement or nondisclosure agreement with Intel Corporation
#  and may not be copied or disclosed except in accordance
#  with the terms of that agreement.
#
##############################################################################
#
# What string:
#
# @(#) hwcfg DIAG_REL_2.0 Thu Jan  5 12:04:09 PST 1995
#
##############################################################################
#
# Modification History:
#
# $Log: hwcfg,v $
# Revision 1.5  1995/01/05  20:05:28  chowell
# chowell - added version string to the file
#
# Revision 1.4  1993/10/08  18:35:17  mouli
# -c (to specify number of cabs) is an optional argument so that
# on systems that have down-rev powercontrol board will still work.
#
# Revision 1.3  1993/07/08  18:32:20  mouli
# Added -q (to suppress warning messages) and -p to specify the
# directory path of the gencfg utility.
#
# Revision 1.2  1993/06/23  21:32:07  mouli
# Added utility path variable.
#
# Revision 1.1  1993/03/24  01:22:53  mouli
# Initial revision
#
#
p=$0
#default paths
def_cfg="/usr/paragon/boot/HWCONFIG.TXT"
def_upat=/u/paragon/diag
quiet=""
# Utility path
upat=${def_upat}
hwcfg=${def_cfg}
usage()
{
	echo "usage: $0 [-c num_cabinets] [ -h hw_cfg_file -p path_to_util -q]"
	echo "		OR"
	echo "       $0 -u to get this usage message"
	echo 
	echo "num_cabinets is the total number of cabinets, no default"
	echo "hw_cfg_file  is the output hardware configuration file"
	echo "             default hw_cfg_file = ${def_cfg}"
	echo "path_to_util is the directory where gencfg utility resides"
	echo "             default path_to_util = ${def_upat}"
	echo "specifying -q option will suppress warning messages"
	echo
	exit
}

#
# Process and validate arguments 
set - - `getopt h:c:p:qu $*`
if [ $? != 0 ] ; then
	usage
fi
for i in $*
do
       case $i in
		-h)
			hwcfg=$3; shift; shift;;
		-c)
			cab=$3; shift; shift;;
		-p)
			upat=$3; shift; shift;;
		-q)
			quiet=$2; shift;;
		-u)
			usage;;
	       --)      
			shift;    break;;
       esac
done
if [ -f ! ${upat}/gencfg ] ; then
	echo "${p}: ${upat}/gencfg does not exist to generate h/w config file"
	exit 1
fi
if [ -f "${hwcfg}" ] ; then
	echo "${p}: ${hwcfg} exists, overwrite it ? \c"
	read rsp
	case ${rsp} in
		[Yy]*)
			;;
		*)
			echo "${hwcfg} not overwritten, exiting"
			exit
			;;
	esac
fi
if [ "$cab" != "" ]
then
	${upat}/gencfg -f /dev/scan ${quiet} -c ${cab} > ${hwcfg}
else
	${upat}/gencfg -f /dev/scan ${quiet} > ${hwcfg}
fi
