mirror of https://github.com/Icinga/icinga2.git
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")) {
|
||||
NscpPath = "C:\\Program Files\\NSClient++"
|
||||
NscpPath = msi_get_component_path("{5C45463A-4AE9-4325-96DB-6E239C034F93}")
|
||||
}
|
||||
|
||||
object CheckCommand "nscp-local" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ "$nscp_path$\\nscp.exe", "client" ]
|
||||
command = [ NscpPath, "client" ]
|
||||
|
||||
arguments = {
|
||||
"-q" = {
|
||||
|
|
|
@ -63,7 +63,7 @@ if(UNIX OR CYGWIN)
|
|||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(base ws2_32 dbghelp shlwapi)
|
||||
target_link_libraries(base ws2_32 dbghelp shlwapi msi)
|
||||
endif()
|
||||
|
||||
set_target_properties (
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
#include <boost/regex.hpp>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#ifdef _WIN32
|
||||
#include <msi.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
@ -52,6 +55,9 @@ REGISTER_SCRIPTFUNCTION(string, &ScriptUtils::CastString);
|
|||
REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
|
||||
REGISTER_SCRIPTFUNCTION(bool, &ScriptUtils::CastBool);
|
||||
REGISTER_SCRIPTFUNCTION(get_time, &Utility::GetTime);
|
||||
#ifdef _WIN32
|
||||
REGISTER_SCRIPTFUNCTION(msi_get_component_path, &ScriptUtils::MsiGetComponentPathShim);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
String ScriptUtils::CastString(const Value& value)
|
||||
{
|
||||
|
@ -278,3 +284,16 @@ void ScriptUtils::Assert(const Value& arg)
|
|||
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 Array::Ptr GetObjects(const Type::Ptr& type);
|
||||
static void Assert(const Value& arg);
|
||||
#ifdef _WIN32
|
||||
static String MsiGetComponentPathShim(const String& component);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
private:
|
||||
ScriptUtils(void);
|
||||
|
|
Loading…
Reference in New Issue