From e749f6eae5e4e4930319088e4a31af1005c16a53 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 20 Apr 2014 11:22:15 +0200 Subject: [PATCH] Make sure the installer doesn't overwrite config files. Refs #4865 --- CMakeLists.txt | 60 +++++++++++++------------- cmake/InstallConfig.cmake | 35 +++++++++++++++ etc/CMakeLists.txt | 90 +++++++++++++++++++-------------------- lib/base/timer.cpp | 1 + 4 files changed, 110 insertions(+), 76 deletions(-) create mode 100644 cmake/InstallConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d5097ba53..8a2f7786c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,35 +49,6 @@ else() configure_file(${CMAKE_CURRENT_BINARY_DIR}/icinga-version.h ${CMAKE_CURRENT_SOURCE_DIR}/icinga-version.h.fallback COPYONLY) endif() -set(CPACK_PACKAGE_NAME "Icinga2") -set(CPACK_PACKAGE_VENDOR "Icinga Development Team") -set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION}) -set(CPACK_NSIS_DISPLAY_NAME "Icinga 2") -set(CPACK_PACKAGE_INSTALL_DIRECTORY "ICINGA2") -set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico") -set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico") -set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico") -set(CPACK_NSIS_INSTALLED_ICON_NAME "sbin\\\\icinga2.exe") -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt") -set(CPACK_SOURCE_IGNORE_FILES "/.git/" "/debian/" "/.vagrant/" "/release/" "/debug/" "/build/" ) - -if(MSVC) - set(CPACK_NSIS_EXECUTABLES_DIRECTORY "sbin") - set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard") - set(CPACK_NSIS_MUI_FINISHPAGE_RUN "Icinga2SetupAgent") - - set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) - include(InstallRequiredSystemLibraries) - - install( - PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} - C:\\\\openssl\\\\bin\\\\libeay32.dll C:\\\\openssl\\\\bin\\\\ssleay32.dll - DESTINATION ${CMAKE_INSTALL_SBINDIR} - ) -endif() - -include(CPack) - if(WIN32) set(Boost_USE_STATIC_LIBS ON) add_definitions(-DBOOST_ALL_NO_LIB) @@ -159,3 +130,34 @@ add_subdirectory(itl) add_subdirectory(doc) add_subdirectory(test) add_subdirectory(pki) + +set(CPACK_PACKAGE_NAME "Icinga2") +set(CPACK_PACKAGE_VENDOR "Icinga Development Team") +set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION}) +set(CPACK_NSIS_DISPLAY_NAME "Icinga 2") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "ICINGA2") +set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico") +set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico") +set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico") +set(CPACK_NSIS_INSTALLED_ICON_NAME "sbin\\\\icinga2.exe") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt") +set(CPACK_SOURCE_IGNORE_FILES "/.git/" "/debian/" "/.vagrant/" "/release/" "/debug/" "/build/" ) + +set(CPACK_NSIS_EXECUTABLES_DIRECTORY "sbin") +set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard") +set(CPACK_NSIS_MUI_FINISHPAGE_RUN "Icinga2SetupAgent") + +set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) +include(InstallRequiredSystemLibraries) + +if(WIN32) + install( + PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} + C:\\\\openssl\\\\bin\\\\libeay32.dll C:\\\\openssl\\\\bin\\\\ssleay32.dll + DESTINATION ${CMAKE_INSTALL_SBINDIR} + ) +endif() + +message("${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}") + +include(CPack) \ No newline at end of file diff --git a/cmake/InstallConfig.cmake b/cmake/InstallConfig.cmake new file mode 100644 index 000000000..89779a6c2 --- /dev/null +++ b/cmake/InstallConfig.cmake @@ -0,0 +1,35 @@ +function(install_if_not_exists src dest) + set(real_dest "${dest}") + if(NOT IS_ABSOLUTE "${src}") + 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}\") + message(STATUS \"Installing: \$ENV{DESTDIR}${dest}/${src_name}\") + execute_process(COMMAND \${CMAKE_COMMAND} -E copy \"${src}\" + \"\$ENV{DESTDIR}${dest}/${src_name}\" + RESULT_VARIABLE copy_result + ERROR_VARIABLE error_output) + if(copy_result) + message(FATAL_ERROR \${error_output}) + endif() + else() + message(STATUS \"Skipping : \$ENV{DESTDIR}${dest}/${src_name}\") + endif() + ") +endfunction(install_if_not_exists) diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt index 3fabb506e..b6994d7d7 100644 --- a/etc/CMakeLists.txt +++ b/etc/CMakeLists.txt @@ -15,55 +15,49 @@ # along with this program; if not, write to the Free Software Foundation # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +include(InstallConfig) + configure_file(icinga/icinga-classic-apache.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga/icinga-classic-apache.conf) -install( - FILES icinga2/icinga2.conf icinga2/constants.conf - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2 -) - -install( - FILES icinga2/conf.d/commands.conf icinga2/conf.d/downtimes.conf icinga2/conf.d/generic-host.conf - icinga2/conf.d/generic-service.conf icinga2/conf.d/generic-user.conf icinga2/conf.d/groups.conf - icinga2/conf.d/notifications.conf icinga2/conf.d/timeperiods.conf icinga2/conf.d/users.conf - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d -) - -install( - FILES icinga2/conf.d/hosts/localhost.conf - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts -) - -install( - FILES icinga2/conf.d/hosts/localhost/disk.conf icinga2/conf.d/hosts/localhost/http.conf - icinga2/conf.d/hosts/localhost/icinga.conf icinga2/conf.d/hosts/localhost/kernel.conf - icinga2/conf.d/hosts/localhost/load.conf icinga2/conf.d/hosts/localhost/processes.conf - icinga2/conf.d/hosts/localhost/ssh.conf icinga2/conf.d/hosts/localhost/swap.conf - icinga2/conf.d/hosts/localhost/users.conf - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost -) - -install( - FILES icinga2/features-available/agent.conf icinga2/features-available/checker.conf - icinga2/features-available/command.conf icinga2/features-available/compatlog.conf - icinga2/features-available/debuglog.conf icinga2/features-available/graphite.conf - icinga2/features-available/ido-mysql.conf icinga2/features-available/ido-pgsql.conf - icinga2/features-available/livestatus.conf icinga2/features-available/mainlog.conf - icinga2/features-available/notification.conf icinga2/features-available/perfdata.conf - icinga2/features-available/statusdata.conf icinga2/features-available/syslog.conf - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available -) - -install( - FILES icinga2/scripts/check_kernel icinga2/scripts/mail-host-notification.sh - icinga2/scripts/mail-service-notification.sh - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts -) - -install( - FILES logrotate.d/icinga2 - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d -) +install_if_not_exists(icinga2/icinga2.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2) +install_if_not_exists(icinga2/constants.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2) +install_if_not_exists(icinga2/conf.d/commands.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/conf.d/downtimes.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/conf.d/generic-host.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/conf.d/generic-service.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/conf.d/generic-user.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/conf.d/groups.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/conf.d/hosts/localhost.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts) +install_if_not_exists(icinga2/conf.d/hosts/localhost/disk.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/hosts/localhost/http.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/hosts/localhost/icinga.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/hosts/localhost/kernel.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/hosts/localhost/load.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/hosts/localhost/processes.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/hosts/localhost/ssh.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/hosts/localhost/swap.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/hosts/localhost/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost) +install_if_not_exists(icinga2/conf.d/notifications.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/conf.d/timeperiods.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/conf.d/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d) +install_if_not_exists(icinga2/features-available/agent.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/checker.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/command.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/compatlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/debuglog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/graphite.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/ido-mysql.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/ido-pgsql.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/livestatus.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/mainlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/notification.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/perfdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/statusdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/features-available/syslog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) +install_if_not_exists(icinga2/scripts/check_kernel ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts) +install_if_not_exists(icinga2/scripts/mail-host-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts) +install_if_not_exists(icinga2/scripts/mail-service-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts) +install_if_not_exists(logrotate.d/icinga2 ${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d) if(NOT WIN32) install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")") @@ -86,3 +80,5 @@ if(NOT WIN32) PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) endif() + +set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE) diff --git a/lib/base/timer.cpp b/lib/base/timer.cpp index f39ce3b55..85b5cfa4f 100644 --- a/lib/base/timer.cpp +++ b/lib/base/timer.cpp @@ -260,6 +260,7 @@ void Timer::AdjustTimers(double adjustment) l_Timers.erase(timer); l_Timers.insert(timer); } + /* Notify the worker that we've rescheduled some timers. */ l_CV.notify_all(); }