@echo off

:restart
java -cp "../lib/*" de.sillysky.nyssr.impl.kernel.CKernel node.id=ceres
set exitCode=%errorlevel%

if %exitCode%==1 goto restart

if %exitCode%==2 call :updateLib
if %exitCode%==3 call :updatePlugins
if %exitCode%==4 call :updateBoth

goto :eof

:updateLib
echo LIB Update is being performed...
del /Q /F ..\lib
xcopy /Y .\update\new_files\lib\*.jar ..\lib
echo Update completed. Application is restarted...
goto restart

:updatePlugins
echo PLUGIN Update is being performed...
del /Q /F ..\plugins
xcopy /Y .\update\new_files\plugins\*.jar ..\plugins
echo Update completed. Application is restarted...
goto restart

:updateBoth
echo LIB and PLUGIN Update is being performed...
del /Q /F ..\lib
xcopy /Y .\update\new_files\lib\*.jar ..\lib
del /Q /F ..\plugins
xcopy /Y .\update\new_files\plugins\*.jar ..\plugins
echo Update completed. Application is restarted...
goto restart
