Module: check_mk
Branch: master
Commit: 172b64dd3212c54b8901cfa0c12b4d762f412bc4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=172b64dd3212c5…
Author: Sergey Kipnis <sk(a)mathias-kettner.de>
Date: Thu Mar 28 18:12:31 2019 +0100
[CMK-1890] - deploy script checks whether automatic update works
Change-Id: I427cf15aa86438e6cdbc8fbf05b026c430e01560
---
agents/wnx/build_release.cmd | 16 ++++++++++++++++
agents/wnx/call_deploy.cmd | 24 ++++++++++++++++++------
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/agents/wnx/build_release.cmd b/agents/wnx/build_release.cmd
index 76aebc2..9dcda5c 100644
--- a/agents/wnx/build_release.cmd
+++ b/agents/wnx/build_release.cmd
@@ -59,8 +59,22 @@ if not %errorlevel% == 0 powershell Write-Host "Failed
%exec%-32" -Foreground Re
%msbuild% wamain.sln /t:%exec% /p:Configuration=Release,Platform=x64
if not %errorlevel% == 0 powershell Write-Host "Failed %exec%-64" -Foreground
Red && exit 7
+@rem auto install msi
+git update-index --assume-unchanged install/resources/check_mk.dat > nul
+@copy install\resources\check_mk.dat save.tmp > nul
+echo update > install\resources\check_mk.dat
+%msbuild% wamain.sln /t:install /p:Configuration=Release,Platform=x64
+set el=%errorlevel%
+@type save.tmp > install\resources\check_mk.dat
+@del save.tmp > nul
+git update-index --no-assume-unchanged install/resources/check_mk.dat > nul
+if not %el% == 0 powershell Write-Host "Failed Install build" -Foreground Red
&& exit 88
+copy %REMOTE_MACHINE%\check_mk_service.msi %REMOTE_MACHINE%\check_mk_agent_update.msi
+
+
%msbuild% wamain.sln /t:install /p:Configuration=Release,Platform=x64
if not %errorlevel% == 0 powershell Write-Host "Failed Install build"
-Foreground Red && exit 8
+
goto end
@rem ignored:
powershell Write-Host "starting unit tests" -Foreground Cyan
@@ -83,5 +97,7 @@ copy %REMOTE_MACHINE%\check_mk_service.msi
%REMOTE_MACHINE%\check_mk_agent.msi
copy %REMOTE_MACHINE%\check_mk_service32.exe %REMOTE_MACHINE%\check_mk_agent.exe
copy %REMOTE_MACHINE%\check_mk_service64.exe %REMOTE_MACHINE%\check_mk_agent-64.exe
+rem touching update msi
+copy %REMOTE_MACHINE%\check_mk_agent_update.msi /B+ ,,/Y > nul
diff --git a/agents/wnx/call_deploy.cmd b/agents/wnx/call_deploy.cmd
index 1558f09..8e4fa9a 100644
--- a/agents/wnx/call_deploy.cmd
+++ b/agents/wnx/call_deploy.cmd
@@ -1,7 +1,7 @@
@echo off
powershell Write-Host Starting deployment -Foreground Green
if "%1" == "SIMULATE_OK" powershell Write-Host "Deploy:
SUCCESS" -Foreground Green && exit 0
-if "%1" == "SIMULATE_FAIL" powershell Write-Host "Deploy:
FAIL" -Foreground Red && del %REMOTE_MACHINE%\check_mk_service.msi &&
exit 99
+if "%1" == "SIMULATE_FAIL" powershell Write-Host "Deploy:
FAIL" -Foreground Red && del %REMOTE_MACHINE%\check_mk_agent.msi &&
exit 99
set root=%cd%\..\..\artefacts
set REMOTE_MACHINE=%root%
@set svc=CheckMkService
@@ -9,25 +9,35 @@ set p="%ProgramFiles(X86)%\check_mk_service\upgrade.protocol"
pushd
cd %root%
powershell Write-Host "%svc% is cleaning up" -Foreground DarkGray
-msiexec /uninstall check_mk_service.msi /quiet /LV* log.tmp
+msiexec /uninstall check_mk_agent.msi /quiet /LV* log.tmp
del %p% 2> null
powershell Write-Host "%svc% is installing" -Foreground Cyan
-msiexec /I check_mk_service.msi /quiet /LV* log
+msiexec /I check_mk_agent.msi /quiet /LV* log
powershell Write-Host "%svc% is installed" -Foreground Green
powershell Start-Sleep 2
@set status=1
powershell Write-Host "checking status" -Foreground Cyan
sc query "%svc%" | find /i "RUNNING" > null
-if %ERRORLEVEL% == 0 goto work
+if %ERRORLEVEL% == 0 goto update
powershell Write-Host "%svc% is NOT running" -Foreground Red
set status=3
goto end
+:update
+@rem Update check
+mkdir %ALLUSERSPROFILE%\CheckMk\Agent\Update 2> nul
+copy check_mk_agent_update.msi %ALLUSERSPROFILE%\CheckMk\Agent\update\check_mk_agent.msi
> nul
+powershell Start-Sleep 20
+echo update > control.tmp
+fc "%ProgramFiles(X86)%\check_mk_service\check_mk.dat" control.tmp > nul
+set upd=%errorlevel%
+del control.tmp > nul
:work
+@rem Uninstall check
powershell Write-Host "%svc% is running" -Foreground Green
if not exist %p% powershell Write-Host "Upgrade Protocol file not found"
-Foreground Red && set status=5 && goto end
powershell Write-Host "protocol file is found" -Foreground Green
powershell Write-Host "%svc% is uninstalling" -Foreground Cyan
-msiexec /uninstall check_mk_service.msi /quiet /LV* log.tmp
+msiexec /uninstall check_mk_agent.msi /quiet /LV* log.tmp
sc query "%svc%1" > null
if %ERRORLEVEL% == 0 powershell Write-Host "Cannot Uninstall Service"
-Foreground Red && set status=5 && goto end
powershell Write-Host "%svc% is uninstalled" -Foreground Green
@@ -35,4 +45,6 @@ set status=0
:end
popd
del %p%
-exit /B %status%
+if "%upd%" == "0" exit /B %status%
+powershell Write-Host "%svc% is failed in update" -Foreground Red
+exit /B %upd%