Module: check_mk
Branch: master
Commit: 95ab09d30bdaaa2337601ff4615d68ec6fab5441
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=95ab09d30bdaaa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 10 11:33:24 2012 +0100
Added compiled agent installer; Improved installer
---
agents/windows/Makefile | 5 +-
agents/windows/check_mk_agent.exe | Bin 102912 -> 102912 bytes
agents/windows/crash.exe | Bin 20024 -> 20024 bytes
agents/windows/install_agent.exe | Bin 0 -> 124971 bytes
agents/windows/installer.ico | Bin 1406 -> 12862 bytes
agents/windows/installer.nsi | 94 ++++++++++++++++++++++---------------
6 files changed, 58 insertions(+), 41 deletions(-)
diff --git a/agents/windows/Makefile b/agents/windows/Makefile
index 036ac08..31a2105 100755
--- a/agents/windows/Makefile
+++ b/agents/windows/Makefile
@@ -28,14 +28,13 @@ else
CXX = mingw32-g++
endif
-all: check_mk_agent.exe crash.exe installer
-
-installer:
+install_agent.exe: check_mk_agent.exe crash.exe
if ! which makensis; then \
echo "ERROR: makensis missing. Please install the nsis package." ; \
exit 1 ; \
fi
makensis installer.nsi
+ chmod +x install_agent.exe
check_mk_agent.exe: check_mk_agent.cc Makefile
$(CXX) -s -O2 -Wall -Werror -o $@ $< -lwsock32
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 08976c5..5b1ca11 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/crash.exe b/agents/windows/crash.exe
index e3c5b3e..ff7c400 100755
Binary files a/agents/windows/crash.exe and b/agents/windows/crash.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
new file mode 100755
index 0000000..e973cd4
Binary files /dev/null and b/agents/windows/install_agent.exe differ
diff --git a/agents/windows/installer.ico b/agents/windows/installer.ico
index 2e8c4ea..a56e224 100644
Binary files a/agents/windows/installer.ico and b/agents/windows/installer.ico differ
diff --git a/agents/windows/installer.nsi b/agents/windows/installer.nsi
index 025583e..4a6e9f8 100644
--- a/agents/windows/installer.nsi
+++ b/agents/windows/installer.nsi
@@ -14,7 +14,7 @@ Icon "installer.ico"
Name "${NAME}"
; The file to write
-OutFile "check_mk_agent_install-${CHECK_MK_VERSION}.exe"
+OutFile "install_agent.exe"
SetDateSave on
SetDatablockOptimize on
@@ -46,47 +46,65 @@ UninstPage instfiles
;--------------------------------
Section "Check_MK_Agent"
- ; Can not be disabled
- SectionIn RO
-
- SetOutPath "$INSTDIR"
- File check_mk_agent.exe
- File check_mk.ini
- CreateDirectory "$INSTDIR\local"
- CreateDirectory "$INSTDIR\plugins"
-
- ; Write the installation path into the registry
- WriteRegStr HKLM SOFTWARE\check_mk_agent "Install_Dir" "$INSTDIR"
-
- ; Write the uninstall keys for Windows
- WriteRegStr HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
"DisplayName" "${NAME}"
- WriteRegStr HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
"UninstallString" '"$INSTDIR\uninstall.exe"'
- WriteRegDWORD HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
"NoModify" 1
- WriteRegDWORD HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
"NoRepair" 1
- WriteUninstaller "uninstall.exe"
+ ; Can not be disabled
+ SectionIn RO
+
+ !include LogicLib.nsh
+ ExpandEnvStrings $0 "%comspec%"
+ nsExec::ExecToStack '"$0" /k "net start | FIND /C /I
"check_mk_agent""'
+ Pop $0
+ Pop $1
+ StrCpy $1 $1 1
+ Var /GLOBAL stopped
+ ${If} "$0$1" == "01"
+ DetailPrint "Stop running check_mk_agent..."
+ StrCpy $stopped "1"
+ nsExec::Exec 'cmd /C "net stop check_mk_agent"'
+ ${Else}
+ StrCpy $stopped "0"
+ ${EndIf}
+
+ SetOutPath "$INSTDIR"
+ File check_mk_agent.exe
+ File check_mk.ini
+ CreateDirectory "$INSTDIR\local"
+ CreateDirectory "$INSTDIR\plugins"
+
+ ; Write the installation path into the registry
+ WriteRegStr HKLM SOFTWARE\check_mk_agent "Install_Dir"
"$INSTDIR"
+
+ ; Write the uninstall keys for Windows
+ WriteRegStr HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
"DisplayName" "${NAME}"
+ WriteRegStr HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
"UninstallString" '"$INSTDIR\uninstall.exe"'
+ WriteRegDWORD HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
"NoModify" 1
+ WriteRegDWORD HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
"NoRepair" 1
+ WriteUninstaller "uninstall.exe"
SectionEnd
Section "Install & start service"
- ExecWait '"$INSTDIR\check_mk_agent.exe" install'
- ExecWait 'net start check_mk_agent'
+ DetailPrint "Installing and starting the check_mk_agent service..."
+ nsExec::Exec 'cmd /C \'"$INSTDIR\check_mk_agent.exe"
install\''
+ nsExec::Exec 'cmd /C "net start check_mk_agent"'
SectionEnd
Section "Uninstall"
- ; Remove the service
- ExecWait 'net stop check_mk_agent'
- ExecWait '"$INSTDIR\check_mk_agent.exe" remove'
-
- ; Remove registry keys
- DeleteRegKey HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
- DeleteRegKey HKLM SOFTWARE\check_mk_agent
-
- ; Remove files and uninstaller
- Delete "$INSTDIR\check_mk_agent.exe"
- Delete "$INSTDIR\check_mk.ini"
- Delete "$INSTDIR\uninstall.exe"
- RMDir "$INSTDIR\local"
- RMDir "$INSTDIR\plugins"
-
- ; Remove directories used
- RMDir "$INSTDIR"
+ ; Remove the service
+ DetailPrint "Stopping service..."
+ nsExec::Exec 'cmd /C "net stop check_mk_agent"'
+ DetailPrint "Removing service..."
+ nsExec::Exec 'cmd /C "$INSTDIR\check_mk_agent.exe" remove"'
+
+ ; Remove registry keys
+ DeleteRegKey HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\check_mk_agent"
+ DeleteRegKey HKLM SOFTWARE\check_mk_agent
+
+ ; Remove files and uninstaller
+ Delete "$INSTDIR\check_mk_agent.exe"
+ Delete "$INSTDIR\check_mk.ini"
+ Delete "$INSTDIR\uninstall.exe"
+ RMDir "$INSTDIR\local"
+ RMDir "$INSTDIR\plugins"
+
+ ; Remove directories used
+ RMDir "$INSTDIR"
SectionEnd