[icinga-checkins] icinga.org: icinga2/next: Move the sysdefines.conf file to /etc/sysconfig.

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


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

Author: Gerd von Egidy <gerd at egidy.de>
Date:   Sun Jun 15 19:47:27 2014 +0200

Move the sysdefines.conf file to /etc/sysconfig.

As /etc/sysconfig is distro specific, the filename used can be configured via the CMake parameter
ICINGA2_SYSCONFIGFILE

Refs #4794

---

 etc/CMakeLists.txt                                    |   13 ++++++++++---
 etc/initsystem/icinga2-prepare-dirs                   |    8 ++++----
 etc/initsystem/icinga2.init.d.cmake                   |   17 +++++++----------
 etc/initsystem/icinga2.service.cmake                  |    4 ++--
 .../icinga2.sysconfig.cmake}                          |    0
 icinga2.spec                                          |    2 +-
 6 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt
index 949da3a..e078e4d 100644
--- a/etc/CMakeLists.txt
+++ b/etc/CMakeLists.txt
@@ -76,10 +76,17 @@ else()
 endif()
 
 if(NOT WIN32)
-  configure_file(icinga2/sysdefines.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2/sysdefines.conf @ONLY)
+  if(NOT DEFINED ICINGA2_SYSCONFIGFILE)
+    set(ICINGA2_SYSCONFIGFILE "${CMAKE_INSTALL_SYSCONFDIR}/sysconfig/icinga2" CACHE PATH "where to store configuation for the init system, defaults to /etc/sysconfig/icinga2")
+  endif()
+
+  configure_file(initsystem/icinga2.sysconfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.sysconfig @ONLY)
+  get_filename_component(ICINGA2_SYSCONFIGFILE_NAME ${ICINGA2_SYSCONFIGFILE} NAME)
+  get_filename_component(ICINGA2_SYSCONFIGFILE_DIR ${ICINGA2_SYSCONFIGFILE} PATH)
   install(
-    FILES ${CMAKE_CURRENT_BINARY_DIR}/icinga2/sysdefines.conf
-    DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2
+    FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.sysconfig
+    DESTINATION ${ICINGA2_SYSCONFIGFILE_DIR}
+    RENAME ${ICINGA2_SYSCONFIGFILE_NAME}
     PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   )
 
diff --git a/etc/initsystem/icinga2-prepare-dirs b/etc/initsystem/icinga2-prepare-dirs
index a0c1891..8d55ac0 100644
--- a/etc/initsystem/icinga2-prepare-dirs
+++ b/etc/initsystem/icinga2-prepare-dirs
@@ -4,11 +4,11 @@
 #
 
 # load system specific defines
-SYSDEFFILE=$1
-if [ -f "$SYSDEFFILE" ]; then
-	. $SYSDEFFILE
+SYSCONFIGFILE=$1
+if [ -f "$SYSCONFIGFILE" ]; then
+	. $SYSCONFIGFILE
 else
-	echo "Error: You need to supply the path to the Icinga2 sysdefines.conf as parameter."
+	echo "Error: You need to supply the path to the Icinga2 sysconfig file as parameter."
 	exit 1
 fi
 
diff --git a/etc/initsystem/icinga2.init.d.cmake b/etc/initsystem/icinga2.init.d.cmake
index 50de2bf..eb8ec25 100644
--- a/etc/initsystem/icinga2.init.d.cmake
+++ b/etc/initsystem/icinga2.init.d.cmake
@@ -16,11 +16,11 @@
 ### END INIT INFO
 
 # load system specific defines
-SYSDEFFILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf
-if [ -f $SYSDEFFILE ]; then
-	. $SYSDEFFILE
+SYSCONFIGFILE=@ICINGA2_SYSCONFIGFILE@
+if [ -f $SYSCONFIGFILE ]; then
+	. $SYSCONFIGFILE
 else
-	echo "Can't load system specific defines from $SYSDEFFILE."
+	echo "Can't load system specific defines from $SYSCONFIGFILE."
 	exit 1
 fi
 
@@ -39,17 +39,14 @@ elif [ -f /etc/init.d/functions ]; then
 fi
 
 # Load extra environment variables
-if [ -f /etc/sysconfig/icinga ]; then
-        . /etc/sysconfig/icinga
-fi
-if [ -f /etc/default/icinga ]; then
-        . /etc/default/icinga
+if [ -f /etc/default/icinga2 ]; then
+        . /etc/default/icinga2
 fi
 
 # Start Icinga 2
 start() {
 	printf "Starting Icinga 2: "
-	@CMAKE_INSTALL_FULL_SBINDIR@/icinga2-prepare-dirs $SYSDEFFILE
+	@CMAKE_INSTALL_FULL_SBINDIR@/icinga2-prepare-dirs $SYSCONFIGFILE
 
 	if ! $DAEMON -c $ICINGA2_CONFIG_FILE -d -e $ICINGA2_ERROR_LOG -u $ICINGA2_USER -g $ICINGA2_GROUP > $ICINGA2_STARTUP_LOG 2>&1; then
 		echo "Error starting Icinga. Check '$ICINGA2_STARTUP_LOG' for details."
diff --git a/etc/initsystem/icinga2.service.cmake b/etc/initsystem/icinga2.service.cmake
index 2da628e..575eb7c 100644
--- a/etc/initsystem/icinga2.service.cmake
+++ b/etc/initsystem/icinga2.service.cmake
@@ -4,8 +4,8 @@ After=syslog.target postgresql.service mariadb.service
 
 [Service]
 Type=forking
-EnvironmentFile=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf
-ExecStartPre=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2-prepare-dirs @CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf
+EnvironmentFile=@ICINGA2_SYSCONFIGFILE@
+ExecStartPre=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2-prepare-dirs @ICINGA2_SYSCONFIGFILE@
 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
 ExecReload=/bin/kill -HUP $MAINPID
diff --git a/etc/icinga2/sysdefines.conf.cmake b/etc/initsystem/icinga2.sysconfig.cmake
similarity index 100%
rename from etc/icinga2/sysdefines.conf.cmake
rename to etc/initsystem/icinga2.sysconfig.cmake
diff --git a/icinga2.spec b/icinga2.spec
index 52bba06..eb49854 100644
--- a/icinga2.spec
+++ b/icinga2.spec
@@ -458,13 +458,13 @@ exit 0
 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
-%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/sysdefines.conf
 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/*.conf
 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/localhost/*.conf
 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
 %{_sbindir}/%{name}
 %{_bindir}/%{name}-build-ca
 %{_bindir}/%{name}-build-key



More information about the icinga-checkins mailing list