build/
build-debug/
build-release/
+build32/
+build64/
debug/
release/
add_subdirectory(agent)
add_subdirectory(plugins)
+if(MSVC)
+ add_subdirectory(icinga-installer)
+endif()
+
if(ICINGA2_WITH_STUDIO)
add_subdirectory(icinga-studio)
endif()
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(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/icinga2.wixpatch")
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
# include <sys/types.h>
# include <pwd.h>
# include <grp.h>
-#else /* _WIN32 */
-# include <msi.h>
#endif /* _WIN32 */
using namespace icinga;
#ifdef _WIN32
bool builtinPaths = true;
- String prefix;
+ String prefix = Utility::GetIcingaInstallPath();
- char szProduct[39];
- bool foundMsi = false;
-
- 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;
- prefix = szLocation;
- foundMsi = true;
- break;
- }
- }
-
- if (!builtinPaths) {
+ if (!prefix.IsEmpty()) {
Application::DeclarePrefixDir(prefix);
Application::DeclareSysconfDir(prefix + "\\etc");
Application::DeclareRunDir(prefix + "\\var\\run");
--- /dev/null
+# Icinga 2
+# Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_executable(icinga-installer icinga-installer.cpp)
+
+include_directories(${Boost_INCLUDE_DIRS})
+target_link_libraries(icinga-installer ${Boost_LIBRARIES} base config cli)
+
+set_target_properties (
+ icinga-installer PROPERTIES
+ FOLDER Bin
+ OUTPUT_NAME icinga2-installer
+ LINK_FLAGS "/SUBSYSTEM:WINDOWS"
+)
+
+set(InstallPath "${CMAKE_INSTALL_SBINDIR}")
+
+install(
+ TARGETS icinga-installer
+ RUNTIME DESTINATION ${InstallPath}
+)
--- /dev/null
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License *
+ * as published by the Free Software Foundation; either version 2 *
+ * of the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software Foundation *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ******************************************************************************/
+
+#include "base/utility.hpp"
+#include "base/application.hpp"
+
+using namespace icinga;
+
+int InstallIcinga(void)
+{
+ MessageBox(NULL, "Install", "Icinga 2", 0);
+ return 0;
+}
+
+int UninstallIcinga(void)
+{
+ MessageBox(NULL, "Uninstall", "Icinga 2", 0);
+ return 0;
+}
+
+/**
+* Entry point for the installer application.
+*/
+int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+ /* must be called before using any other libbase functions */
+ Application::InitializeBase();
+
+ int rc;
+
+ if (strcmp(lpCmdLine, "install") == 0) {
+ rc = InstallIcinga();
+ } else if (strcmp(lpCmdLine, "uninstall") == 0) {
+ rc = UninstallIcinga();
+ } else {
+ MessageBox(NULL, "This application should only be run by the MSI installer package.", "Icinga 2 Installer", MB_ICONWARNING);
+ rc = 1;
+ }
+
+ Application::Exit(rc);
+}
--- /dev/null
+<CPackWiXPatch>
+ <CPackWiXFragment Id="#PRODUCT">
+ <CustomAction Id="XtraInstall" FileKey="CM_FP_sbin.icinga2_installer.exe" ExeCommand="install" Execute="deferred" Impersonate="no" />
+ <CustomAction Id="XtraUninstall" FileKey="CM_FP_sbin.icinga2_installer.exe" ExeCommand="uninstall" Execute="deferred" Impersonate="no" />
+
+ <InstallExecuteSequence>
+ <Custom Action="XtraInstall" Before="InstallFinalize">$CM_CP_sbin.icinga2_installer.exe>2</Custom>
+ <Custom Action="XtraUninstall" After="InstallInitialize">$CM_CP_sbin.icinga2_installer.exe=2</Custom>
+ </InstallExecuteSequence>
+ </CPackWiXFragment>
+</CPackWiXPatch>
\ No newline at end of file
# include <VersionHelpers.h>
# include <windows.h>
# include <io.h>
+# include <msi.h>
#endif /*_WIN32*/
using namespace icinga;
errno = EEXIST;
return -1;
}
-#endif /*_WIN32*/
+
+String Utility::GetIcingaInstallPath(void)
+{
+ char szProduct[39];
+
+ 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)
+ return szLocation;
+ }
+
+ return "";
+}
+
+#endif /* _WIN32 */
\ No newline at end of file
static String CreateTempFile(const String& path, int mode, std::fstream& fp);
+#ifdef _WIN32
+ static String GetIcingaInstallPath(void);
+#endif /* _WIN32 */
+
private:
Utility(void);
static void CollectPaths(const String& path, std::vector<String>& paths);