#!/bin/sh
#
#
#    Copyright (c) 1996-2000 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#
# NAME
#      burninname - set the diagnostics burnin test name
# 
# SYNOPSIS
#      burninname [ name | -show ] [ slotno ]
# 
# AVAILABILITY
#      admin
# 
# DESCRIPTION
#      This command sets the name of the current burnin test.  This
#      value is used in messages to indicate which  test  was  run-
#      ning.
# 
#      The  mode becomes active as soon as this command is executed
#      so that It does not require a reboot to take effect.
# 
# OPTIONS
#      -show     The current burnin test name will be displayed.
# 
#      name      The burnin test name will be set to the  specified
#                string.
# 
#      slotno    Specify  which  slot  to  update  or show. If this
#                option is not specifed, the current slot  will  be
#                assumed. You can set the current slot by execution
#                of setslot command. To  use  this  option,  either
#                name, -show should be specified before.
# 
# EXAMPLES
#      > burninname -show 1
#      Slot 1 burnin name is switchess.sh.
# 
# SEE ALSO
#      burninlevel(1d), burninscript(1d) setslot(1d)
# 
# NOTES
#      This command may be removed in future releases.
# 

def_slot=0

#
#
# Load library -- must be first.
#
home="/fabos/share"
util="diagcommon.sh"
ok=0
for f in "./$util" "$FABOSHOME/share/$util" "$home/$util" ; do
	if [ -r $f ] ; then
		. $f
		ok=1
		break;
	fi
done
if [ $ok -ne 1 ] ; then
	echo "Error -- could not locate $util"
	exit 3
fi

#
# get sys info for multi blade
#
multiBlade=`isMultiBlade`

#
# Get slot number
#
x=`/usr/bin/expr "$2" : "\([0-9]\+\)"`
if [ -z $x ] ; then
    ans="`isValidSlot $FABOS_SLOTNO`"
    if [ "$ans" = TRUE ] ; then
       slot=$FABOS_SLOTNO
    else
       slot=$def_slot
    fi
else
      ans="`isValidSlot $x`"
      if [ "$ans" = TRUE ] ; then
         slot=$x
      else 
	  err "$x is an invalid slot number"
	  exit 4
      fi
fi

#
# Program customization
#

config_string="diag.mode.burnin.$slot.name" # config string to update
if [ $multiBlade = TRUE ]
then
    config_name="Slot $slot burnin name"	# User name of config.
    syntax="`/bin/basename $0` [ name \| -show ] [ slotno ]"
else
    config_name="burnin name"	# User name of config.
    syntax="`/bin/basename $0` [ name \| -show ]"
fi
config_default=""		# default value
config_mode=$STRING		# config mode


#
# burninname()
#
checkForShow "$config_name" "$config_string" "$config_mode" "$config_default" $1

cur_val=`getConfig $config_string $config_mode $config_default`
if [ "$cur_val" != "$1" ]
then
	setConfig $config_string $config_mode "$1"
	echo "$config_name is now $1."
	updateConfig
else
	echo "$config_name is still $1."
fi	
exit 0
