]> granicus.if.org Git - icinga2/commitdiff
Make location of the /run directory configurable
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 22 Jul 2014 11:18:41 +0000 (13:18 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 22 Jul 2014 11:26:37 +0000 (13:26 +0200)
fixes #6627

16 files changed:
CMakeLists.txt
INSTALL
components/compat/CMakeLists.txt
components/compat/externalcommandlistener.ti
components/livestatus/livestatuslistener.ti
config.h.cmake
debian/rules
doc/3-monitoring-basics.md
doc/6-configuring-icinga-2.md
etc/initsystem/icinga2-prepare-dirs
etc/initsystem/icinga2.service.cmake
etc/initsystem/icinga2.sysconfig.cmake
icinga-app/CMakeLists.txt
icinga-app/icinga.cpp
lib/base/application.cpp
lib/base/application.hpp

index 24e3778fb51b7065a6e44627981e3d6bf982de4e..449f42f256562a41fb16ec4ed1b8b2dea70a8ecb 100644 (file)
@@ -31,10 +31,13 @@ endif()
 file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
 string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
 
+include(GNUInstallDirs)
+
 set(ICINGA2_USER "icinga" CACHE STRING "Icinga 2 user")
 set(ICINGA2_GROUP "icinga" CACHE STRING "Icinga 2 group")
 set(ICINGA2_COMMAND_USER "icinga" CACHE STRING "Icinga 2 command user")
 set(ICINGA2_COMMAND_GROUP "icingacmd" CACHE STRING "Icinga 2 command group")
+set(ICINGA2_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" CACHE STRING "/run directory")
 set(ICINGA2_PLUGIN_PATH "/usr/lib/nagios/plugins" CACHE STRING "Path for the check plugins")
 set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe")
 
@@ -121,7 +124,6 @@ if(HAVE_LIBEXECINFO)
   set(HAVE_BACKTRACE_SYMBOLS TRUE)
 endif()
 
-include(GNUInstallDirs)
 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
 
 install(
diff --git a/INSTALL b/INSTALL
index 06f530529759a515eb84a1f83a8d2d957c770d73..a3e0245f2a159194c59a666876ef402b5e47df74 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -127,6 +127,7 @@ variables are supported:
 - ICINGA2_GIT_VERSION_INFO: Whether to use Git to determine the version number; defaults to "ON"
 - ICINGA2_COMMAND_GROUP: The command group Icinga 2 should use; defaults to "icingacmd"
 - ICINGA2_PLUGIN_PATH: The path for the Monitoring Plugins project binaries; defaults to "/usr/lib/nagios/plugins"
+- ICINGA2_RUNDIR: The location of the "run" directory; defaults to CMAKE_INSTALL_LOCALSTATEDIR/run
 - CMAKE_INSTALL_SYSCONFDIR: The configuration directory; defaults to CMAKE_INSTALL_PREFIX/etc
 - ICINGA2_SYSCONFIGFILE: Where to put the config file the initscript/systemd pulls it's dirs from; 
                defaults to CMAKE_INSTALL_PREFIX/etc/sysconfig/icinga2
index 9e555ea61d9af19bd8605b07cb525d1e48b77d13..2efab5f20195091829851be02f0f1a0b34b25458 100644 (file)
@@ -37,5 +37,5 @@ install(TARGETS compat RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DEST
 install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2/compat/archives\")")
 install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/icinga2\")")
 install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run/icinga2/cmd\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_RUNDIR}/icinga2/cmd\")")
 
index 7ef94e73c2da954b54fa36502afcde59e1045c22..2a634b4d0e63bff80ed9f6da48d39019c52642cd 100644 (file)
@@ -7,7 +7,7 @@ namespace icinga
 class ExternalCommandListener : DynamicObject
 {
        [config] String command_path {
-               default {{{ return Application::GetLocalStateDir() + "/run/icinga2/cmd/icinga2.cmd"; }}}
+               default {{{ return Application::GetRunDir() + "/icinga2/cmd/icinga2.cmd"; }}}
        };
 };
 
