Unify resources for SysV-Init and systemd.

- Move system-specific defines like paths and usernames to /etc/icinga2/sysdefines.conf
  Do not use /etc/sysconfig for this as per suggestion on the systemd mailinglist: it is RedHat-specific
- Use /etc/icinga2/sysdefines.conf in SysV-Init and systemd
- Move both the sources of the SysV-Initscript and the systemd-service definition to etc/initsystem

Refs #4794

Conflicts:
	etc/initsystem/icinga2.init.d.cmake
This commit is contained in:
Gerd von Egidy 2014-05-18 22:47:27 +02:00
parent 59a1a133c3
commit ef49658474
4 changed files with 25 additions and 24 deletions

View File

@ -75,6 +75,15 @@ else()
) )
endif() 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) if(NOT WIN32)
option (USE_SYSTEMD option (USE_SYSTEMD
@ -82,25 +91,18 @@ if(NOT WIN32)
if (NOT USE_SYSTEMD) 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( install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/init.d/icinga2 FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
) )
else() 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( install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/systemd/icinga2.service FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.service
DESTINATION ${DESTDIR}/usr/lib/systemd/system DESTINATION ${DESTDIR}/usr/lib/systemd/system
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ 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
) )
endif() endif()
endif() endif()

View File

@ -1,6 +1,9 @@
DAEMON=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2
ICINGA2_CONFIG_FILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf ICINGA2_CONFIG_FILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf
ICINGA2_STATE_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@ 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_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_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/icinga2.log
ICINGA2_USER=@ICINGA2_USER@ ICINGA2_USER=@ICINGA2_USER@
ICINGA2_GROUP=@ICINGA2_GROUP@ ICINGA2_GROUP=@ICINGA2_GROUP@

View File

@ -15,17 +15,13 @@
# Description: Icinga 2 is a monitoring and management system for hosts, services and networks. # Description: Icinga 2 is a monitoring and management system for hosts, services and networks.
### END INIT INFO ### END INIT INFO
DAEMON=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 # load system specific defines
ICINGA2_CONFIG_FILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf if [ -f @CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf ]; then
ICINGA2_STATE_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@ . @CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf
ICINGA2_PID_FILE=$ICINGA2_STATE_DIR/run/icinga2/icinga2.pid else
ICINGA2_ERROR_LOG=$ICINGA2_STATE_DIR/log/icinga2/error.log echo "Can't load system specific defines from @CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf."
ICINGA2_STARTUP_LOG=$ICINGA2_STATE_DIR/log/icinga2/startup.log exit 1
ICINGA2_LOG=$ICINGA2_STATE_DIR/log/icinga2/icinga2.log fi
ICINGA2_USER=@ICINGA2_USER@
ICINGA2_GROUP=@ICINGA2_GROUP@
ICINGA2_COMMAND_USER=@ICINGA2_COMMAND_USER@
ICINGA2_COMMAND_GROUP=@ICINGA2_COMMAND_GROUP@
test -x $DAEMON || exit 0 test -x $DAEMON || exit 0

View File

@ -4,7 +4,7 @@ After=syslog.target postgresql.service mariadb.service
[Service] [Service]
Type=forking 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 # 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} 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 PIDFile=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/icinga2/icinga2.pid