diff --git a/config.h.cmake b/config.h.cmake index 2a4fe035a..cc80a2e04 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -7,6 +7,7 @@ #cmakedefine HAVE_VFORK #define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}" +#define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}" #define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}" #define ICINGA_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2" diff --git a/doc/4.2-global-variables.md b/doc/4.2-global-variables.md index 247db3c15..becc1de5e 100644 --- a/doc/4.2-global-variables.md +++ b/doc/4.2-global-variables.md @@ -1,10 +1,11 @@ -## Global Variables +## Global Variables Icinga 2 provides a number of special global variables: Variable |Description --------------------------|------------------- IcingaPrefixDir |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. Defaults to /usr/local +IcingaSysconfDir |**Read-only.** Contains the path of the sysconf directory. Defaults to IcingaPrefixDir + "/etc". IcingaLocalStateDir |**Read-only.** Contains the path of the local state directory. Defaults to IcingaPrefixDir + "/var". IcingaPkgDataDir |**Read-only.** Contains the path of the package data directory. Defaults to IcingaPrefixDir + "/share/icinga2". IcingaStatePath |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to IcingaLocalStateDir + "/lib/icinga2/icinga2.state". diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 1a203521c..d10671b70 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -198,6 +198,7 @@ int main(int argc, char **argv) Application::InstallExceptionHandlers(); Application::DeclarePrefixDir(ICINGA_PREFIX); + Application::DeclareSysconfDir(ICINGA_SYSCONFDIR); Application::DeclareLocalStateDir(ICINGA_LOCALSTATEDIR); Application::DeclarePkgDataDir(ICINGA_PKGDATADIR); diff --git a/lib/base/application.cpp b/lib/base/application.cpp index f6220be8e..932e9f9b7 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -609,6 +609,26 @@ void Application::DeclarePrefixDir(const String& path) ScriptVariable::Declare("IcingaPrefixDir", path); } +/** + * Retrives the path of the sysconf dir. + * + * @returns The path. + */ +String Application::GetSysconfDir(void) +{ + return ScriptVariable::Get("IcingaSysconfDir"); +} + +/** + * Sets the path of the sysconf dir. + * + * @param path The new path. + */ +void Application::DeclareSysconfDir(const String& path) +{ + ScriptVariable::Declare("IcingaSysconfDir", path); +} + /** * Retrieves the path for the local state dir. * diff --git a/lib/base/application.h b/lib/base/application.h index 98e7ee1e5..720f43c70 100644 --- a/lib/base/application.h +++ b/lib/base/application.h @@ -73,6 +73,9 @@ public: static String GetPrefixDir(void); static void DeclarePrefixDir(const String& path); + static String GetSysconfDir(void); + static void DeclareSysconfDir(const String& path); + static String GetLocalStateDir(void); static void DeclareLocalStateDir(const String& path);