index 61d85b9e974b62ec221f6b25ace2d4b7d123b4f0..0bd8e948993dc9e77f7f4d6528b3cec79d536286 100644 (file)
@@ -9,7 +9,7 @@ class LivestatusListener : DynamicObject {
                default {{{ return "unix"; }}}
        };
        [config] String socket_path {
-               default {{{ return Application::GetLocalStateDir() + "/run/icinga2/cmd/livestatus"; }}}
+               default {{{ return Application::GetRunDir() + "/icinga2/cmd/livestatus"; }}}
        };
        [config] String bind_host {
                default {{{ return "127.0.0.1"; }}}
index 71e42eee733bf9005e817c99983865777e3077fd..cde13a1735ff7b5cc4424f2318bbe1531682bb96 100644 (file)
@@ -9,6 +9,7 @@
 
 #define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
 #define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}"
+#define ICINGA_RUNDIR "${ICINGA2_RUNDIR}"
 #define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}"
 #define ICINGA_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2"
 #define ICINGA_INCLUDECONFDIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2/include"
index d7a5d84da5844b787fd792b721bb66b24b2fbae2..2a6e20d0483aef3dba0303db86f149f0d0a0a31a 100755 (executable)
@@ -22,6 +22,7 @@ override_dh_auto_configure:
        dh_auto_configure -- \
                -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
                -DCMAKE_INSTALL_SYSCONFDIR=/etc \
+               -DICINGA2_RUNDIR=/run \
                -DICINGA2_USER=nagios \
                -DICINGA2_GROUP=nagios \
                -DICINGA2_COMMAND_USER=nagios \
index 4c3c1e6ae175bad437e38d47866fa1f42ace8e59..3fe30520da884163f155baf2a37db28bc723d17c 100644 (file)
@@ -934,7 +934,7 @@ information in the check output (`-o`).
         PluginDir + "/process_check_result",
         "-H", "$host.name$",
         "-S", "$service.name$",
-        "-c", LocalStateDir + "/run/icinga2/cmd/icinga2.cmd",
+        "-c", RunDir + "/icinga2/cmd/icinga2.cmd",
         "-r", "0",
         "-o", "Event Handler triggered in state '$service.state$' with output '$service.output$'."
       ]
index 1440e1b28044e78c0b9d60c0ea2844c81da76c95..d6ae9bafdee285583e9f7848795af4b6610f4e54 100644 (file)
@@ -10,6 +10,7 @@ PrefixDir           |**Read-only.** Contains the installation prefix that was sp
 SysconfDir          |**Read-only.** Contains the path of the sysconf directory. Defaults to PrefixDir + "/etc".
 ZonesDir            |**Read-only.** Contains the path of the zones.d directory. Defaults to SysconfDir + "/zones.d".
 LocalStateDir       |**Read-only.** Contains the path of the local state directory. Defaults to PrefixDir + "/var".
+RunDir              |**Read-only.** Contains the path of the run directory. Defaults to LocalStateDir + "/run".
 PkgDataDir          |**Read-only.** Contains the path of the package data directory. Defaults to PrefixDir + "/share/icinga2".
 StatePath           |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to LocalStateDir + "/lib/icinga2/icinga2.state".
 PidPath             |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to LocalStateDir + "/run/icinga2/icinga2.pid".
@@ -1435,7 +1436,7 @@ Attributes:
   socket\_type      |**Optional.** Specifies the socket type. Can be either "tcp" or "unix". Defaults to "unix".
   bind\_host        |**Optional.** Only valid when socket\_type is "tcp". Host address to listen on for connections. Defaults to "127.0.0.1".
   bind\_port        |**Optional.** Only valid when `socket_type` is "tcp". Port to listen on for connections. Defaults to 6558.
-  socket\_path      |**Optional.** Only valid when `socket_type` is "unix". Specifies the path to the UNIX socket file. Defaults to LocalStateDir + "/run/icinga2/cmd/livestatus".
+  socket\_path      |**Optional.** Only valid when `socket_type` is "unix". Specifies the path to the UNIX socket file. Defaults to RunDir + "/icinga2/cmd/livestatus".
   compat\_log\_path |**Optional.** Required for historical table queries. Requires `CompatLogger` feature enabled. Defaults to LocalStateDir + "/log/icinga2/compat"
 
 > **Note**
@@ -1481,7 +1482,7 @@ Attributes:
 
   Name            |Description
   ----------------|----------------
-  command\_path   |**Optional.** Path to the command pipe. Defaults to LocalStateDir + "/run/icinga2/cmd/icinga2.cmd".
+  command\_path   |**Optional.** Path to the command pipe. Defaults to RunDir + "/icinga2/cmd/icinga2.cmd".
 
 ### <a id="objecttype-compatlogger"></a> CompatLogger
 
index 8d55ac077689a7109853e50231348847b14ce442..89aaa641669b6644fdcf8b3ac80a27db4a33b5f7 100644 (file)
@@ -28,6 +28,6 @@ if [ -f $ICINGA2_LOG ]; then
        chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_LOG
 fi
 
-mkdir -p $ICINGA2_STATE_DIR/run/icinga2/cmd
-chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_STATE_DIR/run/icinga2/cmd
-chmod 2755 $ICINGA2_STATE_DIR/run/icinga2/cmd
+mkdir -p $ICINGA2_RUN_DIR/icinga2/cmd
+chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_RUN_DIR/icinga2/cmd
+chmod 2755 $ICINGA2_RUN_DIR/icinga2/cmd
index e15c0040f5ff2a1b4cca3137264c19f6c0225fc7..815d57338eb2e8b4a5930451b4f5d5cbc5528180 100644 (file)
@@ -7,7 +7,7 @@ Type=forking
 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
+PIDFile=@ICINGA2_RUNDIR@/icinga2/icinga2.pid
 ExecReload=/bin/kill -HUP $MAINPID
 
 [Install]
index 4348b4d46f6a56fb11428f47f86c07633df8b435..8b65b801753dbbaba8a6feda1f7f10cd685274f3 100644 (file)
@@ -1,7 +1,8 @@
 DAEMON=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2
 ICINGA2_CONFIG_FILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf
