@echo off

rem ********************************************************************************
rem *
rem * COMPATCK.BAT
rem *
rem * This file checks that the machine type is supported by the supplied set of
rem * device drivers.
rem *
rem * This batch file is called by the ckvars.bat.
rem *
rem ********************************************************************************


rem ********************************************************************************
rem * Does the Machine Type exist in the list?
rem ********************************************************************************
CLIni %DSET_PATH%\DrvSet.ini /S:Main /I:Supported Systems /CT:%MachType%
    
if errorlevel 100 goto INVALSYS
if errorlevel 1 goto ERR_CLI
if errorlevel 0 goto VALIDSYS


:VALIDSYS
rem ********************************************************************************
rem * The device drivers are supported on this system.
rem ********************************************************************************
REM Message will be displayed by ckvars.bat, if it makes it through all its checks.
REM echo The machine type of %MachType% is supported by this set of device drivers.

if %DPLY_TYPE%==4 goto ALTSTAT0

goto END


:INVALSYS
rem ********************************************************************************
rem * The device drivers are NOT supported on this system.
rem ********************************************************************************
rem Clear the screen and display the Toolkit header
call stkhder.bat

set MSG1=The machine type of %MachType% is NOT supported by the supplied 
set MSG2=set of device drivers.
set MSG3=Verify the supplied set of device drivers supports the target 
set MSG4=machine and that the machine type for the target machine is 
set MSG5=set correctly in F1 - Configuration/Setup.

echo.
echo %MSG1%
echo %MSG2%
echo.
echo %MSG3%
echo %MSG4%
echo %MSG5%
echo.

if not %DPLY_TYPE%==4 goto ERROR
%TKDRV%\logevent.exe -c:2 -l:2 -ss:"COMPATCK:  %MSG1%"
%TKDRV%\logevent.exe -c:2 -l:2 -ss:"COMPATCK:  %MSG2%"
%TKDRV%\logevent.exe -c:2 -l:2 -ss:"COMPATCK:  %MSG3%"
%TKDRV%\logevent.exe -c:2 -l:2 -ss:"COMPATCK:  %MSG4%"
%TKDRV%\logevent.exe -c:2 -l:2 -ss:"COMPATCK:  %MSG5%"
goto ERROR


:ERR_CLI
rem ********************************************************************************
rem * CLIni program error.
rem ********************************************************************************
rem Clear the screen and display the Toolkit header
call stkhder.bat

set MSG1=Had a problem determining if the machine type of %MACHTYPE% is 
set MSG2=supported by the supplied set of device drivers.  A program 
set MSG3=error occurred while running clini.exe

echo.
echo %MSG1%
echo %MSG2%
echo %MSG3%
echo.

if not %DPLY_TYPE%==4 goto ERROR
%TKDRV%\logevent.exe -c:2 -l:2 -ss:"COMPATCK:  %MSG1%"
%TKDRV%\logevent.exe -c:2 -l:2 -ss:"COMPATCK:  %MSG2%"
%TKDRV%\logevent.exe -c:2 -l:2 -ss:"COMPATCK:  %MSG3%"
goto ERROR


:ERROR
rem ********************************************************************************
rem * Hit an error in this batch file.
rem ********************************************************************************
echo Encountered an error and stopped processing in "compatck.bat".

savestat.exe /set2=251 > nul

if %DPLY_TYPE%==4 goto ALTSTAT1

goto END


:ALTSTAT0
rem ********************************************************************************
rem * Update Altiris with necessary status
rem ********************************************************************************
echo Updating Altiris status: Good

%TKDRV%\logevent.exe -c:0 -l:1 -ss:"COMPATCK: Completed successfully."

rem Reset to root of Toolkit drive
%TKDRV%
cd \

goto END



:ALTSTAT1
rem ********************************************************************************
rem * Update Altiris with necessary status
rem ********************************************************************************
echo Updating Altiris status: Error
%TKDRV%\logevent.exe -c:251 -l:3 -ss:"COMPATCK:  Encountered an error."

rem Reset to root of Toolkit drive
%TKDRV%
cd \

goto END


:END
set MSG1=
set MSG2=
set MSG3=
set MSG4=
set MSG5=
