[icinga-checkins] icinga.org: icinga2/next: Unify resources for SysV-Init and systemd.

git at icinga.org git at icinga.org
Sun Jun 15 20:27:42 CEST 2014


Module: icinga2
Branch: next
Commit: ef4965847413f9fb2f3154e52e69cd8e1c4ea8f1
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=ef4965847413f9fb2f3154e52e69cd8e1c4ea8f1

Author: Gerd von Egidy <gerd at egidy.de>
Date:   Sun May 18 22:47:27 2014 +0200

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

---

 etc/CMakeLists.txt                                 |   26 +++++++++++---------
 .../sysdefines.conf.cmake}                         |    3 +++
 .../icinga2.init.d.cmake}                          |   18 ++++++--------
 etc/{systemd => initsystem}/icinga2.service.cmake  |    2 +-
 4 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt
index 4ae50d2..7f87ba7 100644
--- a/etc/CMakeLists.txt
+++ b/etc/CMakeLists.txt
@@ -76,31 +76,33 @@ 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
      "Configure icinga as native systemd service instead of a SysV initscript" OFF) 
 
   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 da0e51c..4348b4d 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 007695e..99b41ee 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 7fc386b..fb049f7 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



More information about the icinga-checkins mailing list