#!/bin/sh
#
#
#    Copyright (c) 1996-2006 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#
# 
# NAME
#      diagfaillimit - set diagnostics fail limit
# 
# SYNOPSIS
#      diagfaillimit [ limit | -show ]
# 
# AVAILABILITY
#      admin
# 
# DESCRIPTION
#      This  command  sets the diagnostics fail limit to the speci-
#      fied value.  The fail limit is saved  in  flash  memory  and
#      stays  set  until  the  next execution of diagfaillimit. The
#      mode becomes active as soon as this command is executed.  It
#      does not require a reboot to take effect.
# 
#      The  fail  limit  is  used to control the number of failures
#      before certain diagnostics test  methods  will  abort.   The
#      normal  setting  is  1  so  that the tests will abort on the
#      first failure.  The exact use of this configuration  setting
#      depends on the test method.
# 
# OPTIONS
#      limit     Specify  the number of failures before diagnostics
#                test methods abort. limit must be >= 1.
# 
#      -show     If specified or no limit is given,the current fail
#                limit will be displayed.
# 
# EXAMPLES
#      > diagfaillimit -show
#      Fail Limit is 1.
# 

echo "This command is no longer supported as of Fabric OS v6.2.0"
exit 3

#
# Load library -- must be first.
#
home="/fabos/share"
util="diagcommon.sh"
ok=0

if [ $# -eq 0 ]; then
	# Check RBAC permission on command
	/fabos/libexec/rbac_check `/bin/basename $0`
else
	# Check RBAC permission on identified options
	/fabos/libexec/rbac_check `/bin/basename $0` $1
fi

if [ $? -ne 0 ]; then
	exit 127
fi

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

#
# Program customization
#

config_string="diag.failLimit"	# config string to update
config_name="Fail Limit"	# User name of config.
config_default=1		# default value
config_mode=$INTEGER		# config mode

syntax="`/bin/basename $0` [ limit \| -show ]" ; export syntax

#
# diagfaillimit()
#
checkForShow "$config_name" "$config_string" "$config_mode" "$config_default" $1
val=`getValue $1`
if [ $? != 0 ] ; then exit 3 ; fi

if [ "$val" -lt 1 ] ; then
   err "Fail limit must be > 0"
   exit 3
fi

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