diff --git a/cmake/InstallConfig.cmake b/cmake/InstallConfig.cmake index 452abfadf..e4af25d5e 100644 --- a/cmake/InstallConfig.cmake +++ b/cmake/InstallConfig.cmake @@ -21,25 +21,20 @@ function(install_if_not_exists src dest) set(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}") endif() get_filename_component(src_name "${src}" NAME) - if (NOT IS_ABSOLUTE "${dest}") - set(dest "${CMAKE_INSTALL_PREFIX}/${dest}") - endif() get_filename_component(basename_dest "${src}" NAME) string(REPLACE "/" "\\\\" nsis_src "${src}") string(REPLACE "/" "\\\\" nsis_dest_dir "${real_dest}") string(REPLACE "/" "\\\\" nsis_dest "${real_dest}/${basename_dest}") - set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS} - SetOverwrite off - CreateDirectory '$INSTDIR\\\\${nsis_dest_dir}' - File '/oname=${nsis_dest}' '${nsis_src}' - SetOverwrite on - " PARENT_SCOPE) install(CODE " - if(NOT EXISTS \"\$ENV{DESTDIR}${dest}/${src_name}\") - #file(INSTALL \"${src}\" DESTINATION \"${dest}\") + if(\${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.* OR NOT EXISTS \"\$ENV{DESTDIR}${dest}/${src_name}\") message(STATUS \"Installing: \$ENV{DESTDIR}${dest}/${src_name}\") + if(\${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.*) + set(skel_prefix \"share/skel/\") + else() + set(skel_prefix \"\") + endif() execute_process(COMMAND \${CMAKE_COMMAND} -E copy \"${src}\" - \"\$ENV{DESTDIR}${dest}/${src_name}\" + \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\${skel_prefix}${dest}/${src_name}\" RESULT_VARIABLE copy_result ERROR_VARIABLE error_output) if(copy_result) diff --git a/icinga-installer/icinga-installer.cpp b/icinga-installer/icinga-installer.cpp index 022faa726..ea5c5d8e0 100644 --- a/icinga-installer/icinga-installer.cpp +++ b/icinga-installer/icinga-installer.cpp @@ -41,10 +41,24 @@ static void ExecuteIcingaCommand(const String& args) ExecuteCommand("\"" + GetIcingaInstallDir() + "\\sbin\\icinga2.exe\" " + args); } +static void CopyConfigFile(const String& installDir, const String& sourceConfigPath, size_t skelPrefixLength) +{ + String relativeConfigPath = sourceConfigPath.SubStr(installDir.GetLength() + skelPrefixLength); + + String targetConfigPath = installDir + relativeConfigPath; + + if (!Utility::PathExists(targetConfigPath)) { + Utility::MkDirP(Utility::DirName(targetConfigPath), 0700); + Utility::CopyFile(sourceConfigPath, targetConfigPath); + } +} + static int InstallIcinga(void) { String installDir = GetIcingaInstallDir(); + installDir = "C:\\Program Files\\Icinga2\\"; + ExecuteCommand("icacls \"" + installDir + "\" /grant *S-1-5-20:(oi)(ci)m"); ExecuteCommand("icacls \"" + installDir + "\\etc\" /inheritance:r /grant:r *S-1-5-20:(oi)(ci)m *S-1-5-32-544:(oi)(ci)f"); @@ -61,6 +75,9 @@ static int InstallIcinga(void) Utility::MkDirP(installDir + "/var/spool/icinga2/perfdata", 0700); Utility::MkDirP(installDir + "/var/spool/icinga2/tmp", 0700); + String skelDir = "/share/skel"; + Utility::GlobRecursive(installDir + skelDir, "*", boost::bind(&CopyConfigFile, installDir, _1, skelDir.GetLength()), GlobFile); + ExecuteIcingaCommand("--scm-install daemon"); return 0;