mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-05 21:04:28 +02:00
Determine NSClient++ installation path using MsiGetComponentPath
fixes #9256
This commit is contained in:
parent
801d2a7f62
commit
2f3a8be2e6
@ -18,13 +18,13 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
if (!globals.contains("NscpPath")) {
|
if (!globals.contains("NscpPath")) {
|
||||||
NscpPath = "C:\\Program Files\\NSClient++"
|
NscpPath = msi_get_component_path("{5C45463A-4AE9-4325-96DB-6E239C034F93}")
|
||||||
}
|
}
|
||||||
|
|
||||||
object CheckCommand "nscp-local" {
|
object CheckCommand "nscp-local" {
|
||||||
import "plugin-check-command"
|
import "plugin-check-command"
|
||||||
|
|
||||||
command = [ "$nscp_path$\\nscp.exe", "client" ]
|
command = [ NscpPath, "client" ]
|
||||||
|
|
||||||
arguments = {
|
arguments = {
|
||||||
"-q" = {
|
"-q" = {
|
||||||
|
@ -63,7 +63,7 @@ if(UNIX OR CYGWIN)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(base ws2_32 dbghelp shlwapi)
|
target_link_libraries(base ws2_32 dbghelp shlwapi msi)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties (
|
set_target_properties (
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <msi.h>
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
@ -52,6 +55,9 @@ REGISTER_SCRIPTFUNCTION(string, &ScriptUtils::CastString);
|
|||||||
REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
|
REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
|
||||||
REGISTER_SCRIPTFUNCTION(bool, &ScriptUtils::CastBool);
|
REGISTER_SCRIPTFUNCTION(bool, &ScriptUtils::CastBool);
|
||||||
REGISTER_SCRIPTFUNCTION(get_time, &Utility::GetTime);
|
REGISTER_SCRIPTFUNCTION(get_time, &Utility::GetTime);
|
||||||
|
#ifdef _WIN32
|
||||||
|
REGISTER_SCRIPTFUNCTION(msi_get_component_path, &ScriptUtils::MsiGetComponentPathShim);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
String ScriptUtils::CastString(const Value& value)
|
String ScriptUtils::CastString(const Value& value)
|
||||||
{
|
{
|
||||||
@ -278,3 +284,16 @@ void ScriptUtils::Assert(const Value& arg)
|
|||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Assertion failed"));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Assertion failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
String ScriptUtils::MsiGetComponentPathShim(const String& component)
|
||||||
|
{
|
||||||
|
TCHAR productCode[39];
|
||||||
|
if (MsiGetProductCode(component.CStr(), productCode) != ERROR_SUCCESS)
|
||||||
|
return "";
|
||||||
|
TCHAR path[2048];
|
||||||
|
DWORD szPath = sizeof(path);
|
||||||
|
path[0] = '\0';
|
||||||
|
MsiGetComponentPath(productCode, component.CStr(), path, &szPath);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
@ -50,6 +50,9 @@ public:
|
|||||||
static DynamicObject::Ptr GetObject(const Type::Ptr& type, const String& name);
|
static DynamicObject::Ptr GetObject(const Type::Ptr& type, const String& name);
|
||||||
static Array::Ptr GetObjects(const Type::Ptr& type);
|
static Array::Ptr GetObjects(const Type::Ptr& type);
|
||||||
static void Assert(const Value& arg);
|
static void Assert(const Value& arg);
|
||||||
|
#ifdef _WIN32
|
||||||
|
static String MsiGetComponentPathShim(const String& component);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptUtils(void);
|
ScriptUtils(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user