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")
set(HAVE_BACKTRACE_SYMBOLS TRUE)
endif()
-include(GNUInstallDirs)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
install(
- 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
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\")")
class ExternalCommandListener : DynamicObject
{
[config] String command_path {
- default {{{ return Application::GetLocalStateDir() + "/run/icinga2/cmd/icinga2.cmd"; }}}
+ default {{{ return Application::GetRunDir() + "/icinga2/cmd/icinga2.cmd"; }}}
};
};
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"; }}}
#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"
dh_auto_configure -- \
-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+ -DICINGA2_RUNDIR=/run \
-DICINGA2_USER=nagios \
-DICINGA2_GROUP=nagios \
-DICINGA2_COMMAND_USER=nagios \
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$'."
]
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".
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**
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
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
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]
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
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\")")
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");
#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);
}
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")) {
<< "* 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
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.
*
}
/**
- * 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);
}
/**
}
/**
- * 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);
}
/**
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);