:
#
# aodmkset (Online Diagnostics)
#


# check for superuser id

if [ `logname` != "root" ]
then
	echo "Must be super-user to execute aodsetdef script"
	exit 2
fi

################################################################################

#define file equates to shorten shell script lines, if not already defined
if [ ! "$tfile" ]
then
	tfile=/usr/lib/err.thresh
fi

# first check if thresholds settings file exists
if [ -f $tfile ]
then
	# thresholds file DOES exist; can't create default over existing file
	echo "Thresholds settings file already exists; cannot create default"
	exit 3
fi

################################################################################

# the thresholds settings file doesn't exist, create default values.
if [ "$HEADINGS" ]
then
	echo
	echo "No existing threshold settings file; loading default values...\c"
fi
# preset simple defaults

for device in hd fd tp mdc sio krn mis
do
	eval fieldlist=$"$device""fields"
	for fieldtype in $fieldlist
	do
		eval fieldname=$""$device"val"$fieldtype""
		eval "$device""$fieldname"=20
		eval "$device""$fieldname"ACT=N
	done
done

if [ "$HEADINGS" ]
then
	echo "done"
	echo "Saving error detection thresholds file...\c"
fi

for device in hd fd tp mdc sio krn mis
do
	eval fieldlist=$"$device""fields"
	for fieldtype in $fieldlist
	do
		eval fieldname=$""$device"val"$fieldtype""
		eval echo "$device""$fieldname" $""$device""$fieldname"" $""$device""$fieldname"ACT" >> /usr/lib/err.thresh
	done
done
if [ "$HEADINGS" ]
then
	echo "done"
	echo
fi
