diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt index 4ae50d2b4..7f87ba7c8 100644 --- a/etc/CMakeLists.txt +++ b/etc/CMakeLists.txt @@ -75,6 +75,15 @@ else() ) endif() +if(NOT WIN32) + configure_file(icinga2/sysdefines.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2/sysdefines.conf @ONLY) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/icinga2/sysdefines.conf + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2 + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) +endif() + if(NOT WIN32) option (USE_SYSTEMD @@ -82,25 +91,18 @@ if(NOT WIN32) if (NOT USE_SYSTEMD) - configure_file(init.d/icinga2.cmake ${CMAKE_CURRENT_BINARY_DIR}/init.d/icinga2) + configure_file(initsystem/icinga2.init.d.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/init.d/icinga2 + FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2 DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) else() - configure_file(systemd/icinga2.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/systemd/icinga2.service @ONLY) + configure_file(initsystem/icinga2.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.service @ONLY) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/systemd/icinga2.service + FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.service DESTINATION ${DESTDIR}/usr/lib/systemd/system - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ - ) - - configure_file(systemd/icinga2.sysconfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/systemd/icinga2 @ONLY) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/systemd/icinga2 - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sysconfig - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) endif() endif() diff --git a/etc/systemd/icinga2.sysconfig.cmake b/etc/icinga2/sysdefines.conf.cmake similarity index 67% rename from etc/systemd/icinga2.sysconfig.cmake rename to etc/icinga2/sysdefines.conf.cmake index da0e51c38..4348b4d46 100644 --- a/etc/systemd/icinga2.sysconfig.cmake +++ b/etc/icinga2/sysdefines.conf.cmake @@ -1,6 +1,9 @@ +DAEMON=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 ICINGA2_CONFIG_FILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf ICINGA2_STATE_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@ +ICINGA2_PID_FILE=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/icinga2/icinga2.pid ICINGA2_ERROR_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/error.log +ICINGA2_STARTUP_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/startup.log ICINGA2_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/icinga2.log ICINGA2_USER=@ICINGA2_USER@ ICINGA2_GROUP=@ICINGA2_GROUP@ diff --git a/etc/init.d/icinga2.cmake b/etc/initsystem/icinga2.init.d.cmake similarity index 88% rename from etc/init.d/icinga2.cmake rename to etc/initsystem/icinga2.init.d.cmake index 007695e63..99b41ee0a 100644 --- a/etc/init.d/icinga2.cmake +++ b/etc/initsystem/icinga2.init.d.cmake @@ -15,17 +15,13 @@ # Description: Icinga 2 is a monitoring and management system for hosts, services and networks. ### END INIT INFO -DAEMON=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 -ICINGA2_CONFIG_FILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf -ICINGA2_STATE_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@ -ICINGA2_PID_FILE=$ICINGA2_STATE_DIR/run/icinga2/icinga2.pid -ICINGA2_ERROR_LOG=$ICINGA2_STATE_DIR/log/icinga2/error.log -ICINGA2_STARTUP_LOG=$ICINGA2_STATE_DIR/log/icinga2/startup.log -ICINGA2_LOG=$ICINGA2_STATE_DIR/log/icinga2/icinga2.log -ICINGA2_USER=@ICINGA2_USER@ -ICINGA2_GROUP=@ICINGA2_GROUP@ -ICINGA2_COMMAND_USER=@ICINGA2_COMMAND_USER@ -ICINGA2_COMMAND_GROUP=@ICINGA2_COMMAND_GROUP@ +# load system specific defines +if [ -f @CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf ]; then + . @CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf +else + echo "Can't load system specific defines from @CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf." + exit 1 +fi test -x $DAEMON || exit 0 diff --git a/etc/systemd/icinga2.service.cmake b/etc/initsystem/icinga2.service.cmake similarity index 88% rename from etc/systemd/icinga2.service.cmake rename to etc/initsystem/icinga2.service.cmake index 7fc386bd5..fb049f737 100644 --- a/etc/systemd/icinga2.service.cmake +++ b/etc/initsystem/icinga2.service.cmake @@ -4,7 +4,7 @@ After=syslog.target postgresql.service mariadb.service [Service] Type=forking -EnvironmentFile=/etc/sysconfig/icinga2 +EnvironmentFile=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf # ExecStartPre= TODO: execute the mkdir & chown/chmod stuff, ideally in a separate script, used by both init.d and systemd ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 -c ${ICINGA2_CONFIG_FILE} -d -e ${ICINGA2_ERROR_LOG} -u ${ICINGA2_USER} -g ${ICINGA2_GROUP} PIDFile=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/icinga2/icinga2.pid