Rational Developer Silent Install doLicense.bat

From MidrangeWiki
Revision as of 16:59, 21 February 2018 by Mattt (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
@echo off
setlocal
set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set dt=%date:~10,4%%date:~4,2%%date:~7,2%_%hh%_%time:~3,2%_%time:~6,2%

echo =================================================================
echo Apply RDI License %dt%
echo =================================================================

:check_Permissions
    echo Administrative permissions required. Detecting permissions...

    net session >nul 2>&1
    if %errorLevel% neq 0 (
        echo Failure: This script needs to be run as Administrator.
		goto EXIT_1
    )

rem set USER_IM_FOLDER=%1
rem IF ERRORLEVEL 1 (
rem 	set USER_IM_FOLDER="C:\IBM\Installation Manager"
rem ) else if "%USER_IM_FOLDER%"=="" (
rem 	set USER_IM_FOLDER="C:\IBM\Installation Manager"
rem )

echo Checking Installation Manager
IF EXIST "C:\IBM\Installation Manager\eclipse\IBMIM.exe" (
  set USER_IM_FOLDER="C:\IBM\Installation Manager"
) else if EXIST "C:\Program Files\IBM\Installation Manager\eclipse\IBMIM.exe" (
  set USER_IM_FOLDER="C:\Program Files\IBM\Installation Manager"
) else (
  Echo Installation Manager Not Found. 
  echo Install Installation Manager.
  GOTO EXIT_1
)

set RDI_INSTALL_FOLDER=C:\Software\RationalDeveloper\RDI_V9.6
set RDI_REMOTE_FOLDER="\\<servername>\[download_folder]"
set RDI_PRODUCT_INSTALL=C:\IBM\SDP96
set RUN_LOG_FILE=%RDI_INSTALL_FOLDER%\license_log%dt%.xml

set CHOOSE_KIT=%1
IF ERRORLEVEL 1 (
	echo Using Kit 1
	set  RDI_LICENSE_KIT=%RDI_REMOTE_FOLDER%\applyLicense.xml
) else if "%CHOOSE_KIT%"=="1"  ( 
	echo Using Kit 1
	set  RDI_LICENSE_KIT=%RDI_REMOTE_FOLDER%\applyLicense.xml
) else if "%CHOOSE_KIT%"=="2"  ( 
	echo Using Kit 2
	set  RDI_LICENSE_KIT=%RDI_REMOTE_FOLDER%\applyLicense2.xml
) else (
	echo Using Kit 1
	set  RDI_LICENSE_KIT=%RDI_REMOTE_FOLDER%\applyLicense.xml
)

C:
IF NOT EXIST %RDI_INSTALL_FOLDER% (
	echo Folder not found: %RDI_INSTALL_FOLDER%
	goto EXIT_1
)
:HAVE_INSTALL_FOLDER
cd %RDI_INSTALL_FOLDER%

echo Using Remote Location: "%RDI_REMOTE_FOLDER%"
echo       Using IM Folder: "%USER_IM_FOLDER%"
echo  Using Install Folder: "%RDI_INSTALL_FOLDER%"


echo Checking: %RDI_INSTALL_FOLDER%\disk1
IF NOT EXIST %RDI_INSTALL_FOLDER%\disk1 (
  echo Folder not found! %RDI_INSTALL_FOLDER%\disk1
  goto EXIT_1
)
echo Found: %RDI_INSTALL_FOLDER%\disk1

echo Checking: %RDI_INSTALL_FOLDER%\disk2
IF NOT EXIST %RDI_INSTALL_FOLDER%\disk2 (
  echo Folder not found! %RDI_INSTALL_FOLDER%\disk2
  goto EXIT_1
)
echo Found: %RDI_INSTALL_FOLDER%\disk2

echo Running installation manager 

IF NOT EXIST %USER_IM_FOLDER%\eclipse\IBMIM.exe (
  echo Installation manager not found.
  echo %USER_IM_FOLDER%\eclipse\IBMIM.exe
  goto EXIT_1
)

rem %USER_IM_FOLDER%\eclipse\IBMIM.exe input %RDI_INSTALL_FOLDER%\applyLicense.xml -acceptLicense -silent -log %RUN_LOG_FILE%
%USER_IM_FOLDER%\eclipse\IBMIM.exe input %RDI_LICENSE_KIT% -acceptLicense -silent -log %RUN_LOG_FILE%
if %errorlevel% neq 0 (
  echo Installation manager failed. This script probably needs to be run as Administrator.
  IF EXIST %RUN_LOG_FILE% GOTO CHECK_ERROR_LOG
  goto EXIT_1
)


:CHECK_ERROR_LOG

echo Install Finished. Checking error log for errors.
rem Check If the error log contains anything other than the default warning.
:CHECK_IM_EMPTYLOG
FC /lb1 /0 %RDI_REMOTE_FOLDER%\im_install_log_empty.xml %RUN_LOG_FILE% >NUL 2>&1
if %errorlevel% eq 0 (
	del %RUN_LOG_FILE%
	echo =================================================================
	echo Install Complete %dt%. No Errors Found.
	echo =================================================================
	GOTO EXIT_0
)

:CHECK_WARNINGLOG
FC /lb1 /0 %RDI_REMOTE_FOLDER%\install_log_warningonly.xml %RUN_LOG_FILE% >NUL 2>&1
if %errorlevel% eq 0 (
	del %RUN_LOG_FILE%
	echo =================================================================
	echo Install Complete %dt%. No Errors Found.
	echo =================================================================
	GOTO EXIT_0
)

:CHECK_NOTMODIFIEDLOG
FC /lb1 /0 %RDI_REMOTE_FOLDER%\install_log_notmodified.xml %RUN_LOG_FILE% >NUL 2>&1
if %errorlevel% eq 0 (
	del %RUN_LOG_FILE%
	echo =================================================================
	echo Install Complete %dt%. No Errors Found.
	echo =================================================================
	GOTO EXIT_0
)

:HAVE_ERRORS_IN_LOG
echo =================================================================
echo Check Log for errors "%RUN_LOG_FILE%"
echo =================================================================
type %RUN_LOG_FILE%

:EXIT_1
echo ========================end======================================
pause
exit /b 1

:EXIT_0
echo ========================end======================================
pause
exit /b

License installation script XML, create as many copies of this for as many copies of license files you have.

<?xml version='1.0' encoding='UTF-8'?>
<agent-input>
  <variables>
    <variable name='sharedLocation' value='C:\IBM\SDPShared'/>
  </variables>
  <server>
    <repository location='\\gofs\Departments\Programming\Downloads\RDi RDp Editors\RDi 9.x\RDI_9.6\com.ibm.rational.developer.ibmi.rpgcobol.v96.pek.jar'/>
    <!-- <repository location='C:\Software\RationalDeveloper\RDI_V9.6\License\com.ibm.rational.developer.ibmi.rpgcobol.v96.pek.jar'/> -->
    <repository location='C:\Software\RationalDeveloper\RDI_V9.6'/>
  </server>
  <install>
    <!-- com.ibm.rational.developer.ibmi.rpgcobol.v96.pek.offering 9.0.1.20171002_1405 -->
    <offering id='com.ibm.rational.developer.ibmi.rpgcobol.v96.pek.offering' version='9.0.1.20171002_1405' features='main.feature'/>
  </install>
  <preference name='com.ibm.cic.common.core.preferences.eclipseCache' value='${sharedLocation}'/>
</agent-input>