diff options
| author | chenjinsong <[email protected]> | 2018-09-27 16:11:54 +0800 |
|---|---|---|
| committer | chenjinsong <[email protected]> | 2018-09-27 16:11:54 +0800 |
| commit | 56d71f261a8bd6031e47e2bf80867049a2aa13da (patch) | |
| tree | f09257b2143782a333a9eda3395137837d9bdad1 /wininstall/script | |
initial commit
Diffstat (limited to 'wininstall/script')
| -rw-r--r-- | wininstall/script/nmsclient_shouhu.bat | 77 | ||||
| -rw-r--r-- | wininstall/script/restart.bat | 110 |
2 files changed, 187 insertions, 0 deletions
diff --git a/wininstall/script/nmsclient_shouhu.bat b/wininstall/script/nmsclient_shouhu.bat new file mode 100644 index 0000000..3f1e108 --- /dev/null +++ b/wininstall/script/nmsclient_shouhu.bat @@ -0,0 +1,77 @@ +@ECHO OFF +rem --------------------------------------------------------------------------- +rem Start ShouHu Script for the NMS Client +rem --------------------------------------------------------------------------- + +rem Guess NMSCLIENT_HOME if not defined +set "PRG_DIR=%~dp0" + + +if not "%NMSCLIENT_HOME%" == "" goto gotHome + +set "NMSCLIENT_HOME=%PRG_DIR%" +if exist "%NMSCLIENT_HOME%\bin\NMSClient.exe" goto okHome +cd /d %PRG_DIR%\.. +set "NMSCLIENT_HOME=%cd%" +cd "%PRG_DIR%" + +:gotHome +if exist "%NMSCLIENT_HOME%\bin\NMSClient.exe" goto okHome +echo The NMSCLIENT_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end + +:okHome + +set "NC_TASKDIR=%1" +set "log_file=%NMSCLIENT_HOME%\temp\job.log" +echo start shouhu at: %DATE% %TIME% NC_TASKDIR:"%NC_TASKDIR%" >> "%log_file%" + +:topLoop + ping -n 50 127.0.0.1>nul + set procExist=0 + wmic process where name="NMSClient.exe" get name |findstr "NMSClient.exe">nul &&set /a procExist+=1 + echo procExist: "%procExist%" + if not "%procExist%" == "0" goto toPing + + echo Down at: %DATE% %TIME% >> "%log_file%" + + :: ---------- handler agent upgrade result + if not "%NC_TASKDIR%" == "" ( + if exist "%NC_TASKDIR%" ( + cd /d %NC_TASKDIR% + ren *.upgrade *.result >>"%log_file%" 2>&1 + cd /d %NMSCLIENT_HOME%\bin + ) + ) + + :: ---------- start NC + echo start NMSClient ... >> "%log_file%" + net start NMSClient + + :toPing + ping -n 3 127.0.0.1>nul +goto topLoop + + + + + +rem set XMS_VALUE=32 +rem set XMX_VALUE=128 +rem if exist "%NMSCLIENT_HOME%\bin\jvm.ini" ( +rem cd /d "%NMSCLIENT_HOME%\bin" +rem for /f "tokens=1,2 delims==" %%a IN (jvm.ini) Do ( +rem rem echo "Xms"=="%%a" +rem if "Xms"=="%%a" ( +rem set XMS_VALUE=%%b +rem ) +rem if "Xmx"=="%%a" ( +rem set XMX_VALUE=%%b +rem ) +rem ) +rem ) +rem set /a XMS_VALUE=%XMS_VALUE%*(1024*1024) +rem set /a XMX_VALUE=%XMX_VALUE%*(1024*1024) + +rem start "" "%NMSCLIENT_HOME%\bin\NMSClient.exe" -Jinitialheap=%XMS_VALUE% -Jmaxheap=%XMX_VALUE%
\ No newline at end of file diff --git a/wininstall/script/restart.bat b/wininstall/script/restart.bat new file mode 100644 index 0000000..f174e7f --- /dev/null +++ b/wininstall/script/restart.bat @@ -0,0 +1,110 @@ +@ECHO OFF +rem --------------------------------------------------------------------------- +rem Start Script for the NMS Client +rem --------------------------------------------------------------------------- + +rem Guess NMSCLIENT_HOME if not defined +set "PRG_DIR=%~dp0" + + +if not "%NMSCLIENT_HOME%" == "" goto gotHome + +set "NMSCLIENT_HOME=%PRG_DIR%" +if exist "%NMSCLIENT_HOME%\bin\NMSClient.exe" goto okHome +cd /d %PRG_DIR%\.. +set "NMSCLIENT_HOME=%cd%" +cd "%PRG_DIR%" + +:gotHome +if exist "%NMSCLIENT_HOME%\bin\NMSClient.exe" goto okHome +echo The NMSCLIENT_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end + +:okHome + +::----NMSCLIENT_TASKDIR use : modify taskresult and start shouhu +set "NMSCLIENT_TASKDIR=%NMSCLIENT_HOME%\task" +if ""%3"" == """" goto okHome2 +set "NMSCLIENT_TASKDIR=%3" +set "cd_=%3" +:loop +set "cd_=%cd_:*\=%" +set "cd_tmp=%cd_:\=%" +if not "%cd_tmp%"=="%cd_%" goto loop +call set "NMSCLIENT_TASKDIR=%%NMSCLIENT_TASKDIR:%cd_%=%%" + +:okHome2 + +echo NMSCLIENT_HOME: %NMSCLIENT_HOME% +echo NMSCLIENT_TASKDIR: %NMSCLIENT_TASKDIR% +set "wtitle=NmsClient" +set "_NAME=NMSClient.exe" + +set procExist=0 +wmic process where name="%_NAME%" get name |findstr "%_NAME%">nul &&set /a procExist+=1 +if not "%procExist%" == "0" goto stopProc +echo %wtitle% is not start, now start...... +goto copyCode + +:stopProc +echo %wtitle% is start, now restart...... + +set "shouhu_name=nmsclient_shouhu.bat" +::-------stopShouhu +set shouhuProcExist=0 +wmic process where name="cmd.exe" get CommandLine |findstr "%shouhu_name%">nul &&set /a shouhuProcExist+=1 +if not "%shouhuProcExist%" == "0" ( + echo stop shouhu process ..... + wmic process where "name='cmd.exe' and CommandLine like '%%nmsclient_shouhu.bat%%'" delete + ping -n 3 127.0.0.1>nul +) +::-------startShouhu +set shouhuProcExist=0 +wmic process where name="cmd.exe" get CommandLine |findstr "%shouhu_name%">nul &&set /a shouhuProcExist+=1 +if "%shouhuProcExist%" == "0" ( + echo start shouhu process ..... + start /b %NMSCLIENT_HOME: =" "%\script\nmsclient_shouhu.bat %NMSCLIENT_TASKDIR: =" "% >nul 2>&1 +) + +wmic process where name="%_NAME%" delete >nul +ping -n 3 127.0.0.1>nul +set stopOk=0 +wmic process where name="%_NAME%" get name |findstr "%_NAME%">nul &&set /a stopOk+=1 +if not "%stopOk%" == "0" goto handleTask + +:copyCode +set copyError=0 +if ""%1"" == """" goto startProc +if ""%2"" == """" goto startProc +if ""%3"" == """" goto startProc +if not ""%1"" == """" ( + if not ""%2"" == """" ( + if not ""%3"" == """" ( + xcopy /Y /I /E /F %1 %2 >>%3 2>&1 ||set /a copyError+=1 + ) else ( + xcopy /Y /I /E /F %1 %2 >nul 2>&1 ||set /a copyError+=1 + ) + rmdir /S /Q %1 >nul 2>&1 + ) +) +rem ---------- copy error +if not "%copyError%" == "0" goto handleTask + +:startProc +net start NMSClient +set startOk=0 +ping -n 3 127.0.0.1>nul +wmic process where name="%_NAME%" get name |findstr "%_NAME%">nul &&set /a startOk+=1 +if not "%startOk%" == "1" goto handleTask +goto end + +:handleTask +if "%NMSCLIENT_TASKDIR%" == "" goto end +if not exist "%NMSCLIENT_TASKDIR%" goto end +cd /d %NMSCLIENT_TASKDIR% +ren *.upgrade *.result>nul 2>&1 +cd /d %NMSCLIENT_HOME%\bin +goto end + +:end
\ No newline at end of file |
