diff --git a/scriptbuilder/src/test/resources/client_rb.cmd b/scriptbuilder/src/test/resources/client_rb.cmd index 4f74c24cac..d7bd4e6ddf 100644 --- a/scriptbuilder/src/test/resources/client_rb.cmd +++ b/scriptbuilder/src/test/resources/client_rb.cmd @@ -1,3 +1,3 @@ -echo log_level :info>>c:\etc\chef\client.rb -echo log_location STDOUT>>c:\etc\chef\client.rb -echo chef_server_url "http://localhost:4000">>c:\etc\chef\client.rb +echo log_level :info>>c:\etc\chef\client.rb +echo log_location STDOUT>>c:\etc\chef\client.rb +echo chef_server_url "http://localhost:4000">>c:\etc\chef\client.rb diff --git a/scriptbuilder/src/test/resources/test_init.cmd b/scriptbuilder/src/test/resources/test_init.cmd index 283ea07881..f7cc2709c3 100644 --- a/scriptbuilder/src/test/resources/test_init.cmd +++ b/scriptbuilder/src/test/resources/test_init.cmd @@ -1,134 +1,134 @@ -@echo off -set PATH= -set JAVA_HOME= -set PATH= -GOTO FUNCTION_END -:abort - echo aborting: %EXCEPTION% - exit /b 1 -:default - set INSTANCE_NAME=mkebsboot -set INSTANCE_HOME=/mnt/tmp -set LOG_DIR=/mnt/tmp - exit /b 0 -:mkebsboot - set TMP_DIR=/mnt/tmp - exit /b 0 -:findPid - set FOUND_PID= - set _expression=%1 - shift - set FIND_PROCESS=TASKLIST /FI "WINDOWTITLE eq %_expression%" /NH - FOR /F "usebackq tokens=2 delims= " %%A IN (`cmd /c "%FIND_PROCESS% 2>NUL"`) DO ( - SET FOUND_PID=%%A - ) - if defined FOUND_PID ( - exit /b 0 - ) else ( - set EXCEPTION=%_expression% not found - exit /b 1 - ) -:forget - SETLOCAL - set FOUND_PID= - set NEXT_MINUTE= - set INSTANCE_NAME=%1 - shift - set SCRIPT=%1 - shift - set LOG_DIR=%1 - shift - CALL :findProcess %INSTANCE_NAME% - if defined FOUND_PID ( - echo %INSTANCE_NAME% already running pid [%FOUND_PID%] - ) else ( - CALL :nextMinute - set _DATE=%DATE:~4% - set CMD=schtasks /create /sd %_DATE% /tn %INSTANCE_NAME% /ru System /tr "cmd /c title %INSTANCE_NAME%&%SCRIPT% >%LOG_DIR%\stdout.log 2>%LOG_DIR%\stderr.log" /sc:once /st %NEXT_MINUTE% - echo %INSTANCE_NAME% will start at %NEXT_MINUTE% - set SECONDS=%TIME:~6,2% - set /a SECOND=60-SECONDS - %CMD% >NUL - ping -n %SECONDS% 127.0.0.1 > NUL 2>&1 - CALL :findProcess %INSTANCE_NAME% - if not defined FOUND_PID ( - set EXCEPTION=%INSTANCE_NAME% did not start - abort - ) - ) - exit /b 0 -:FUNCTION_END -set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem -if not "%1" == "init" if not "%1" == "status" if not "%1" == "stop" if not "%1" == "start" if not "%1" == "tail" if not "%1" == "tailerr" if not "%1" == "run" ( - set EXCEPTION=bad argument: %1 not in init status stop start tail tailerr run - goto abort -) -goto CASE_%1 -:CASE_init - call :default - if errorlevel 1 goto abort - call :mkebsboot - if errorlevel 1 goto abort - md %INSTANCE_HOME% - del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL - echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd - echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd - echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd - echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd - echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd - echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd - echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd - echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd - echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd - md %INSTANCE_HOME% - del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL - echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd - echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd - echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd - echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd - echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd - echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd - echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd - echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd - echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd - echo exit /b 0 >>%INSTANCE_HOME%\mkebsboot.cmd - GOTO END_SWITCH -:CASE_status - call :default - if errorlevel 1 goto abort - call :findPid %INSTANCE_NAME% - if errorlevel 1 goto abort - echo [%FOUND_PID%] - GOTO END_SWITCH -:CASE_stop - call :default - if errorlevel 1 goto abort - call :findPid %INSTANCE_NAME% - if errorlevel 1 goto abort - if defined FOUND_PID ( - TASKKILL /F /T /PID %FOUND_PID% >NUL - ) - GOTO END_SWITCH -:CASE_start - call :default - if errorlevel 1 goto abort - call :forget %INSTANCE_NAME% %INSTANCE_HOME%\%INSTANCE_NAME%.cmd %LOG_DIR% - if errorlevel 1 goto abort - GOTO END_SWITCH -:CASE_tail - call :default - if errorlevel 1 goto abort - tail %LOG_DIR%\stdout.log - GOTO END_SWITCH -:CASE_tailerr - call :default - if errorlevel 1 goto abort - tail %LOG_DIR%\stderr.log - GOTO END_SWITCH -:CASE_run - call :default - if errorlevel 1 goto abort - %INSTANCE_HOME%\%INSTANCE_NAME%.cmd - GOTO END_SWITCH -:END_SWITCH -exit /b 0 +@echo off +set PATH= +set JAVA_HOME= +set PATH= +GOTO FUNCTION_END +:abort + echo aborting: %EXCEPTION% + exit /b 1 +:default + set INSTANCE_NAME=mkebsboot +set INSTANCE_HOME=/mnt/tmp +set LOG_DIR=/mnt/tmp + exit /b 0 +:mkebsboot + set TMP_DIR=/mnt/tmp + exit /b 0 +:findPid + set FOUND_PID= + set _expression=%1 + shift + set FIND_PROCESS=TASKLIST /FI "WINDOWTITLE eq %_expression%" /NH + FOR /F "usebackq tokens=2 delims= " %%A IN (`cmd /c "%FIND_PROCESS% 2>NUL"`) DO ( + SET FOUND_PID=%%A + ) + if defined FOUND_PID ( + exit /b 0 + ) else ( + set EXCEPTION=%_expression% not found + exit /b 1 + ) +:forget + SETLOCAL + set FOUND_PID= + set NEXT_MINUTE= + set INSTANCE_NAME=%1 + shift + set SCRIPT=%1 + shift + set LOG_DIR=%1 + shift + CALL :findProcess %INSTANCE_NAME% + if defined FOUND_PID ( + echo %INSTANCE_NAME% already running pid [%FOUND_PID%] + ) else ( + CALL :nextMinute + set _DATE=%DATE:~4% + set CMD=schtasks /create /sd %_DATE% /tn %INSTANCE_NAME% /ru System /tr "cmd /c title %INSTANCE_NAME%&%SCRIPT% >%LOG_DIR%\stdout.log 2>%LOG_DIR%\stderr.log" /sc:once /st %NEXT_MINUTE% + echo %INSTANCE_NAME% will start at %NEXT_MINUTE% + set SECONDS=%TIME:~6,2% + set /a SECOND=60-SECONDS + %CMD% >NUL + ping -n %SECONDS% 127.0.0.1 > NUL 2>&1 + CALL :findProcess %INSTANCE_NAME% + if not defined FOUND_PID ( + set EXCEPTION=%INSTANCE_NAME% did not start + abort + ) + ) + exit /b 0 +:FUNCTION_END +set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem +if not "%1" == "init" if not "%1" == "status" if not "%1" == "stop" if not "%1" == "start" if not "%1" == "tail" if not "%1" == "tailerr" if not "%1" == "run" ( + set EXCEPTION=bad argument: %1 not in init status stop start tail tailerr run + goto abort +) +goto CASE_%1 +:CASE_init + call :default + if errorlevel 1 goto abort + call :mkebsboot + if errorlevel 1 goto abort + md %INSTANCE_HOME% + del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL + echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd + echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd + echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd + echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd + echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd + echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd + echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd + echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd + echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd + md %INSTANCE_HOME% + del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL + echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd + echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd + echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd + echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd + echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd + echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd + echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd + echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd + echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd + echo exit /b 0 >>%INSTANCE_HOME%\mkebsboot.cmd + GOTO END_SWITCH +:CASE_status + call :default + if errorlevel 1 goto abort + call :findPid %INSTANCE_NAME% + if errorlevel 1 goto abort + echo [%FOUND_PID%] + GOTO END_SWITCH +:CASE_stop + call :default + if errorlevel 1 goto abort + call :findPid %INSTANCE_NAME% + if errorlevel 1 goto abort + if defined FOUND_PID ( + TASKKILL /F /T /PID %FOUND_PID% >NUL + ) + GOTO END_SWITCH +:CASE_start + call :default + if errorlevel 1 goto abort + call :forget %INSTANCE_NAME% %INSTANCE_HOME%\%INSTANCE_NAME%.cmd %LOG_DIR% + if errorlevel 1 goto abort + GOTO END_SWITCH +:CASE_tail + call :default + if errorlevel 1 goto abort + tail %LOG_DIR%\stdout.log + GOTO END_SWITCH +:CASE_tailerr + call :default + if errorlevel 1 goto abort + tail %LOG_DIR%\stderr.log + GOTO END_SWITCH +:CASE_run + call :default + if errorlevel 1 goto abort + %INSTANCE_HOME%\%INSTANCE_NAME%.cmd + GOTO END_SWITCH +:END_SWITCH +exit /b 0 diff --git a/scriptbuilder/src/test/resources/test_runrun.cmd b/scriptbuilder/src/test/resources/test_runrun.cmd index 45fab930e4..ab5cf7c7bd 100644 --- a/scriptbuilder/src/test/resources/test_runrun.cmd +++ b/scriptbuilder/src/test/resources/test_runrun.cmd @@ -1,17 +1,17 @@ -md %TEMP%\%USERNAME%\scripttest -del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL -echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -md %TEMP%\%USERNAME%\scripttest -del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL -echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd -echo exit /b 0 >>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +md %TEMP%\%USERNAME%\scripttest +del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL +echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +md %TEMP%\%USERNAME%\scripttest +del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL +echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd +echo exit /b 0 >>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd diff --git a/scriptbuilder/src/test/resources/test_script.cmd b/scriptbuilder/src/test/resources/test_script.cmd index 9f70acf13b..0c20094c76 100644 --- a/scriptbuilder/src/test/resources/test_script.cmd +++ b/scriptbuilder/src/test/resources/test_script.cmd @@ -1,35 +1,35 @@ -@echo off -set PATH= -set JAVA_HOME= -set PATH= -set RUNTIME= -GOTO FUNCTION_END -:abort - echo aborting: %EXCEPTION% - exit /b 1 -:default - set RUNTIME=Moo - exit /b 0 -:FUNCTION_END -set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem -if not "%1" == "start" if not "%1" == "stop" if not "%1" == "status" ( - set EXCEPTION=bad argument: %1 not in start stop status - goto abort -) -goto CASE_%1 -:CASE_start - call :default - if errorlevel 1 goto abort - echo start %RUNTIME% - GOTO END_SWITCH -:CASE_stop - call :default - if errorlevel 1 goto abort - echo stop %RUNTIME% - GOTO END_SWITCH -:CASE_status - echo hello world>>%TEMP%\%USERNAME%\scripttest\temp.txt - echo the following should be []: [%RUNTIME%] - GOTO END_SWITCH -:END_SWITCH -exit /b 0 +@echo off +set PATH= +set JAVA_HOME= +set PATH= +set RUNTIME= +GOTO FUNCTION_END +:abort + echo aborting: %EXCEPTION% + exit /b 1 +:default + set RUNTIME=Moo + exit /b 0 +:FUNCTION_END +set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem +if not "%1" == "start" if not "%1" == "stop" if not "%1" == "status" ( + set EXCEPTION=bad argument: %1 not in start stop status + goto abort +) +goto CASE_%1 +:CASE_start + call :default + if errorlevel 1 goto abort + echo start %RUNTIME% + GOTO END_SWITCH +:CASE_stop + call :default + if errorlevel 1 goto abort + echo stop %RUNTIME% + GOTO END_SWITCH +:CASE_status + echo hello world>>%TEMP%\%USERNAME%\scripttest\temp.txt + echo the following should be []: [%RUNTIME%] + GOTO END_SWITCH +:END_SWITCH +exit /b 0