#!/bin/bash

#This script is wrapper for racadm4 and racadm3
#We just check the version of the rac on the system
#and execute the correct racadm.
#for DRAC 5 we configure using syscfg.
rac3=1028:0008
rac4=1028:0012
rac5=1028:

# Prepare arguments
args=''
while [ ! -z "$1" ]; do
	arg="$1"
	args="$args '$arg'"
	shift
done

#echo args: [$args]
test=""
test=`racadm6 getconfig -g idRacInfo -o idRacType 2> /dev/null`
errcode=$?
idractype=$test
if [ "$errcode" = "0" ]; then
if [ "$idractype" -gt 9 ];
then
	eval racadm6 $args
	exit $?
fi
fi

test=""
test=`syscfg | grep racreset`
if [ -n "$test" ]; then
	eval racadm5 $args
	exit $?
fi

test=""
test=`lspci -i $DT_TOOLS/pci.ids -d $rac3`
if [ -n "$test" ]; then
	eval racadm3 $args
	exit $?
fi

test=""
test=`lspci -i $DT_TOOLS/pci.ids -d $rac4`
if [ -n "$test" ]; then
	eval racadm4 $args
	exit $?
fi

echo "This system does not have a DRAC"
exit -1
