Difference between revisions of "NSClient++"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
(NSClient++ silent installer)
(No difference)

Revision as of 12:29, 27 May 2014

NSClient++ 0.4.1

NSClient++ can be downloaded here:http://nsclient.org/nscp/downloads

One package for the 32bit-version, one for the 64bit.

I create an sample init-file, and copy it with each install/upgrade.

The remove-Tag is a bit crude, because i used the (maybe new) package for deinstalling, because i couldn't figure out, how to get the registry-key ...

<package
  id="nsclient32"
  name="NSClient++ 32bit"
  revision="%version%"
  priority="0"
  reboot="false">

  <variable name="version" value="0.4.1.102" />

  <check type="logical" condition="or">
    <check type="uninstall" condition="versiongreaterorequal" path="NSClient++ (Win32)" value="%version%"/>
    <check type="file" condition="versiongreaterorequal" path="%ProgramFiles%\NSClient++\nscp.exe" value="%version%"/>
  </check>

  <!-- install new package -->
  <install cmd='msiexec /quiet /norestart /i %SOFTWARE%\nsclientpp\NSCP-%version%-Win32.msi'/>
  <!-- copy (new) Ini -->
  <install cmd='xcopy %SOFTWARE%\nsclientpp\nsclient.ini "%ProgramFiles%\NSClient++\nsclient.ini" /q /y'/>
  <!-- restart NSclient++ -->
  <install cmd='net stop nscp'/>
  <install cmd='net start nscp'/>

  <upgrade include="install" />

  <!-- remove -->
  <remove cmd='net stop nscp'/>
  <remove cmd='msiexec /quiet /norestart /x %SOFTWARE%\nsclientpp\NSCP-%version%-Win32.msi'/>
</package>

<package
  id="nsclient64"
  name="NSClient++ 64bit"
  revision="%version%"
  priority="0"
  reboot="false">

  <variable name="version" value="0.4.1.102" />

  <check type="logical" condition="or">
    <check type="uninstall" condition="versiongreaterorequal" path="NSClient++ (x64)" value="%version%"/>
    <check type="file" condition="versiongreaterorequal" path="%ProgramFiles%\NSClient++\nscp.exe" value="%version%"/>
  </check>

  <!-- install new package -->
  <install cmd='msiexec /quiet /norestart /i %SOFTWARE%\nsclientpp\NSCP-%version%-x64.msi'/>
  <!-- copy (new) ini -->
  <install cmd='xcopy %SOFTWARE%software\nsclientpp\nsclient.ini "%ProgramFiles%\NSClient++\nsclient.ini" /q /y'/>
  <!-- restart NSclient++ -->
  <install cmd='net stop nscp'/>
  <install cmd='net start nscp'/>

  <upgrade include="install" />

  <!-- remove -->
  <remove cmd='net stop nscp'/>
  <remove cmd='msiexec /quiet /norestart /x %SOFTWARE%software\nsclientpp\NSCP-%version%-x64.msi'/>
</package>

NSClient++ Plugins

If you have own scripts for NSClient++, this package may be useful.

Because i haven't set a version number for the scripts, i use the date and write it to a file on the local computer. A batch-skript in the tools-directory compare xml-version with installed-version (see below), to call it i used a %SETTINGS%-Variable from WPKG, which link on the WPKG-Root (I should define a own Variable for that, i now ... maybe later :-)

<package
  id="nsclientplugins"
  name="NSClient++ Plugins"
  revision="%version%"
  priority="0"
  reboot="false">

  <variable name="version" value="2013-05-27" />
  <variable name="versionfile" value="%ProgramFiles%\NSClient++\scripts\pluginsversion.txt" />

  <check type="execute" path='%SETTINGS%tools\compareStringAndFile.bat "%version%" "%versionfile%"' condition="exitcodeequalto" value="0"/>

  <!-- stop NSclient++ -->
  <install cmd='net stop nscp'>
    <exit code="0" />
    <!-- If Nsclient++ already stopped, continue too. -->
    <exit code="2" />
  </install>
  <!-- copy new skripts -->
  <install cmd='xcopy %SOFTWARE%\nsclientpp\scripts\* "%ProgramFiles%\NSClient++\scripts\" /q /y'/>
  <!-- set version -->
  <install cmd='%ComSpec% /c echo %version%>"%versionfile%"'/>
  <!-- to be sure: set executionpolicy of the powershell (If you don't have powershellskripts, you don't need this) -->
  <install cmd='powershell Set-ExecutionPolicy remotesigned -Confirm:$false'/>
  <!-- and start NSclient++ -->
  <install cmd='net start nscp'/>

  <upgrade include="install" />

</package>

</packages:packages>

And the compareStringAndFile.bat:

@echo off
REM compare parameter 1 (string) with content of parameter 2 (file)

set /p FILECONTENT=<%2
set FILECONTENT="%FILECONTENT%"

REM echo %FILECONTENT%
REM echo %1

if %1 == %FILECONTENT% exit /B 0

REM echo "Die Strings sind ungleich!"
exit /B 1