@echo off rem rem Copyright (c) 2018, 2019 SAS Institute Inc, Cary, NC, USA, All Rights Reserved rem rem This script copies updated hotfix files from SASHome to the correct target rem directories in the designated LevNN subtree. rem rem Version 1.1 rem Renamed script rem Copy logCentralize.groovy also rem rem Version 1.2 rem Changed SASHome sanity check, removed cp plugins to agent rem set SASEVMGRVER=2.3 set MYNAME=%0 rem Main execution path rem collect the arguments set excessargs="" set doit=false rem set some defaults set homedir="C:\Program Files\SASHome" set levn=C:\SAS\Config\Lev1 rem parse command line args :parseargs if -%1-==-- goto parseargsend rem batch command stupidity - shift doesn't wotk inside parens so we have to rem branch around sections as opposed to using them within if blocks :checkhome1 if not "%1"=="--home" goto checkhome2 shift set homedir=%1 shift goto parseargs :checkhome2 if not "%1"=="-home" goto checklevn1 shift set homedir=%1 shift echo myhomedir is %homedir% goto parseargs :checklevn1 if not "%1"=="--levn" goto checklevn2 shift set levn=%1 shift goto parseargs :checklevn2 if not "%1"=="-levn" goto checkdoit1 shift set levn=%1 shift goto parseargs :checkdoit1 if not "%1"=="--doit" goto checkdoit2 set doit=true shift goto parseargs :checkdoit2 if not "%1"=="-doit" goto unknownopt set doit=true shift goto parseargs :unknownopt rem if we don't recognize argument as expected opt, explain and bail out echo Unknown option specified: %1 call :usage exit/b 1 :parseargsend echo. echo homedir is %homedir% echo levn is %levn% echo. rem Minor sanity checking rem does this look like a real SASHome? if not exist %homedir%\SASEnvironmentManagerAgent ( echo Fatal, this does not appear to be a valid SASHome directory: echo. echo %homedir% echo. echo A subdirectory we expect to exist there was not found. exit/b 2 ) rem does this look like a real LevNN? if not exist %levn%\level_env.bat ( echo Fatal, this does not appear to be a valid LevNN directory: echo. echo %levn% echo. echo A script that we expect to exist there was not found. exit/b 3 ) rem rem some of these copy operations only apply to the emi-framework host, so check for that rem set is_framework=false set is_client=false set is_hqserver=false set is_hqagent=false if exist %levn%\Web\SASEnvironmentManager\emi-framework ( set is_framework=true echo emi-framework detected ) if exist %levn%\Web\SASEnvironmentManager\emi-client ( set is_client=true echo emi-client detected ) if exist %levn%\Web\SASEnvironmentManager\server-5.8.0-EE ( set is_hqserver=true echo hq-server detected ) if exist %levn%\Web\SASEnvironmentManager\agent-5.8.0-EE ( set is_hqagent=true echo hq-agent detected ) set missing=0 if %is_framework%==true ( echo. echo Checking emi-framework sources if not exist %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\classes\NetworkUtil.groovy set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\classes\Validator.groovy set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\classes\HQApiUtil.groovy set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\SASMacros\loadappcfg.sas set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\SASMacros\logarmanalyzer.sas set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\masterACMETL.groovy set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\masterAPMETL.groovy set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\logCentralize.groovy set/a missing+=1 ) if %is_client%==true ( echo. echo Checking emi-client sources if not exist %homedir%\SASEnvironmentManagerLogFileCollector\%SASEVMGRVER%\emi_client\Scripts\classes\NetworkUtil.groovy set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerLogFileCollector\%SASEVMGRVER%\emi_client\Scripts\classes\HQApiUtil.groovy set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerLogFileCollector\%SASEVMGRVER%\emi_client\Scripts\configureAPM.groovy set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerLogFileCollector\%SASEVMGRVER%\emi_client\Scripts\logDiscovery.groovy set/a missing+=1 ) if %is_hqserver%==true ( echo. echo Checking JAR sources if not exist %homedir%\SASEnvironmentManagerEnablementKitPlugin\%SASEVMGRVER%\emi-framework-plugin.jar set/a missing+=1 if not exist %homedir%\SASEnvironmentManagerEnablementKitPlugin\%SASEVMGRVER%\sas-deploy-agent-plugin.jar set/a missing+=1 ) if %missing% gtr 0 ( echo. echo Fatal, %missing% of the expected input files were not found. Giving up. exit/b 4 ) rem ### rem copy (or NO-OP echo) files rem ### if not %doit%==true ( echo. echo Showing copy commands that would be executed if you specify the '-doit' option. ) if %is_framework%==true ( echo. echo Copying framework files. call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\classes\NetworkUtil.groovy ^ %levn%\Web\SASEnvironmentManager\emi-framework\Scripts\classes\NetworkUtil.groovy call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\classes\Validator.groovy ^ %levn%\Web\SASEnvironmentManager\emi-framework\Scripts\classes\Validator.groovy call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\classes\HQApiUtil.groovy ^ %levn%\Web\SASEnvironmentManager\emi-framework\Scripts\classes\HQApiUtil.groovy call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\SASMacros\loadappcfg.sas ^ %levn%\Web\SASEnvironmentManager\emi-framework\SASMacros\loadappcfg.sas call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\SASMacros\logarmanalyzer.sas ^ %levn%\Web\SASEnvironmentManager\emi-framework\SASMacros\logarmanalyzer.sas call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\masterACMETL.groovy ^ %levn%\Web\SASEnvironmentManager\emi-framework\Scripts\masterACMETL.groovy call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\masterAPMETL.groovy ^ %levn%\Web\SASEnvironmentManager\emi-framework\Scripts\masterAPMETL.groovy call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitServer\%SASEVMGRVER%\core\Scripts\logCentralize.groovy ^ %levn%\Web\SASEnvironmentManager\emi-framework\Scripts\logCentralize.groovy ) if %is_client%==true ( echo. echo Copying client files. call :copysrc %doit% %homedir%\SASEnvironmentManagerLogFileCollector\%SASEVMGRVER%\emi_client\Scripts\classes\NetworkUtil.groovy ^ %levn%\Web\SASEnvironmentManager\emi-client\Scripts\classes\NetworkUtil.groovy call :copysrc %doit% %homedir%\SASEnvironmentManagerLogFileCollector\%SASEVMGRVER%\emi_client\Scripts\classes\HQApiUtil.groovy ^ %levn%\Web\SASEnvironmentManager\emi-client\Scripts\classes\HQApiUtil.groovy call :copysrc %doit% %homedir%\SASEnvironmentManagerLogFileCollector\%SASEVMGRVER%\emi_client\Scripts\configureAPM.groovy ^ %levn%\Web\SASEnvironmentManager\emi-client\Scripts\configureAPM.groovy call :copysrc %doit% %homedir%\SASEnvironmentManagerLogFileCollector\%SASEVMGRVER%\emi_client\Scripts\logDiscovery.groovy ^ %levn%\Web\SASEnvironmentManager\emi-client\Scripts\logDiscovery.groovy ) if %is_hqserver%==true ( echo. echo Copying JAR files. call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitPlugin\%SASEVMGRVER%\emi-framework-plugin.jar ^ %levn%\Web\SASEnvironmentManager\server-5.8.0-EE\hq-engine\hq-server\webapps\ROOT\WEB-INF\hq-plugins\emi-framework-plugin.jar call :copysrc %doit% %homedir%\SASEnvironmentManagerEnablementKitPlugin\%SASEVMGRVER%\sas-deploy-agent-plugin.jar ^ %levn%\Web\SASEnvironmentManager\server-5.8.0-EE\hq-engine\hq-server\webapps\ROOT\WEB-INF\hq-plugins\sas-deploy-agent-plugin.jar ) if not %doit%==true ( echo. echo To execute these commands, rerun this command adding the '-doit' option. ) exit/b 0 rem Function definitions rem copysrc - conditionally copies files rem rem if $1 is "true", copy $2 to $3 rem rem :copysrc setlocal set _rc=0 if %1==true ( copy/y %2 %3 set _rc=%ERRORLEVEL% if %_rc% neq 0 ( echo Copy command failed, return code=%_rc% echo THIS FAILED copy/y %2 %3 ) ) else ( echo copy/y %2 %3 ) endlocal goto :eof :usage setlocal echo . echo . echo This script copies updated SAS hotfix files from the designated SASHome directory tree echo to the target configuration directories in the specified LevNN subtree. echo. echo You must run this command as the Admin user. echo. echo %MYNAME% [-doit] [-home yourSASHomeDir] [-levn yourConfigLevNDir] echo. echo -doit By default, the script shows what files it will copy WITHOUT executing echo the actual copy commands so that you can verify the expected actions. echo The -doit option says to execute the copy commands. echo. echo -home Specify the full path of your SASHome directory, quoting the path echo if it contains spaces or other special characters, for example, echo if unspecified, the default is: echo -home "C:\Program Files\SASHome" echo. echo -levn Specify the full path of your Config\LevNN directory, quoting the echo path if it contains spaces or other special characters, for example, echo if unspecified, the default is: echo -levn C:\SAS\Config\Lev1 echo. endlocal goto :eof