mirror of https://github.com/Icinga/icinga2.git
parent
d276c7e4c2
commit
7b37bd8f41
|
@ -289,7 +289,7 @@ if(ICINGA2_WITH_TESTS)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CPACK_PACKAGE_NAME "Icinga2")
|
set(CPACK_PACKAGE_NAME "Icinga 2")
|
||||||
set(CPACK_PACKAGE_VENDOR "Icinga Development Team")
|
set(CPACK_PACKAGE_VENDOR "Icinga Development Team")
|
||||||
set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
|
set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
|
||||||
set(CPACK_NSIS_DISPLAY_NAME "Icinga 2")
|
set(CPACK_NSIS_DISPLAY_NAME "Icinga 2")
|
||||||
|
@ -321,6 +321,8 @@ set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}\nCre
|
||||||
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}\nnsExec::Exec '\\\"$INSTDIR\\\\sbin\\\\icinga2\\\" --scm-install daemon'")
|
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}\nnsExec::Exec '\\\"$INSTDIR\\\\sbin\\\\icinga2\\\" --scm-install daemon'")
|
||||||
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}\nnsExec::Exec 'net start icinga2'")
|
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}\nnsExec::Exec 'net start icinga2'")
|
||||||
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "nsExec::Exec '\\\"$INSTDIR\\\\sbin\\\\icinga2\\\" --scm-uninstall'")
|
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "nsExec::Exec '\\\"$INSTDIR\\\\sbin\\\\icinga2\\\" --scm-uninstall'")
|
||||||
|
set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
|
||||||
|
set(CPACK_WIX_UPGRADE_GUID "52F2BEAA-4DF0-4C3E-ABDC-C0F61DE4DF8A")
|
||||||
|
|
||||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
||||||
include(InstallRequiredSystemLibraries)
|
include(InstallRequiredSystemLibraries)
|
||||||
|
|
|
@ -2,22 +2,46 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Icinga
|
namespace Icinga
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
|
[DllImport("msi.dll", SetLastError = true)]
|
||||||
|
static extern int MsiEnumProducts(int iProductIndex, StringBuilder lpProductBuf);
|
||||||
|
|
||||||
public static string Icinga2InstallDir
|
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
|
||||||
|
static extern Int32 MsiGetProductInfo(string product, string property, [Out] StringBuilder valueBuf, ref Int32 len);
|
||||||
|
|
||||||
|
public static string Icinga2InstallDir
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Icinga Development Team\\ICINGA2");
|
StringBuilder szProduct;
|
||||||
|
|
||||||
if (rk == null)
|
for (int index = 0; ; index++) {
|
||||||
return "";
|
szProduct = new StringBuilder(39);
|
||||||
|
if (MsiEnumProducts(index, szProduct) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
return (string)rk.GetValue("");
|
int cbName = 128;
|
||||||
|
StringBuilder szName = new StringBuilder(cbName);
|
||||||
|
|
||||||
|
if (MsiGetProductInfo(szProduct.ToString(), "ProductName", szName, ref cbName) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (szName.ToString() != "Icinga 2")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int cbLocation = 1024;
|
||||||
|
StringBuilder szLocation = new StringBuilder(cbLocation);
|
||||||
|
if (MsiGetProductInfo(szProduct.ToString(), "InstallLocation", szLocation, ref cbLocation) == 0)
|
||||||
|
return szLocation.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <pwd.h>
|
# include <pwd.h>
|
||||||
# include <grp.h>
|
# include <grp.h>
|
||||||
|
#else /* _WIN32 */
|
||||||
|
# include <msi.h>
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
@ -125,30 +127,38 @@ int Main(void)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
bool builtinPaths = true;
|
bool builtinPaths = true;
|
||||||
|
|
||||||
HKEY hKey;
|
String prefix;
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Icinga Development Team\\ICINGA2", 0,
|
|
||||||
KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
|
|
||||||
BYTE pvData[MAX_PATH];
|
|
||||||
DWORD cbData = sizeof(pvData)-1;
|
|
||||||
DWORD lType;
|
|
||||||
if (RegQueryValueEx(hKey, NULL, NULL, &lType, pvData, &cbData) == ERROR_SUCCESS && lType == REG_SZ) {
|
|
||||||
pvData[cbData] = '\0';
|
|
||||||
|
|
||||||
String prefix = (char *)pvData;
|
char szProduct[39];
|
||||||
Application::DeclarePrefixDir(prefix);
|
bool foundMsi = false;
|
||||||
Application::DeclareSysconfDir(prefix + "\\etc");
|
|
||||||
Application::DeclareRunDir(prefix + "\\var\\run");
|
|
||||||
Application::DeclareLocalStateDir(prefix + "\\var");
|
|
||||||
Application::DeclarePkgDataDir(prefix + "\\share\\icinga2");
|
|
||||||
Application::DeclareIncludeConfDir(prefix + "\\share\\icinga2\\include");
|
|
||||||
|
|
||||||
|
for (int i = 0; MsiEnumProducts(i, szProduct) == ERROR_SUCCESS; i++) {
|
||||||
|
char szName[128];
|
||||||
|
DWORD cbName = sizeof(szName);
|
||||||
|
if (MsiGetProductInfo(szProduct, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, szName, &cbName) != ERROR_SUCCESS)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(szName, "Icinga 2") != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
char szLocation[1024];
|
||||||
|
DWORD cbLocation = sizeof(szLocation);
|
||||||
|
if (MsiGetProductInfo(szProduct, INSTALLPROPERTY_INSTALLLOCATION, szLocation, &cbLocation) == ERROR_SUCCESS) {
|
||||||
builtinPaths = false;
|
builtinPaths = false;
|
||||||
|
prefix = szLocation;
|
||||||
|
foundMsi = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (builtinPaths) {
|
if (!builtinPaths) {
|
||||||
|
Application::DeclarePrefixDir(prefix);
|
||||||
|
Application::DeclareSysconfDir(prefix + "\\etc");
|
||||||
|
Application::DeclareRunDir(prefix + "\\var\\run");
|
||||||
|
Application::DeclareLocalStateDir(prefix + "\\var");
|
||||||
|
Application::DeclarePkgDataDir(prefix + "\\share\\icinga2");
|
||||||
|
Application::DeclareIncludeConfDir(prefix + "\\share\\icinga2\\include");
|
||||||
|
} else {
|
||||||
Log(LogWarning, "icinga-app", "Registry key could not be read. Falling back to built-in paths.");
|
Log(LogWarning, "icinga-app", "Registry key could not be read. Falling back to built-in paths.");
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
Loading…
Reference in New Issue