NSClient++

From WPKG | Open Source Software Deployment and Distribution
(Redirected from NSClient)
Jump to: navigation, search

NSClient++ can be downloaded from http://nsclient.org/download/

NSClient++ 0.5.0.62, single package for 32- or 64-bit with configuration control

This package installs the 32-bit or 64-bit version of NSClient++, as appropriate, and opens the necessary holes in the firewall.

This package controls configuration with nscp.exe settings --path path to key -key key name --set value instead of copying an INI file.

Note that when upgrading from 0.3.8, firewall rules need to be switched to point to the new nscp.exe instead of nsclient++.exe. This package handles that with netsh advfirewall.

<package
  id="nscp"
  name="NSClient++"
  revision="%version%-%configversion%"
  reboot="false">
 
  <variable name="version" value="0.5.0.62" />
  <variable name="configversion" value="1" />

  <!-- Set IP address or network of your monitoring system(s) -->
  <variable name="myips" value="10.0.0.0/24" /> 
 
  <check
    type="uninstall"
    condition="versiongreaterorequal"
    value="%version%"
    path="NSClient\+\+.*" />
  <check
    type="file"
    condition="versiongreaterorequal"
    path="%PROGRAMFILES%\NSClient++\nscp.exe"
    value="%version%" />
 
  <install cmd='msiexec /qn /norestart /i "%SOFTWARE%\NSclient\NSCP-%version%-x64.msi"' architecture="x64" />
  <install cmd='msiexec /qn /norestart /i "%SOFTWARE%\NSclient\NSCP-%version%-Win32.msi"' architecture="x86" />

  <install cmd="netsh advfirewall firewall set rule name=&quot;NSClient++ Monitoring Agent&quot; profile=&quot;any&quot; new remoteip=&quot;%myips%&quot;" />
  <!-- Handle upgrades from e.g. 0.3.8, where the binary was nsclient++.exe and the firewall rules will be wrong -->
  <install cmd="netsh advfirewall firewall set rule name=&quot;NSClient++ Monitoring Agent&quot; profile=&quot;any&quot; new program=&quot;%PROGRAMFILES%\NSclient++\nscp.exe&quot;" />

  <!-- Example: Set your password-->
<!--
  WARNING. This comment will cause a syntax error if left in, due to double minus in the cmd attribute
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /settings/default --key password --set &quot;your secret password&quot;" />
-->

  <!-- Put settings here -->
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /modules --key CheckDisk --set 1" />
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /modules --key CheckEventLog --set 1" />
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /modules --key CheckExternalScripts --set 1" />
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /modules --key CheckHelpers --set 1" />
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /modules --key CheckNSCP --set 1" />
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /modules --key CheckSystem --set 1" />
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /modules --key CheckWMI --set 1" />
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /modules --key NSClientServer --set 1" />

  <!-- Example: set alternate port -->
<!--
  WARNING. This comment will cause a syntax error if left in, due to double minus in the cmd attribute
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /settings/NSClient/server --key port --set 1248" />
-->

  <!-- Example: set allowed remote host -->
<!--
  WARNING. This comment will cause a syntax error if left in, due to double minus in the cmd attribute
  <install cmd="&quot;%PROGRAMFILES%\NSClient++\nscp.exe&quot; settings --path /settings/default --key &quot;allowed hosts&quot; --set 10.0.0.1" />
-->

  <!-- This works around a bug in NSClient++ and must appear after ALL other configuration commands! -->
  <install cmd='powershell -noprofile -command "(get-content \"%PROGRAMFILES%\NSClient++\\nsclient.ini") | %{$_ -replace \"^An alias is an internal command.*$\", \"\"} | set-content \"%PROGRAMFILES%\NSclient++\nsclient.ini\""' />


  <install cmd="net stop nscp">
    <exit code="any" />
  </install>
  <install cmd="net start nscp" />

  <upgrade include="install" />

  <remove cmd="net stop nscp">
    <exit code="any" />
  </remove>
  <!-- Product code verified with 0.5.0.62 x64, check
       HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\
       for correct GUID with future versions
    -->
  <remove cmd="MsiExec.exe /qn /x{1B7FBEBA-96B5-4837-82C8-B3EED3BFC9D8}">
    <exit code="any" />
  </remove>
  <remove cmd='msiexec /qn /norestart /x "%SOFTWARE%\NSclient\NSCP-%version%-x64.msi"' architecture="x64" >
    <exit code="any" />
  </remove>
  <remove cmd='msiexec /qn /norestart /x "%SOFTWARE%\NSclient\NSCP-%version%-Win32.msi"' architecture="x86" >
    <exit code="any" />
  </remove>

</package>

NSClient++ 0.4.1

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