@echo off rem --------------------------------------------------------------------------- rem deploy script for the WMS Server rem --------------------------------------------------------------------------- setlocal set "RAR=D:\Softwore\install\7Z\7-Zip\7z.exe" set "WMS_VERSION=1.0.0-SNAPSHOT" rem Guess WORKSPACE_HOME if not defined set "CURRENT_DIR=%cd%" if not "%WORKSPACE_BASE%" == "" goto gotBase set "WORKSPACE_BASE=%CURRENT_DIR%" rem set WORKSPACE_BASE=WMS-parent directory cd ..\.. set "WORKSPACE_BASE=%cd%" echo WORKSPACE_BASE="%WORKSPACE_BASE%" if not exist "%WORKSPACE_BASE%\Environment" echo "%WORKSPACE_BASE%\Environment is not exist" && goto end set "WORKSPACE_ENV=%WORKSPACE_BASE%\Environment" :gotEnv if not exist "%WORKSPACE_ENV%\config" echo "%WORKSPACE_ENV%\config is not exist" && goto end set "WORKSPACE_ENV_CONFIG=%WORKSPACE_ENV%\config" rem set application profile directory if not exist "%WORKSPACE_ENV%\config\profile\DEV" echo "%WORKSPACE_ENV%\config\profile\DEV is not exist" && goto end set "WORKSPACE_ENV_PROFILE=%WORKSPACE_ENV%\config\profile\DEV" :gotEnvconfig if not exist "%WORKSPACE_ENV%\cmd" echo "%WORKSPACE_ENV%\cmd is not exist" && goto end set "WORKSPACE_ENV_CMD=%WORKSPACE_ENV%\cmd" :gotEnvcmd if not exist "%WORKSPACE_ENV_CMD%\zidmboot.sh" echo "%WORKSPACE_ENV_CMD%\zidmboot.sh is not exist" && goto end :gotBase if exist "%WORKSPACE_BASE%\output" goto gotOutput mkdir "%WORKSPACE_BASE%\output" :gotOutput if exist "%WORKSPACE_BASE%\output\DEV" goto gotDevOutput mkdir "%WORKSPACE_BASE%\output\DEV" :gotDevOutput if not exist "%WORKSPACE_BASE%\output\DEV\WMS.server" goto gotMakeBaseDir rd /s /Q "%WORKSPACE_BASE%\output\DEV\WMS.server\bin" rd /s /Q "%WORKSPACE_BASE%\output\DEV\WMS.server\conf" rd /s /Q "%WORKSPACE_BASE%\output\DEV\WMS.server\libs" rd /s /Q "%WORKSPACE_BASE%\output\DEV\WMS.server\logs" rd /s /Q "%WORKSPACE_BASE%\output\DEV\WMS.server\temp" goto gotSolution :gotMakeBaseDir mkdir "%WORKSPACE_BASE%\output\DEV\WMS.server" :gotSolution cd %WORKSPACE_BASE%\output\DEV\WMS.server set "WMS_BASE=%cd%" if not exist "%WORKSPACE_BASE%\WMSSolution.Boot\target\WMSSolution.Boot-%WMS_VERSION%.jar" echo The WMSSolution.Boot Execute jar is not defined correctly && goto end :gotExcuteJar if exist "%WMS_BASE%\bin" goto gotBindir mkdir "%WMS_BASE%\bin" :gotBindir if exist "%WMS_BASE%\conf" goto gotConfdir mkdir "%WMS_BASE%\conf" :gotConfdir if exist "%WMS_BASE%\lib" goto gotLibdir mkdir "%WMS_BASE%\lib" :gotLibdir if exist "%WMS_BASE%\logs" goto gotLogsdir mkdir "%WMS_BASE%\logs" :gotLogsdir if exist "%WMS_BASE%\temp" goto gotTempdir mkdir "%WMS_BASE%\temp" :gotTempdir if "%WMS_CONFIGPATH%" == "" goto emptyConfigpath set "WMS_CONFIGPATH=%WMS_CONFIGPATH%" :emptyConfigpath set "WMS_CONFIGPATH=%WMS_BASE%\conf" if "%WMS_BINPATH%" == "" goto emptyBinpath set "WMS_BINPATH=%WMS_BINPATH%" :emptyBinpath set "WMS_BINPATH=%WMS_BASE%\bin" if "%RAR%" == "" echo The 7ZIP environment variable is not defined correctly && goto end :emptyRAR rem clear config and execute jar rd /s /Q %WMS_CONFIGPATH% & md %WMS_CONFIGPATH% rd /s /Q %WMS_BINPATH% & md %WMS_BINPATH% rem copy config file to conf dictory ROBOCOPY %WORKSPACE_ENV_CONFIG% %WMS_CONFIGPATH% /E /MT:10 ROBOCOPY %WORKSPACE_ENV_PROFILE% %WMS_CONFIGPATH%\profile /E /MT:10 rd /S /Q %WMS_CONFIGPATH%\profile\DEV rd /S /Q %WMS_CONFIGPATH%\profile\PRD rd /S /Q %WMS_CONFIGPATH%\profile\TST del /Q /F %WMS_CONFIGPATH%\profile\application.yml ROBOCOPY %WORKSPACE_ENV_CMD% %WMS_BINPATH% /MT:1 ROBOCOPY %WORKSPACE_BASE%\WMSSolution.Boot\target %WMS_BASE%\lib WMSSolution.Boot-%WMS_VERSION%.jar ren "%WMS_BASE%\lib\WMSSolution.Boot-%WMS_VERSION%.jar" "bootstrap.jar" rem compress tar rem set hour , if hour < 10, then 01 ~ 09 set currenthour=%time:~0,2% if "%currenthour:~0,1%" NEQ " " goto gotCurrentHour set currenthour="0"%currenthour:~1,1% :gotCurrentHour set "ymd=%date:~0,4%%date:~5,2%%date:~8,2%%currenthour%%time:~3,2%%time:~6,2%" "%RAR%" a -ttar "%WORKSPACE_BASE%\output\DEV\WMS.server-%WMS_VERSION%-%ymd%.tar" "%WMS_BASE%" "%RAR%" a -tgzip "%WORKSPACE_BASE%\output\DEV\WMS.server-%WMS_VERSION%-%ymd%.tar.gz" "%WORKSPACE_BASE%\output\DEV\WMS.server-%WMS_VERSION%-%ymd%.tar" del /F "%WORKSPACE_BASE%\output\DEV\WMS.server-%WMS_VERSION%-%ymd%.tar" cd %WORKSPACE_BASE%\output\DEV if not exist %WMS_BASE% goto end rd /s /Q %WMS_BASE% :end pause