+ICINGA2_RUN_DIR=@ICINGA2_RUNDIR@
 ICINGA2_STATE_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@
-ICINGA2_PID_FILE=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/icinga2/icinga2.pid
+ICINGA2_PID_FILE=$ICINGA2_RUN_DIR/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
index ee6eceff672b97258becfe4baf608f51608fd9c5..e729e07cf6367f683a2613427c3f8c03eda58298 100644 (file)
@@ -40,4 +40,4 @@ install(
 
 install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2\")")
 install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run/icinga2\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_RUNDIR}/icinga2\")")
index 513d8c211c03991f70800282ed660bedc5d7c6f9..93d8ec3a638b8040f13ea392748086c8c0652f4d 100644 (file)
@@ -300,6 +300,7 @@ int Main(void)
                        String prefix = (char *)pvData;
                        Application::DeclarePrefixDir(prefix);
                        Application::DeclareSysconfDir(prefix + "\\etc");
+                       Application::DeclareRunDir(prefix + "\\var\\run");
                        Application::DeclareLocalStateDir(prefix + "\\var");
                        Application::DeclarePkgDataDir(prefix + "\\share\\icinga2");
                        Application::DeclareIncludeConfDir(prefix + "\\share\\icinga2\\include");
@@ -316,6 +317,7 @@ int Main(void)
 #endif /* _WIN32 */
                Application::DeclarePrefixDir(ICINGA_PREFIX);
                Application::DeclareSysconfDir(ICINGA_SYSCONFDIR);
+               Application::DeclareRunDir(ICINGA_RUNDIR);
                Application::DeclareLocalStateDir(ICINGA_LOCALSTATEDIR);
                Application::DeclarePkgDataDir(ICINGA_PKGDATADIR);
                Application::DeclareIncludeConfDir(ICINGA_INCLUDECONFDIR);
@@ -380,7 +382,7 @@ int Main(void)
        }
 
        Application::DeclareStatePath(Application::GetLocalStateDir() + "/lib/icinga2/icinga2.state");
-       Application::DeclarePidPath(Application::GetLocalStateDir() + "/run/icinga2/icinga2.pid");
+       Application::DeclarePidPath(Application::GetRunDir() + "/icinga2/icinga2.pid");
 
 #ifndef _WIN32
        if (g_AppParams.count("group")) {
index 0d47989a71699a14657119d32f7a4a78a09ba206..a42cafcd61334d5087a414025727fc0bac6cb718 100644 (file)
@@ -459,6 +459,7 @@ void Application::DisplayVersionMessage(void)
                  << "* Application version: " << GetVersion() << std::endl
                  << "* Installation root: " << GetPrefixDir() << std::endl
                  << "* Sysconf directory: " << GetSysconfDir() << std::endl
+                 << "* Run directory: " << GetRunDir() << std::endl
                  << "* Local state directory: " << GetLocalStateDir() << std::endl
                  << "* Package data directory: " << GetPkgDataDir() << std::endl
                  << "* State path: " << GetStatePath() << std::endl
@@ -841,6 +842,26 @@ void Application::DeclareSysconfDir(const String& path)
        ScriptVariable::Set("SysconfDir", path, false);
 }
 
+/**
+ * Retrieves the path for the run dir.
+ *
+ * @returns The path.
+ */
+String Application::GetRunDir(void)
+{
+       return ScriptVariable::Get("RunDir");
+}
+
+/**
+ * Sets the path of the run dir.
+ *
+ * @param path The new path.
+ */
+void Application::DeclareRunDir(const String& path)
+{
+       ScriptVariable::Set("RunDir", path, false);
+}
+
 /**
  * Retrieves the path for the local state dir.
  *
@@ -852,13 +873,13 @@ String Application::GetLocalStateDir(void)
 }
 
 /**
- * Sets the path of the zones dir.
+ * Sets the path for the local state dir.
  *
  * @param path The new path.
  */
-void Application::DeclareZonesDir(const String& path)
+void Application::DeclareLocalStateDir(const String& path)
 {
-       ScriptVariable::Set("ZonesDir", path, false);
+       ScriptVariable::Set("LocalStateDir", path, false);
 }
 
 /**
@@ -872,13 +893,13 @@ String Application::GetZonesDir(void)
 }
 
 /**
- * Sets the path for the local state dir.
+ * Sets the path of the zones dir.
  *
  * @param path The new path.
  */
-void Application::DeclareLocalStateDir(const String& path)
+void Application::DeclareZonesDir(const String& path)
 {
-       ScriptVariable::Set("LocalStateDir", path, false);
+       ScriptVariable::Set("ZonesDir", path, false);
 }
 
 /**
index 1a221ebec862204454a35a39835778377e232925..c132ae196f06f36b5621e752e5f4c847f29438c3 100644 (file)
@@ -87,6 +87,9 @@ public:
        static String GetZonesDir(void);
        static void DeclareZonesDir(const String& path);
 
+       static String GetRunDir(void);
+       static void DeclareRunDir(const String& path);
+
        static String GetLocalStateDir(void);
        static void DeclareLocalStateDir(const String& path);