@echo off
rem ************************************************************************************
rem * Description: 	Captures RAID configuration for cloning purposes 
rem * Name: 		CAPRAID.BAT
rem * Dependencies:	PRAID.EXE, SETERRLV.EXE, SAVERC.BAT, TKOUT.BAT
rem * Parameters:	
rem *			%1 = Output filename for PRAID Policy file
rem * Return Code:
rem * 			0     = Success 
rem * 			>=1   = Error code defined by PRAID.exe
rem *
rem ************************************************************************************

rem ************************************************************************************
rem *** Initialize Return Code
rem ************************************************************************************
set RC=0

rem ************************************************************************************
rem *** Check Parameters
rem ************************************************************************************
if "%1" == "" goto PERROR


rem ************************************************************************************
rem *** Run RAID Configuration Utility
rem ************************************************************************************
PRAID /l /c /f:%1
if errorlevel 1 goto ERROR_1

rem * Check return code for MSDOS
call PRDERR.BAT

if %PRDERR% == 9 goto ERROR_2
if %PRDERR% == 8 goto ERROR_2
if %PRDERR% == 7 goto ERROR_2
if %PRDERR% == 6 goto ERROR_2
if %PRDERR% == 5 goto ERROR_2
if %PRDERR% == 4 goto ERROR_2
if %PRDERR% == 3 goto ERROR_2
if %PRDERR% == 2 goto ERROR_2
if %PRDERR% == 1 goto ERROR_2

goto RAIDGOOD


:PERROR
set MSG="Missing script parameter."
call TKOUT.BAT
set RC=1
goto ERROR

:ERROR_1
call saverc.bat
goto RAIDBAD

:ERROR_2
set RC=%PRDERR%
goto RAIDBAD

:RAIDBAD
set MSG="Capture RAID failed."
call TKOUT.BAT
goto ERROR

:RAIDGOOD
set MSG="Capture RAID succeeded."
call TKOUT.BAT
goto END

:ERROR
set MSG="Encountered an error and stopped processing in capraid.bat"
call TKOUT.BAT
goto END

:END
SET MSG=
SETERRLV %RC%
