]> granicus.if.org Git - icinga2/commitdiff
Improve path handling in cmake and daemon
authorMarkus Frosch <markus.frosch@icinga.com>
Tue, 31 Jul 2018 09:59:09 +0000 (11:59 +0200)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Tue, 7 Aug 2018 12:10:26 +0000 (14:10 +0200)
64 files changed:
CMakeLists.txt
INSTALL.md
cmake/SetFullDir.cmake [new file with mode: 0644]
config.h.cmake
doc/07-agent-based-monitoring.md
doc/08-advanced-topics.md
doc/09-object-types.md
doc/11-cli-commands.md
doc/15-troubleshooting.md
doc/17-language-reference.md
doc/icinga2.8
etc/CMakeLists.txt
etc/icinga2/conf.d/commands.conf
etc/icinga2/features-available/debuglog.conf
etc/icinga2/features-available/mainlog.conf
etc/initsystem/icinga2.init.d.cmake
etc/initsystem/icinga2.service.cmake
etc/initsystem/icinga2.sysconfig.cmake
etc/initsystem/prepare-dirs.cmake
etc/initsystem/safe-reload.cmake
etc/logrotate.d/icinga2.cmake
icinga-app/CMakeLists.txt
icinga-app/icinga.cpp
itl/CMakeLists.txt
itl/plugins-contrib.d/CMakeLists.txt
itl/plugins-contrib.d/databases.conf
itl/plugins-contrib.d/smart-attributes.conf
lib/base/CMakeLists.txt
lib/base/application.cpp
lib/base/application.hpp
lib/base/tlsutility.cpp
lib/checker/CMakeLists.txt
lib/cli/apisetuputility.cpp
lib/cli/daemoncommand.cpp
lib/cli/daemonutility.cpp
lib/cli/featureutility.cpp
lib/cli/nodesetupcommand.cpp
lib/cli/nodeutility.cpp
lib/cli/nodewizardcommand.cpp
lib/cli/objectlistcommand.cpp
lib/cli/troubleshootcommand.cpp
lib/cli/variablegetcommand.cpp
lib/cli/variablelistcommand.cpp
lib/cli/variableutility.cpp
lib/compat/CMakeLists.txt
lib/compat/checkresultreader.ti
lib/compat/compatlogger.ti
lib/compat/externalcommandlistener.ti
lib/compat/statusdatawriter.cpp
lib/compat/statusdatawriter.ti
lib/config/configitem.cpp
lib/db_ido_mysql/CMakeLists.txt
lib/db_ido_pgsql/CMakeLists.txt
lib/icinga/icingaapplication.cpp
lib/icinga/icingaapplication.hpp
lib/livestatus/CMakeLists.txt
lib/livestatus/livestatuslistener.ti
lib/notification/CMakeLists.txt
lib/perfdata/CMakeLists.txt
lib/perfdata/perfdatawriter.ti
lib/remote/CMakeLists.txt
lib/remote/apilistener-filesync.cpp
lib/remote/apilistener.cpp
lib/remote/configpackageutility.cpp

index e66efb2e83ddcbae8ff359be5e245129b28aa7b1..1af1318361d9bf5c520fc6f9bdd631fedb60291d 100644 (file)
@@ -47,19 +47,43 @@ string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
 
 include(GNUInstallDirs)
 include(InstallConfig)
+include(SetFullDir)
 
 set(ICINGA2_USER "icinga" CACHE STRING "Icinga 2 user")
 set(ICINGA2_GROUP "icinga" CACHE STRING "Icinga 2 group")
 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_PLUGINDIR "/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(ICINGA2_UNITY_BUILD ON CACHE BOOL "Whether to perform a unity build")
 set(ICINGA2_LTO_BUILD OFF CACHE BOOL "Whether to use LTO")
 
-if(NOT WIN32)
-  set(ICINGA2_SYSCONFIGFILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sysconfig/icinga2" CACHE PATH "where to store configuation for the init system, defaults to /etc/sysconfig/icinga2")
+set(ICINGA2_CONFIGDIR "${CMAKE_INSTALL_SYSCONFDIR}/icinga2" CACHE FILEPATH "Main config directory, e.g. /etc/icinga2")
+set(ICINGA2_CACHEDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/cache/icinga2" CACHE FILEPATH "Directory for cache files, e.g. /var/cache/icinga2")
+set(ICINGA2_DATADIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/icinga2" CACHE FILEPATH "Data directory for the daemon, e.g. /var/lib/icinga2")
+set(ICINGA2_LOGDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/log/icinga2" CACHE FILEPATH "Logging directory, e.g. /var/log/icinga2")
+set(ICINGA2_SPOOLDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/spool/icinga2" CACHE FILEPATH "Spooling directory, e.g. /var/spool/icinga2")
+set(ICINGA2_RUNDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/run" CACHE STRING "/run directory (deprecated, please use ICINGA2_INITRUNDIR)")
+set(ICINGA2_INITRUNDIR "${ICINGA2_RUNDIR}/icinga2" CACHE FILEPATH "Runtime data for the init system, e.g. /run/icinga2")
+
+set(ICINGA2_PKGDATADIR "${CMAKE_INSTALL_DATADIR}/icinga2" CACHE FILEPATH "Installed data, e.g. /usr/share/icinga2")
+set(ICINGA2_INCLUDEDIR "${ICINGA2_PKGDATADIR}/include" CACHE FILEPATH "Include directory for the ITL, e.g. /usr/share/icinga2/include")
+
+# ensure absolute paths
+set_full_dir(ICINGA2_FULL_CONFIGDIR "${ICINGA2_CONFIGDIR}")
+set_full_dir(ICINGA2_FULL_CACHEDIR "${ICINGA2_CACHEDIR}")
+set_full_dir(ICINGA2_FULL_DATADIR "${ICINGA2_DATADIR}")
+set_full_dir(ICINGA2_FULL_LOGDIR "${ICINGA2_LOGDIR}")
+set_full_dir(ICINGA2_FULL_SPOOLDIR "${ICINGA2_SPOOLDIR}")
+set_full_dir(ICINGA2_FULL_RUNDIR "${ICINGA2_RUNDIR}")
+set_full_dir(ICINGA2_FULL_INITRUNDIR "${ICINGA2_INITRUNDIR}")
+set_full_dir(ICINGA2_FULL_PKGDATADIR "${ICINGA2_PKGDATADIR}")
+set_full_dir(ICINGA2_FULL_INCLUDEDIR "${ICINGA2_INCLUDEDIR}")
+
+set(LOGROTATE_DIR "${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d" CACHE STRING "Location of logrotate configs, e.g. /etc/logrotate.d")
+set(BASHCOMPLETION_DIR "${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d" CACHE STRING "Location of bash_completion files, e.g. /etc/bash_completion.d")
 
+if(NOT WIN32)
+  set(ICINGA2_SYSCONFIGFILE "${CMAKE_INSTALL_SYSCONFDIR}/sysconfig/icinga2" CACHE PATH "where to store configuation for the init system, defaults to /etc/sysconfig/icinga2")
 endif()
 
 site_name(ICINGA2_BUILD_HOST_NAME)
index 6c3b9aa0b1d116d10776d4784dec30383b838dc2..a2855227df0fe2447c1c0acf8f95ef16ef3ec5da 100644 (file)
@@ -130,16 +130,26 @@ $ cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/icinga2
 
 In addition to `CMAKE_INSTALL_PREFIX` here are most of the supported Icinga-specific cmake variables.
 
+For all variables regarding defaults paths on in CMake, see
+[GNUInstallDirs](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html).
+
+Also see `CMakeLists.txt` for details.
+
 **System Environment**
+- `CMAKE_INSTALL_SYSCONFDIR`: The configuration directory; defaults to `CMAKE_INSTALL_PREFIX/etc`
+- `CMAKE_INSTALL_LOCALSTATEDIR`: The state directory; defaults to `CMAKE_INSTALL_PREFIX/var`
+- `ICINGA2_CONFIGDIR`: Main config directory; defaults to `CMAKE_INSTALL_SYSCONFDIR/icinga2` usually `/etc/icinga2`
+- `ICINGA2_CACHEDIR`: Directory for cache files; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/cache/icinga2` usually `/var/cache/icinga2`
+- `ICINGA2_DATADIR`: Data directory  for the daemon; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/lib/icinga2` usually `/var/lib/icinga2`
+- `ICINGA2_LOGDIR`: Logfiles of the daemon; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/log/icinga2 usually `/var/log/icinga2`
+- `ICINGA2_SPOOLDIR`: Spooling directory ; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/spool/icinga2` usually `/var/spool/icinga2`
+- `ICINGA2_INITRUNDIR`: Runtime data for the init system; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/run/icinga2` usually `/run/icinga2`
 - `ICINGA2_GIT_VERSION_INFO`: Whether to use Git to determine the version number; defaults to `ON`
 - `ICINGA2_USER`: The user Icinga 2 should run as; defaults to `icinga`
 - `ICINGA2_GROUP`: The group Icinga 2 should run as; defaults to `icinga`
 - `ICINGA2_COMMAND_GROUP`: The command group Icinga 2 should use; defaults to `icingacmd`
-- `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`
-- `CMAKE_INSTALL_LOCALSTATEDIR`: The state directory; defaults to `CMAKE_INSTALL_PREFIX/var`
 - `ICINGA2_PLUGINDIR`: The path for the Monitoring Plugins project binaries; defaults to `/usr/lib/nagios/plugins`
 
 **Build Optimization**
diff --git a/cmake/SetFullDir.cmake b/cmake/SetFullDir.cmake
new file mode 100644 (file)
index 0000000..bd63a68
--- /dev/null
@@ -0,0 +1,26 @@
+# Icinga 2
+# Copyright (C) 2018 Icinga Development Team (https://www.icinga.com)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Ensures a directory is absolute by prefixing CMAKE_INSTALL_PREFIX if it is not
+# similar to CMAKE_INSTALL_FULL_... https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
+function(set_full_dir var path)
+  if(NOT IS_ABSOLUTE "${path}")
+    message(STATUS "Prefixing in ${var} \"${path}\" with ${CMAKE_INSTALL_PREFIX}")
+    set(path "${CMAKE_INSTALL_PREFIX}/${path}")
+  endif()
+  set(${var} "${path}" PARENT_SCOPE)
+endfunction(set_full_dir)
index c461e029f93a2740900a1187c94362353ac27fe5..16fa190f17e7ccf3b97ccfc2443ed1ad6fb16a0b 100644 (file)
 
 #cmakedefine ICINGA2_UNITY_BUILD
 
-#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"
+#define ICINGA_CONFIGDIR "${ICINGA2_FULL_CONFIGDIR}"
+#define ICINGA_DATADIR "${ICINGA2_FULL_DATADIR}"
+#define ICINGA_LOGDIR "${ICINGA2_FULL_LOGDIR}"
+#define ICINGA_CACHEDIR "${ICINGA2_FULL_CACHEDIR}"
+#define ICINGA_SPOOLDIR "${ICINGA2_FULL_SPOOLDIR}"
+#define ICINGA_INITRUNDIR "${ICINGA2_FULL_INITRUNDIR}"
+#define ICINGA_INCLUDECONFDIR "${ICINGA2_FULL_INCLUDEDIR}"
 #define ICINGA_USER "${ICINGA2_USER}"
 #define ICINGA_GROUP "${ICINGA2_GROUP}"
-#define ICINGA_SYSCONFIGFILE "${ICINGA2_SYSCONFIGFILE}"
 #define ICINGA_BUILD_HOST_NAME "${ICINGA2_BUILD_HOST_NAME}"
 #define ICINGA_BUILD_COMPILER_NAME "${ICINGA2_BUILD_COMPILER_NAME}"
 #define ICINGA_BUILD_COMPILER_VERSION "${ICINGA2_BUILD_COMPILER_VERSION}"
 
+// Deprecated options?
+#define ICINGA_PKGDATADIR "${ICINGA2_FULL_PKGDATADIR}"
+#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
+#define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}"
+#define ICINGA_RUNDIR "${ICINGA2_FULL_RUNDIR}"
+#define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}"
+
 #endif /* CONFIG_H */
index e2597a3410fad647a6794c4912f5d526d28ad0bd..48c0d1cf8f20a376dc2671d49ddfab6aeba3a8c8 100644 (file)
@@ -211,7 +211,7 @@ match your Icinga convention.
 Add an `EventCommand` configuration object for the passive service auto reset event.
 
     object EventCommand "coldstart-reset-event" {
-      command = [ SysconfDir + "/icinga2/conf.d/custom/scripts/coldstart_reset_event.sh" ]
+      command = [ ConfigDir + "/conf.d/custom/scripts/coldstart_reset_event.sh" ]
 
       arguments = {
         "-i" = "$service.state_id$"
@@ -356,4 +356,3 @@ passive update with the state and text from the second and third varbind:
       vars.dummy_state      = 2
       vars.dummy_text       = "No passive check result received."
     }
-
index 44b41dffb344b683b0f78ecfab3bd6aacfe5e4a2..58ce96310c6e8eb30c0ddfa281edef7d2ccd79f2 100644 (file)
@@ -990,7 +990,7 @@ You can omit the `log()` calls, they only help debugging.
         log("Running command")
         log(mailscript)
 
-        var cmd = [ SysconfDir + "/icinga2/scripts/" + mailscript ]
+        var cmd = [ ConfigDir + "/scripts/" + mailscript ]
         log(LogCritical, "me", cmd)
         return cmd
       }}
index 2d81d3ee3f61f091be3f7e5f378c7b4673614ebc..f169ebeb8ad203e32704b757824ebabb6d703a2b 100644 (file)
@@ -76,12 +76,12 @@ The ApiListener type expects its certificate files to be in the following locati
 
   Type                 | Location
   ---------------------|-------------------------------------
-  Private key          | `LocalStateDir + "/lib/icinga2/certs/" + NodeName + ".key"`
-  Certificate file     | `LocalStateDir + "/lib/icinga2/certs/" + NodeName + ".crt"`
-  CA certificate file  | `LocalStateDir + "/lib/icinga2/certs/ca.crt"`
+  Private key          | `DataDir + "/certs/" + NodeName + ".key"`
+  Certificate file     | `DataDir + "/certs/" + NodeName + ".crt"`
+  CA certificate file  | `DataDir + "/certs/ca.crt"`
 
 If the deprecated attributes `cert_path`, `key_path` and/or `ca_path` are specified Icinga 2
-copies those files to the new location in `LocalStateDir + "/lib/icinga2/certs"` unless the
+copies those files to the new location in `DataDir + "/certs"` unless the
 file(s) there are newer.
 
 Please check the [upgrading chapter](16-upgrading-icinga-2.md#upgrading-to-2-8-certificate-paths) for more details.
@@ -273,7 +273,7 @@ Configuration Attributes:
 
   Name                      | Type                  | Description
   --------------------------|-----------------------|----------------------------------
-  spool\_dir                | String                | **Optional.** The directory which contains the check result files. Defaults to LocalStateDir + "/lib/icinga2/spool/checkresults/".
+  spool\_dir                | String                | **Optional.** The directory which contains the check result files. Defaults to DataDir + "/spool/checkresults/".
 
 ## Comment <a id="objecttype-comment"></a>
 
@@ -322,7 +322,7 @@ Configuration Attributes:
 
   Name                      | Type                  | Description
   --------------------------|-----------------------|----------------------------------
-  log\_dir                  | String                | **Optional.** Path to the compat log directory. Defaults to LocalStateDir + "/log/icinga2/compat".
+  log\_dir                  | String                | **Optional.** Path to the compat log directory. Defaults to LogDir + "/compat".
   rotation\_method          | String                | **Optional.** Specifies when to rotate log files. Can be one of "HOURLY", "DAILY", "WEEKLY" or "MONTHLY". Defaults to "HOURLY".
 
 
@@ -1084,7 +1084,7 @@ Configuration Attributes:
   bind\_host                | String                | **Optional.** Only valid when `socket_type` is set to `tcp`. Host address to listen on for connections. Defaults to `127.0.0.1`.
   bind\_port                | Number                | **Optional.** Only valid when `socket_type` is set to `tcp`. Port to listen on for connections. Defaults to `6558`.
   socket\_path              | String                | **Optional.** Only valid when `socket_type` is set to `unix`. Specifies the path to the UNIX socket file. Defaults to RunDir + "/icinga2/cmd/livestatus".
-  compat\_log\_path         | String                | **Optional.** Path to Icinga 1.x log files. Required for historical table queries. Requires `CompatLogger` feature enabled. Defaults to LocalStateDir + "/log/icinga2/compat"
+  compat\_log\_path         | String                | **Optional.** Path to Icinga 1.x log files. Required for historical table queries. Requires `CompatLogger` feature enabled. Defaults to LogDir + "/compat"
 
 > **Note**
 >
@@ -1179,7 +1179,7 @@ Example:
 
 ```
 object NotificationCommand "mail-service-notification" {
-  command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
+  command = [ ConfigDir + "/scripts/mail-service-notification.sh" ]
 
   arguments += {
     "-4" = {
@@ -1329,10 +1329,10 @@ Configuration Attributes:
 
   Name                      | Type                  | Description
   --------------------------|-----------------------|----------------------------------
-  host\_perfdata\_path      | String                | **Optional.** Path to the host performance data file. Defaults to LocalStateDir + "/spool/icinga2/perfdata/host-perfdata".
-  service\_perfdata\_path   | String                | **Optional.** Path to the service performance data file. Defaults to LocalStateDir + "/spool/icinga2/perfdata/service-perfdata".
-  host\_temp\_path          | String                | **Optional.** Path to the temporary host file. Defaults to LocalStateDir + "/spool/icinga2/tmp/host-perfdata".
-  service\_temp\_path       | String                | **Optional.** Path to the temporary service file. Defaults to LocalStateDir + "/spool/icinga2/tmp/service-perfdata".
+  host\_perfdata\_path      | String                | **Optional.** Path to the host performance data file. Defaults to SpoolDir + "/perfdata/host-perfdata".
+  service\_perfdata\_path   | String                | **Optional.** Path to the service performance data file. Defaults to SpoolDir + "/perfdata/service-perfdata".
+  host\_temp\_path          | String                | **Optional.** Path to the temporary host file. Defaults to SpoolDir + "/tmp/host-perfdata".
+  service\_temp\_path       | String                | **Optional.** Path to the temporary service file. Defaults to SpoolDir + "/tmp/service-perfdata".
   host\_format\_template    | String                | **Optional.** Host Format template for the performance data file. Defaults to a template that's suitable for use with PNP4Nagios.
   service\_format\_template | String                | **Optional.** Service Format template for the performance data file. Defaults to a template that's suitable for use with PNP4Nagios.
   rotation\_interval        | Duration              | **Optional.** Rotation interval for the files specified in `{host,service}_perfdata_path`. Defaults to `30s`.
@@ -1534,8 +1534,8 @@ Configuration Attributes:
 
   Name                      | Type                  | Description
   --------------------------|-----------------------|----------------------------------
-  status\_path              | String                | **Optional.** Path to the `status.dat` file. Defaults to LocalStateDir + "/cache/icinga2/status.dat".
-  objects\_path             | String                | **Optional.** Path to the `objects.cache` file. Defaults to LocalStateDir + "/cache/icinga2/objects.cache".
+  status\_path              | String                | **Optional.** Path to the `status.dat` file. Defaults to CacheDir + "/status.dat".
+  objects\_path             | String                | **Optional.** Path to the `objects.cache` file. Defaults to CacheDir + "/objects.cache".
   update\_interval          | Duration              | **Optional.** The interval in which the status files are updated. Defaults to `15s`.
 
 
index 1b50116838fd0c2bb69eee9b9d9c949e22e256ce..012fe72f3182523edb713f58bcf1fe707d3adf72 100644 (file)
@@ -402,7 +402,7 @@ Configuration files are processed in the order they're specified on the command-
 
 When no configuration file is specified and the `--no-config` is not used
 Icinga 2 automatically falls back to using the configuration file
-`SysconfDir + "/icinga2/icinga2.conf"` (where SysconfDir is usually `/etc`).
+`ConfigDir + "/icinga2.conf"` (where ConfigDir is usually `/etc/icinga2`).
 
 ### Validation <a id="cli-command-daemon-validation"></a>
 
@@ -730,4 +730,3 @@ safely reload the Icinga 2 daemon.
 The `reload` action will send the `SIGHUP` signal to the Icinga 2 daemon
 which will validate the configuration in a separate process and not stop
 the other events like check execution, notifications, etc.
-
index d78bc9aa08efa110c737d49d6fdf24ebee61647a..e4758921fd683bf96ec138819737649ebc7ddd9e 100644 (file)
@@ -237,9 +237,9 @@ include <itl>
 include <plugins>
 ```
 
-in the [icinga2.conf](04-configuring-icinga-2.md#icinga2-conf) configuration file. These files are not considered configuration files and will be overridden
-on upgrade, so please send modifications as proposed patches upstream. The default include path is set to
-`LocalStateDir + "/share/icinga2/includes"`.
+in the [icinga2.conf](04-configuring-icinga-2.md#icinga2-conf) configuration file. These files are not considered
+configuration files and will be overridden on upgrade, so please send modifications as proposed patches upstream.
+The default include path is set to `/usr/share/icinga2/includes` with the constant `IncludeConfDir`.
 
 You should add your own command definitions to a new file in `conf.d/` called `commands.conf`
 or similar.
index 285a9fcb9876eddfbc94b63988088bc7fee6ad2f..91828f753939ebdf570ea4b3f331f9a85da3c394 100644 (file)
@@ -388,31 +388,51 @@ once they are set.
 
 Icinga 2 provides a number of special global constants. Some of them can be overridden using the `--define` command line parameter:
 
+Defaults for paths in `/etc` and `/var` are based on `SysconfDir` and `LocalStateDir` respectively.
+
 Variable            |Description
 --------------------|-------------------
-PrefixDir           |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. Defaults to "/usr/local".
-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".
-ObjectsPath         |**Read-write.** Contains the path of the Icinga 2 objects file. Defaults to LocalStateDir + "/cache/icinga2/icinga2.debug".
-PidPath             |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to RunDir + "/icinga2/icinga2.pid".
+ConfigDir           |**Read-only.** Main configuration directory. Usually set to `/etc/icinga2`.
+DataDir             |**Read-only.** Runtime data for the Icinga daemon. Usually set to `/var/lib/icinga2`.
+LogDir              |**Read-only.** Logfiles from the daemon. Usually set to `/var/log/icinga2`.
+CacheDir            |**Read-only.** Cached status information of the daemon. Usually set to `/var/cache/icinga2`.
+SpoolDir            |**Read-only.** Spool directory for certain data outputs. Usually set to `/var/spool/icinga2`.
+InitRunDir          |**Read-only.** Directory for PID files and sockets in daemon mode. Usually set to `/run/icinga2`.
+ZonesDir            |**Read-only.** Contains the path of the zones.d directory. Defaults to `ConfigDir + "/zones.d"`.
 Vars                |**Read-write.** Contains a dictionary with global custom attributes. Not set by default.
 NodeName            |**Read-write.** Contains the cluster node name. Set to the local hostname by default.
 RunAsUser           |**Read-write.** Defines the user the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig.
 RunAsGroup          |**Read-write.** Defines the group the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig.
-PlatformName        |**Read-only.** The name of the operating system, e.g. "Ubuntu".
-PlatformVersion     |**Read-only.** The version of the operating system, e.g. "14.04.3 LTS".
-PlatformKernel      |**Read-only.** The name of the operating system kernel, e.g. "Linux".
-PlatformKernelVersion|**Read-only.** The version of the operating system kernel, e.g. "3.13.0-63-generic".
-BuildCompilerName   |**Read-only.** The name of the compiler Icinga was built with, e.g. "Clang".
-BuildCompilerVersion|**Read-only.** The version of the compiler Icinga was built with, e.g. "7.3.0.7030031".
-BuildHostName       |**Read-only.** The name of the host Icinga was built on, e.g. "acheron".
-ApplicationVersion  |**Read-only.** The application version, e.g. "2.9.0".
-MaxConcurrentChecks |**Read-write**. The number of max checks run simultaneously. Defaults to 512.
-Environment         |**Read-write**. The name of the Icinga environment. Included in the SNI host name when making outbound connections. Defaults to "production".
+PlatformName        |**Read-only.** The name of the operating system, e.g. `Ubuntu`.
+PlatformVersion     |**Read-only.** The version of the operating system, e.g. `14.04.3 LTS`.
+PlatformKernel      |**Read-only.** The name of the operating system kernel, e.g. `Linux`.
+PlatformKernelVersion|**Read-only.** The version of the operating system kernel, e.g. `3.13.0-63-generic`.
+BuildCompilerName   |**Read-only.** The name of the compiler Icinga was built with, e.g. `Clang`.
+BuildCompilerVersion|**Read-only.** The version of the compiler Icinga was built with, e.g. `7.3.0.7030031`.
+BuildHostName       |**Read-only.** The name of the host Icinga was built on, e.g. `acheron`.
+ApplicationVersion  |**Read-only.** The application version, e.g. `2.9.0`.
+MaxConcurrentChecks |**Read-write**. The number of max checks run simultaneously. Defaults to `512`.
+Environment         |**Read-write**. The name of the Icinga environment. Included in the SNI host name when making outbound connections. Defaults to `production`.
+
+Certain variables are used to define file paths, you should never need to change them, as they are built based on
+constants above.
+
+Variable            |Description
+--------------------|-------------------
+StatePath           |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to `DataDir + "/icinga2.state"`.
+ObjectsPath         |**Read-write.** Contains the path of the Icinga 2 objects file. Defaults to `CacheDir + "/icinga2.debug"`.
+PidPath             |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to `InitRunDir + "/icinga2.pid"`.
+PkgDataDir          |**Read-only.** Contains the path of the package data directory. Defaults to `PrefixDir + "/share/icinga2"`.
+
+Some constants have been used in the past, but are deprecated now. They are stil involved in building Icinga,
+see `INSTALL.md`, but please avoid using them for runtime config!
+
+Variable            |Description
+--------------------|-------------------
+PrefixDir           |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. `Defaults to "/usr/local"`.
+SysconfDir          |**Read-only.** Contains the path of the sysconf directory. Defaults to `PrefixDir + "/etc"`.
+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"`.
 
 
 Advanced runtime constants. Please only use them if advised by support or developers.
@@ -733,12 +753,12 @@ You can explicitly access the `this` scope using the `this` keyword:
 
     object Host "localhost" {
       var check_interval = 5m
-  
+
       /* This explicitly specifies that the attribute should be set
        * for the host, if we had omitted `this.` the (poorly named)
        * local variable `check_interval` would have been modified instead.
        */
-      this.check_interval = 1m 
+      this.check_interval = 1m
   }
 
 Similarly the keywords `locals` and `globals` are available to access the local and global scope.
@@ -748,7 +768,7 @@ a function is set to whichever object was used to invoke the function. Here's an
 
      hm = {
        h_word = null
+
        function init(word) {
          h_word = word
        }
@@ -1024,4 +1044,3 @@ You can escape the `include` keyword by prefixing it with an additional `@` char
 
       vars.@include = "some cmdb export field"
     }
-
index 81fd9dba84373228f5d0b696b0c4bfa56f0610c5..f9ea45bb7fc7f3eb9fd975d2bfd26b43b415e00d 100644 (file)
@@ -69,9 +69,9 @@ Config files are processed in the order they are specified on the command-line.
 When no configuration file is specified and the
 .B --no-config
 is not used, Icinga 2 automatically falls back to using the configuration file
-.B SysconfDir + "/icinga2/icinga2.conf"
-(where SysconfDir is usually
-.BI "/etc" ")."
+.B ConfigDir + "/icinga2.conf"
+(where ConfigDir is usually
+.BI "/etc/icinga2" ")."
 
 .TP
 .B "-z, --noconfig"
index bffca3016ade3d16cd3bafe16efcf1fc0b7270c8..4c967cc43ee18c513b2a4f3a30023fdcfd61cc49 100644 (file)
@@ -24,55 +24,52 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
 endif()
 
 if(NOT WIN32)
-  install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/icinga2/constants.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
-       install_if_not_exists(icinga2/icinga2.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
+  install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/icinga2/constants.conf ${ICINGA2_CONFIGDIR})
+       install_if_not_exists(icinga2/icinga2.conf ${ICINGA2_CONFIGDIR})
 else()
-  install_if_not_exists(${CMAKE_CURRENT_SOURCE_DIR}/icinga2/win32/constants.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
-               install_if_not_exists(icinga2/win32/icinga2.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
+  install_if_not_exists(${CMAKE_CURRENT_SOURCE_DIR}/icinga2/win32/constants.conf ${ICINGA2_CONFIGDIR})
+               install_if_not_exists(icinga2/win32/icinga2.conf ${ICINGA2_CONFIGDIR})
 endif()
 
-install_if_not_exists(icinga2/zones.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
-install_if_not_exists(icinga2/conf.d/app.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-install_if_not_exists(icinga2/conf.d/commands.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-install_if_not_exists(icinga2/conf.d/downtimes.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-install_if_not_exists(icinga2/conf.d/groups.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/zones.conf ${ICINGA2_CONFIGDIR})
+install_if_not_exists(icinga2/conf.d/app.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/commands.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/downtimes.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/groups.conf ${ICINGA2_CONFIGDIR}/conf.d)
 
 if(NOT WIN32)
-  install_if_not_exists(icinga2/conf.d/hosts.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-       install_if_not_exists(icinga2/conf.d/services.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+  install_if_not_exists(icinga2/conf.d/hosts.conf ${ICINGA2_CONFIGDIR}/conf.d)
+       install_if_not_exists(icinga2/conf.d/services.conf ${ICINGA2_CONFIGDIR}/conf.d)
 else()
-  install_if_not_exists(icinga2/conf.d/win32/hosts.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-       install_if_not_exists(icinga2/conf.d/win32/services.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+  install_if_not_exists(icinga2/conf.d/win32/hosts.conf ${ICINGA2_CONFIGDIR}/conf.d)
+       install_if_not_exists(icinga2/conf.d/win32/services.conf ${ICINGA2_CONFIGDIR}/conf.d)
 endif()
 
-install_if_not_exists(icinga2/conf.d/notifications.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-install_if_not_exists(icinga2/conf.d/templates.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-install_if_not_exists(icinga2/conf.d/timeperiods.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-install_if_not_exists(icinga2/conf.d/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
-install_if_not_exists(icinga2/features-available/api.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
-install_if_not_exists(icinga2/features-available/debuglog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
-install_if_not_exists(icinga2/features-available/mainlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/conf.d/notifications.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/templates.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/timeperiods.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/users.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/features-available/api.conf ${ICINGA2_CONFIGDIR}/features-available)
+install_if_not_exists(icinga2/features-available/debuglog.conf ${ICINGA2_CONFIGDIR}/features-available)
+install_if_not_exists(icinga2/features-available/mainlog.conf ${ICINGA2_CONFIGDIR}/features-available)
 if(NOT WIN32)
-  install_if_not_exists(icinga2/features-available/syslog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+  install_if_not_exists(icinga2/features-available/syslog.conf ${ICINGA2_CONFIGDIR}/features-available)
 endif()
-install_if_not_exists(icinga2/scripts/mail-host-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts)
-install_if_not_exists(icinga2/scripts/mail-service-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts)
-install_if_not_exists(icinga2/zones.d/README ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/zones.d)
+install_if_not_exists(icinga2/scripts/mail-host-notification.sh ${ICINGA2_CONFIGDIR}/scripts)
+install_if_not_exists(icinga2/scripts/mail-service-notification.sh ${ICINGA2_CONFIGDIR}/scripts)
+install_if_not_exists(icinga2/zones.d/README ${ICINGA2_CONFIGDIR}/zones.d)
 
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
-  install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/logrotate.d/icinga2 ${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d)
+  install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/logrotate.d/icinga2 ${LOGROTATE_DIR})
 endif()
 
 if(NOT WIN32)
-  install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
-  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/mainlog.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/mainlog.conf\")")
+  install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled\")")
+  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/mainlog.conf \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled/mainlog.conf\")")
 
-  install(
-    FILES bash_completion.d/icinga2
-    DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d
-  )
+  install(FILES bash_completion.d/icinga2 DESTINATION ${BASHCOMPLETION_DIR})
 else()
-  install_if_not_exists(icinga2/features-enabled/mainlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled)
+  install_if_not_exists(icinga2/features-enabled/mainlog.conf ${ICINGA2_CONFIGDIR}/features-enabled)
 endif()
 
 if(${CMAKE_SYSTEM_NAME} MATCHES "(Linux|Solaris|SunOS)")
index 9c5153811a7d4aee4cfbd41399ff56ec78447d81..bd511cebcfdf4275ddda81d8827711ecef53ce4a 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 object NotificationCommand "mail-host-notification" {
-  command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ]
+  command = [ ConfigDir + "/scripts/mail-host-notification.sh" ]
 
   arguments += {
     "-4" = "$notification_address$"
@@ -66,7 +66,7 @@ object NotificationCommand "mail-host-notification" {
 }
 
 object NotificationCommand "mail-service-notification" {
-  command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
+  command = [ ConfigDir + "/scripts/mail-service-notification.sh" ]
 
   arguments += {
     "-4" = "$notification_address$"
@@ -146,7 +146,7 @@ object NotificationCommand "mail-service-notification" {
 /*
 
 object NotificationCommand "mail-host-notification" {
-  command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ]
+  command = [ ConfigDir + "/scripts/mail-host-notification.sh" ]
 
   env = {
     NOTIFICATIONTYPE = "$notification.type$"
@@ -164,7 +164,7 @@ object NotificationCommand "mail-host-notification" {
 }
 
 object NotificationCommand "mail-service-notification" {
-  command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
+  command = [ ConfigDir + "/scripts/mail-service-notification.sh" ]
 
   env = {
     NOTIFICATIONTYPE = "$notification.type$"
index 6e8e5813e6112e0ac4318f842c213cb54c9eb1ef..e66518fe16483589d18015821c5d4ba30cdd088c 100644 (file)
@@ -6,6 +6,5 @@
 
 object FileLogger "debug-file" {
   severity = "debug"
-  path = LocalStateDir + "/log/icinga2/debug.log"
+  path = LogDir + "/debug.log"
 }
-
index ded9a7c7d96cda8d12c731908429c27ca2878120..a3bb19dabe6795383626776c22349a265f1a8b33 100644 (file)
@@ -4,6 +4,5 @@
 
 object FileLogger "main-log" {
   severity = "information"
-  path = LocalStateDir + "/log/icinga2/icinga2.log"
+  path = LogDir + "/icinga2.log"
 }
-
index f0698726f9b9270b7fef88db15b91f2fec1ce8c0..ef3f521f23e0bc9710e36f84494ddd0240075528 100644 (file)
@@ -36,10 +36,10 @@ fi
 : ${ICINGA2_GROUP:="@ICINGA2_GROUP@"}
 : ${ICINGA2_COMMAND_GROUP:="@ICINGA2_COMMAND_GROUP@"}
 : ${DAEMON:="@CMAKE_INSTALL_FULL_SBINDIR@/icinga2"}
-: ${ICINGA2_CONFIG_FILE:="@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf"}
-: ${ICINGA2_ERROR_LOG:=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/error.log}
-: ${ICINGA2_STARTUP_LOG:=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/startup.log}
-: ${ICINGA2_PID_FILE:="@ICINGA2_RUNDIR@/icinga2/icinga2.pid"}
+: ${ICINGA2_CONFIG_FILE:="@ICINGA2_CONFIGDIR@/icinga2.conf"}
+: ${ICINGA2_ERROR_LOG:=@ICINGA2_LOGDIR@/error.log}
+: ${ICINGA2_STARTUP_LOG:=@ICINGA2_LOGDIR@/startup.log}
+: ${ICINGA2_PID_FILE:="@ICINGA2_INITRUNDIR@/icinga2.pid"}
 
 # Load extra environment variables
 if [ -f /etc/default/icinga2 ]; then
@@ -90,7 +90,7 @@ stop() {
                if ! icinga2 internal signal -s SIGCHLD -p $pid >/dev/null 2>&1; then
                                break
                        fi
-               
+
                        printf '.'
                        sleep 3
                done
index 771c98f7b3835afb984099e7c61768ff46335071..94b7dcd2ff951c5e28a3c2d4c0a44af634cc0f72 100644 (file)
@@ -7,7 +7,7 @@ Type=notify
 EnvironmentFile=@ICINGA2_SYSCONFIGFILE@
 ExecStartPre=@CMAKE_INSTALL_PREFIX@/lib/icinga2/prepare-dirs @ICINGA2_SYSCONFIGFILE@
 ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 daemon -e ${ICINGA2_ERROR_LOG}
-PIDFile=@ICINGA2_RUNDIR@/icinga2/icinga2.pid
+PIDFile=@ICINGA2_INITRUNDIR@/icinga2.pid
 ExecReload=@CMAKE_INSTALL_PREFIX@/lib/icinga2/safe-reload @ICINGA2_SYSCONFIGFILE@
 TimeoutStartSec=30m
 
index d5d7497f173092c6b56791b5cfaba1450178d236..167c12578c701be5d68b7710964f484dab2e5016 100644 (file)
@@ -2,15 +2,14 @@
 #Make your changes here.
 
 #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=@ICINGA2_RUNDIR@/icinga2/icinga2.pid
-#ICINGA2_LOG_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2
-#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_CACHE_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/cache/icinga2
+#ICINGA2_CONFIG_FILE=@ICINGA2_CONFIGDIR@/icinga2.conf
+#ICINGA2_INIT_RUN_DIR=@ICINGA2_INITRUNDIR@
+#ICINGA2_PID_FILE=@ICINGA2_INITRUNDIR@/icinga2.pid
+#ICINGA2_LOG_DIR=@ICINGA2_LOGDIR@
+#ICINGA2_ERROR_LOG=@ICINGA2_LOGDIR@/error.log
+#ICINGA2_STARTUP_LOG=@ICINGA2_LOGDIR@/startup.log
+#ICINGA2_LOG=@ICINGA2_LOGDIR@/icinga2.log
+#ICINGA2_CACHE_DIR=@ICINGA2_CACHEDIR@
 #ICINGA2_USER=@ICINGA2_USER@
 #ICINGA2_GROUP=@ICINGA2_GROUP@
 #ICINGA2_COMMAND_GROUP=@ICINGA2_COMMAND_GROUP@
index ce155424d2666f3ee99c0c36a815eb5711970128..c0d96bdac7353df65965930bc26f6fd9562380f8 100644 (file)
@@ -17,28 +17,27 @@ fi
 : ${ICINGA2_USER:="@ICINGA2_USER@"}
 : ${ICINGA2_GROUP:="@ICINGA2_GROUP@"}
 : ${ICINGA2_COMMAND_GROUP:="@ICINGA2_COMMAND_GROUP@"}
-: ${ICINGA2_RUN_DIR:="@ICINGA2_RUNDIR@"}
-: ${ICINGA2_LOG_DIR:="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2"}
-: ${ICINGA2_STATE_DIR:="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/cache/icinga2"}
-: ${ICINGA2_CACHE_DIR:="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/cache/icinga2"}
+: ${ICINGA2_INIT_RUN_DIR:="@ICINGA2_INITRUNDIR@"}
+: ${ICINGA2_LOG_DIR:="@ICINGA2_LOGDIR@"}
+: ${ICINGA2_CACHE_DIR:="@ICINGA2_CACHEDIR@"}
 
 getent passwd $ICINGA2_USER >/dev/null 2>&1 || (echo "Icinga user '$ICINGA2_USER' does not exist. Exiting." && exit 6)
 getent group $ICINGA2_GROUP >/dev/null 2>&1 || (echo "Icinga group '$ICINGA2_GROUP' does not exist. Exiting." && exit 6)
 getent group $ICINGA2_COMMAND_GROUP >/dev/null 2>&1 || (echo "Icinga command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting." && exit 6)
 
-if [ ! -e "$ICINGA2_RUN_DIR"/icinga2 ]; then
-       mkdir "$ICINGA2_RUN_DIR"/icinga2
-       mkdir "$ICINGA2_RUN_DIR"/icinga2/cmd
+if [ ! -e "$ICINGA2_INIT_RUN_DIR" ]; then
+       mkdir "$ICINGA2_INIT_RUN_DIR"
+       mkdir "$ICINGA2_INIT_RUN_DIR"/cmd
 fi
 
-chmod 755 "$ICINGA2_RUN_DIR"/icinga2
-chmod 2750 "$ICINGA2_RUN_DIR"/icinga2/cmd
-chown -R $ICINGA2_USER:$ICINGA2_COMMAND_GROUP "$ICINGA2_RUN_DIR"/icinga2
+chmod 755 "$ICINGA2_INIT_RUN_DIR"
+chmod 2750 "$ICINGA2_INIT_RUN_DIR"/cmd
+chown -R $ICINGA2_USER:$ICINGA2_COMMAND_GROUP "$ICINGA2_INIT_RUN_DIR"
 
 test -e "$ICINGA2_LOG_DIR" || install -m 750 -o $ICINGA2_USER -g $ICINGA2_COMMAND_GROUP -d "$ICINGA2_LOG_DIR"
 
 if type restorecon >/dev/null 2>&1; then
-       restorecon -R "$ICINGA2_RUN_DIR"/icinga2/
+       restorecon -R "$ICINGA2_INIT_RUN_DIR"/
 fi
 
 test -e "$ICINGA2_CACHE_DIR" || install -m 750 -o $ICINGA2_USER -g $ICINGA2_COMMAND_GROUP -d "$ICINGA2_CACHE_DIR"
index c42994a305219a3f8f997c6433f1e238bf389fa6..a71ae9db5091e2381b9f0cf4ebfd8f8747c3cbb5 100644 (file)
@@ -11,7 +11,7 @@ fi
 
 # Set defaults, to overwrite see "@ICINGA2_SYSCONFIGFILE@"
 
-: ${ICINGA2_PID_FILE:="@ICINGA2_RUNDIR@/icinga2/icinga2.pid"}
+: ${ICINGA2_PID_FILE:="@ICINGA2_INITRUNDIR@/icinga2.pid"}
 : ${DAEMON:="@CMAKE_INSTALL_FULL_SBINDIR@/icinga2"}
 
 printf "Validating config files: "
index 91d8d23d3a6ef3ebc5738008a5081596863ae7ac..3863f913d64b62c84f4b25e7f8bffb45a5233540 100644 (file)
@@ -1,4 +1,4 @@
-@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/icinga2.log @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/debug.log {
+@ICINGA2_LOGDIR@/icinga2.log @ICINGA2_LOGDIR@/debug.log {
        daily
        rotate 7@LOGROTATE_USE_SU@
        compress
@@ -7,11 +7,11 @@
        notifempty
        create 644 @ICINGA2_USER@ @ICINGA2_GROUP@
        postrotate
-               /bin/kill -USR1 $(cat @ICINGA2_RUNDIR@/icinga2/icinga2.pid 2> /dev/null) 2> /dev/null || true
+               /bin/kill -USR1 $(cat @ICINGA2_INITRUNDIR@/icinga2.pid 2> /dev/null) 2> /dev/null || true
        endscript
 }
 
-@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/error.log {
+@ICINGA2_LOGDIR@/error.log {
        daily
        rotate 90@LOGROTATE_USE_SU@
        compress
@@ -21,4 +21,3 @@
        create 644 @ICINGA2_USER@ @ICINGA2_GROUP@
        # TODO: figure out how to get Icinga to re-open this log file
 }
-
index 0d1293279830aab964f98678ca1e6901d0f8279b..49286776dcda7b60c40820245c8ef0a32ab5e6f3 100644 (file)
@@ -107,6 +107,6 @@ install(
   RUNTIME DESTINATION ${InstallPath}
 )
 
-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}${ICINGA2_RUNDIR}/icinga2\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_LOGDIR}\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_INITRUNDIR}\")")
index 404cedf30582f8def176ca2e7eb363f14c2d22eb..2cde94859f1db5d93afbbac5da7789b3ffd329aa 100644 (file)
@@ -94,6 +94,68 @@ static std::vector<String> GlobalArgumentCompletion(const String& argument, cons
                return std::vector<String>();
 }
 
+static void HandleLegacyDefines()
+{
+#ifdef _WIN32
+       String dataPrefix = Utility::GetIcingaDataPath();
+#endif /* _WIN32 */
+
+       Value localStateDir = Application::GetConst("LocalStateDir");
+       if (!localStateDir.IsEmpty()) {
+               Log(LogWarning, "icinga-app")
+                       << "Please do not set LocalStateDir anymore, set DataDir, LogDir, CacheDir and SpoolDir!"
+                       << " Resetting those vars based on LocalStateDir!";
+
+#ifdef _WIN32
+               ScriptGlobal::Set("DataDir", localStateDir + "\\lib\\icinga2");
+               ScriptGlobal::Set("LogDir", localStateDir + "\\log\\icinga2");
+               ScriptGlobal::Set("CacheDir", localStateDir + "\\cache\\icinga2");
+               ScriptGlobal::Set("SpoolDir", localStateDir + "\\spool\\icinga2");
+       } else {
+               ScriptGlobal::Set("LocalStateDir", dataPrefix + "\\var");
+#else /* _WIN32 */
+               ScriptGlobal::Set("DataDir", localStateDir + "/lib/icinga2");
+               ScriptGlobal::Set("LogDir", localStateDir + "/log/icinga2");
+               ScriptGlobal::Set("CacheDir", localStateDir + "/cache/icinga2");
+               ScriptGlobal::Set("SpoolDir", localStateDir + "/spool/icinga2");
+       } else {
+               ScriptGlobal::Set("LocalStateDir", ICINGA_LOCALSTATEDIR);
+#endif /* _WIN32 */
+       }
+
+       Value sysconfDir = Application::GetConst("SysconfDir");
+       if (!sysconfDir.IsEmpty()) {
+               Log(LogWarning, "icinga-app")
+                       << "Please do not set Sysconfdir anymore, set ConfigDir! Resetting the var based on SysconfDir!";
+
+#ifdef _WIN32
+               ScriptGlobal::Set("ConfigDir", sysconfDir + "\\icinga2");
+       } else {
+               ScriptGlobal::Set("SysconfDir", dataPrefix + "\\etc");
+#else /* _WIN32 */
+               ScriptGlobal::Set("ConfigDir", sysconfDir + "/icinga2");
+       } else {
+               ScriptGlobal::Set("SysconfDir", ICINGA_SYSCONFDIR);
+#endif /* _WIN32 */
+       }
+
+       Value runDir = Application::GetConst("RunDir");
+       if (!runDir.IsEmpty()) {
+               Log(LogWarning, "icinga-app")
+                       << "Please do not set RunDir anymore, set InitRunDir! Resetting the var based on RunDir!";
+
+#ifdef _WIN32
+               ScriptGlobal::Set("InitRunDir", runDir + "\\icinga2");
+       } else {
+               ScriptGlobal::Set("RunDir", dataPrefix + "\\var\\run");
+#else /* _WIN32 */
+               ScriptGlobal::Set("InitRunDir", runDir + "/icinga2");
+       } else {
+               ScriptGlobal::Set("RunDir", ICINGA_RUNDIR);
+#endif /* _WIN32 */
+       }
+}
+
 static int Main()
 {
        int argc = Application::GetArgC();
@@ -128,31 +190,53 @@ static int Main()
 #ifdef _WIN32
        bool builtinPaths = true;
 
+       // Programm install location, C:/Program Files/Icinga2
        String binaryPrefix = Utility::GetIcingaInstallPath();
+       // Returns the datapath for daemons, %PROGRAMDATA%/icinga2
        String dataPrefix = Utility::GetIcingaDataPath();
 
        if (!binaryPrefix.IsEmpty() && !dataPrefix.IsEmpty()) {
-               Application::DeclarePrefixDir(binaryPrefix);
-               Application::DeclareSysconfDir(dataPrefix + "\\etc");
-               Application::DeclareRunDir(dataPrefix + "\\var\\run");
-               Application::DeclareLocalStateDir(dataPrefix + "\\var");
-               Application::DeclarePkgDataDir(binaryPrefix + "\\share\\icinga2");
-               Application::DeclareIncludeConfDir(binaryPrefix + "\\share\\icinga2\\include");
+               Application::DeclareConst("PrefixDir", binaryPrefix);
+               Application::DeclareConst("ProgramData", dataPrefix);
+
+               Application::DeclareConst("ConfigDir", dataPrefix + "\\etc\\icinga2");
+
+               Application::DeclareConst("DataDir", dataPrefix + "\\var\\lib\\icinga2");
+               Application::DeclareConst("LogDir", dataPrefix + "\\var\\log\\icinga2");
+               Application::DeclareConst("CacheDir", dataPrefix + "\\var\\cache\\icinga2");
+               Application::DeclareConst("SpoolDir", dataPrefix + "\\var\\spool\\icinga2");
+
+               // also see call to HandleLegacyDefines() later
+
+               // internal constants
+               Application::DeclareConst("PkgDataDir", binaryPrefix + "\\share\\icinga2");
+               Application::DeclareConst("IncludeConfDir", binaryPrefix + "\\share\\icinga2\\include");
        } else {
                Log(LogWarning, "icinga-app", "Registry key could not be read. Falling back to built-in paths.");
 
 #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::DeclareConst("ConfigDir", ICINGA_CONFIGDIR);
+
+               Application::DeclareConst("DataDir", ICINGA_DATADIR);
+               Application::DeclareConst("LogDir", ICINGA_LOGDIR);
+               Application::DeclareConst("CacheDir", ICINGA_CACHEDIR);
+               Application::DeclareConst("SpoolDir", ICINGA_SPOOLDIR);
+
+               Application::DeclareConst("PrefixDir", ICINGA_PREFIX);
+
+               // also see call to HandleLegacyDefines() later
+
+               // internal constants
+               Application::DeclareConst("PkgDataDir", ICINGA_PKGDATADIR);
+               Application::DeclareConst("IncludeConfDir", ICINGA_INCLUDECONFDIR);
+
+               Application::DeclareConst("InitRunDir", ICINGA_INITRUNDIR);
+
 #ifdef _WIN32
        }
 #endif /* _WIN32 */
 
-       Application::DeclareZonesDir(Application::GetSysconfDir() + "/icinga2/zones.d");
+       Application::DeclareConst("ZonesDir", Application::GetConst("ConfigDir") + "/zones.d");
 
        String icingaUser = Utility::GetFromEnvironment("ICINGA2_USER");
        if (icingaUser.IsEmpty())
@@ -162,17 +246,17 @@ static int Main()
        if (icingaGroup.IsEmpty())
                icingaGroup = ICINGA_GROUP;
 
-       Application::DeclareRunAsUser(icingaUser);
-       Application::DeclareRunAsGroup(icingaGroup);
+       Application::DeclareConst("RunAsUser", icingaUser);
+       Application::DeclareConst("RunAsGroup", icingaGroup);
 
        if (!autocomplete) {
 #ifdef RLIMIT_NOFILE
                String rLimitFiles = Utility::GetFromEnvironment("ICINGA2_RLIMIT_FILES");
                if (rLimitFiles.IsEmpty())
-                       Application::DeclareRLimitFiles(Application::GetDefaultRLimitFiles());
+                       Application::DeclareConst("RLimitFiles", Application::GetDefaultRLimitFiles());
                else {
                        try {
-                               Application::DeclareRLimitFiles(Convert::ToLong(rLimitFiles));
+                               Application::DeclareConst("RLimitFiles", Convert::ToLong(rLimitFiles));
                        } catch (const std::invalid_argument& ex) {
                                std::cout
                                        << "Error setting \"ICINGA2_RLIMIT_FILES\": " << ex.what() << '\n';
@@ -184,10 +268,10 @@ static int Main()
 #ifdef RLIMIT_NPROC
                String rLimitProcesses = Utility::GetFromEnvironment("ICINGA2_RLIMIT_PROCESSES");
                if (rLimitProcesses.IsEmpty())
-                       Application::DeclareRLimitProcesses(Application::GetDefaultRLimitProcesses());
+                       Application::DeclareConst("RLimitProcesses", Application::GetDefaultRLimitProcesses());
                else {
                        try {
-                               Application::DeclareRLimitProcesses(Convert::ToLong(rLimitProcesses));
+                               Application::DeclareConst("RLimitProcesses", Convert::ToLong(rLimitProcesses));
                        } catch (const std::invalid_argument& ex) {
                                std::cout
                                        << "Error setting \"ICINGA2_RLIMIT_PROCESSES\": " << ex.what() << '\n';
@@ -199,10 +283,10 @@ static int Main()
 #ifdef RLIMIT_STACK
                String rLimitStack = Utility::GetFromEnvironment("ICINGA2_RLIMIT_STACK");
                if (rLimitStack.IsEmpty())
-                       Application::DeclareRLimitStack(Application::GetDefaultRLimitStack());
+                       Application::DeclareConst("RLimitStack", Application::GetDefaultRLimitStack());
                else {
                        try {
-                               Application::DeclareRLimitStack(Convert::ToLong(rLimitStack));
+                               Application::DeclareConst("RLimitStack", Convert::ToLong(rLimitStack));
                        } catch (const std::invalid_argument& ex) {
                                std::cout
                                        << "Error setting \"ICINGA2_RLIMIT_STACK\": " << ex.what() << '\n';
@@ -212,8 +296,8 @@ static int Main()
 #endif /* RLIMIT_STACK */
        }
 
-       Application::DeclareConcurrency(std::thread::hardware_concurrency());
-       Application::DeclareMaxConcurrentChecks(Application::GetDefaultMaxConcurrentChecks());
+       Application::DeclareConst("Concurrency", std::thread::hardware_concurrency());
+       Application::DeclareConst("MaxConcurrentChecks", Application::GetDefaultMaxConcurrentChecks());
 
        ScriptGlobal::Set("Environment", "production");
 
@@ -277,7 +361,8 @@ static int Main()
        GetUserName(username, &usernameLen);
 
        std::ifstream userFile;
-       userFile.open(Application::GetSysconfDir() + "/icinga2/user");
+       String configDir = Application::GetConst("ConfigDir");
+       userFile.open(configDir + "/user");
 
        if (userFile && command && !Application::IsProcessElevated()) {
                std::string userLine;
@@ -361,16 +446,18 @@ static int Main()
                }
        }
 
+       HandleLegacyDefines();
+
        if (vm.count("script-debugger"))
                Application::SetScriptDebuggerEnabled(true);
 
-       Application::DeclareStatePath(Application::GetLocalStateDir() + "/lib/icinga2/icinga2.state");
-       Application::DeclareModAttrPath(Application::GetLocalStateDir() + "/lib/icinga2/modified-attributes.conf");
-       Application::DeclareObjectsPath(Application::GetLocalStateDir() + "/cache/icinga2/icinga2.debug");
-       Application::DeclareVarsPath(Application::GetLocalStateDir() + "/cache/icinga2/icinga2.vars");
-       Application::DeclarePidPath(Application::GetRunDir() + "/icinga2/icinga2.pid");
+       Application::DeclareConst("StatePath", Application::GetConst("DataDir") + "/icinga2.state");
+       Application::DeclareConst("ModAttrPath", Application::GetConst("DataDir") + "/modified-attributes.conf");
+       Application::DeclareConst("ObjectsPath", Application::GetConst("CacheDir") + "/icinga2.debug");
+       Application::DeclareConst("VarsPath", Application::GetConst("CacheDir") + "/icinga2.vars");
+       Application::DeclareConst("PidPath", Application::GetConst("InitRunDir") + "/icinga2.pid");
 
-       ConfigCompiler::AddIncludeSearchDir(Application::GetIncludeConfDir());
+       ConfigCompiler::AddIncludeSearchDir(Application::GetConst("IncludeConfDir"));
 
        if (!autocomplete && vm.count("include")) {
                for (const String& includePath : vm["include"].as<std::vector<std::string> >()) {
@@ -480,8 +567,8 @@ static int Main()
                                return 0;
                        }
                } else if (command && command->GetImpersonationLevel() == ImpersonateIcinga) {
-                       String group = Application::GetRunAsGroup();
-                       String user = Application::GetRunAsUser();
+                       String group = Application::GetConst("RunAsGroup");
+                       String user = Application::GetConst("RunAsUser");
 
                        errno = 0;
                        struct group *gr = getgrnam(group.CStr());
index 75b2e728970d49dc5becf689b7ff345f1942eee0..6d70ad9f1129017a17cba9c6095f2b4fbe830933 100644 (file)
@@ -19,5 +19,5 @@ add_subdirectory(plugins-contrib.d)
 
 install(
   FILES itl command-icinga.conf hangman plugins command-plugins.conf manubulon command-plugins-manubulon.conf windows-plugins command-plugins-windows.conf nscp command-nscp-local.conf plugins-contrib
-  DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2/include
+  DESTINATION ${ICINGA2_INCLUDEDIR}
 )
index 099ea2485e3fb62cf7ed9f94390fcd9271434046..5d60a1b70dd9ab7c350c59915c9e2d41a5382522 100644 (file)
@@ -17,5 +17,5 @@
 
 install(
   FILES databases.conf hardware.conf icingacli.conf ipmi.conf logmanagement.conf metrics.conf network-components.conf network-services.conf operating-system.conf raid-controller.conf smart-attributes.conf storage.conf virtualization.conf vmware.conf web.conf
-  DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2/include/plugins-contrib.d
+  DESTINATION ${ICINGA2_INCLUDEDIR}/plugins-contrib.d
 )
index e1fbbfc9d1922948cc7725ef9e559dd6a6dde39a..23397ba49b1728285dc5d25b6727ec4180982e35 100644 (file)
@@ -519,7 +519,7 @@ object CheckCommand "oracle_health" {
 
        vars.oracle_home = "/usr/lib/oracle/11.2/client64/lib"
        vars.oracle_ld_library_path = "/usr/lib/oracle/11.2/client64/lib"
-       vars.oracle_tns_admin = SysconfDir + "/icinga2/plugin-configs"
+       vars.oracle_tns_admin = ConfigDir + "/plugin-configs"
 }
 
 object CheckCommand "postgres" {
index 25e3333dd21aded1b724c20dab5efbba939844ae..e668bd3cca760443064a8cf29f39af600b34ba3c 100644 (file)
@@ -20,5 +20,5 @@ object CheckCommand "smart-attributes" {
                }
        }
 
-       vars.smart_attributes_config_path = SysconfDir + "/icinga2/plugins-config/check_smartdb.json"
+       vars.smart_attributes_config_path = ConfigDir + "/plugins-config/check_smartdb.json"
 }
index d86f676d242bd5c732f8da8054f8009db3a38896..c16cda028ae05a8e0905af038a27cdd691f569da 100644 (file)
@@ -122,7 +122,7 @@ set_target_properties (
   FOLDER Lib
 )
 
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/icinga2\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2/crash\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CACHEDIR}\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_LOGDIR}/crash\")")
 
 set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
index 4287c76879f5de539f109781a18336714f664ebf..0e6b018f22b872de451ecbc8910bc77db7187705 100644 (file)
@@ -168,7 +168,7 @@ void Application::SetResourceLimits()
        rlimit rl;
 
 #      ifdef RLIMIT_NOFILE
-       rlim_t fileLimit = GetRLimitFiles();
+       rlim_t fileLimit = GetConst("RLimitFiles");
 
        if (fileLimit != 0) {
                if (fileLimit < GetDefaultRLimitFiles()) {
@@ -189,7 +189,7 @@ void Application::SetResourceLimits()
        }
 
 #      ifdef RLIMIT_NPROC
-       rlim_t processLimit = GetRLimitProcesses();
+       rlim_t processLimit = GetConst("RLimitProcesses");
 
        if (processLimit != 0) {
                if (processLimit < GetDefaultRLimitProcesses()) {
@@ -228,7 +228,7 @@ void Application::SetResourceLimits()
 
        rlim_t stackLimit;
 
-       stackLimit = GetRLimitStack();
+       stackLimit = GetConst("RLimitStack");
 
        if (stackLimit != 0) {
                if (stackLimit < GetDefaultRLimitStack()) {
@@ -543,16 +543,28 @@ void Application::DisplayInfoMessage(std::ostream& os, bool skipVersion)
        if (!skipVersion)
                os << "  Application version: " << GetAppVersion() << "\n";
 
-       os << "  Installation root: " << GetPrefixDir() << "\n"
-               << "  Sysconf directory: " << GetSysconfDir() << "\n"
-               << "  Run directory: " << GetRunDir() << "\n"
-               << "  Local state directory: " << GetLocalStateDir() << "\n"
-               << "  Package data directory: " << GetPkgDataDir() << "\n"
-               << "  State path: " << GetStatePath() << "\n"
-               << "  Modified attributes path: " << GetModAttrPath() << "\n"
-               << "  Objects path: " << GetObjectsPath() << "\n"
-               << "  Vars path: " << GetVarsPath() << "\n"
-               << "  PID path: " << GetPidPath() << "\n";
+       os
+               << "\n"
+               << "  Config directory: " << GetConst("ConfigDir") << "\n"
+               << "  Data directory: " << GetConst("DataDir") << "\n"
+               << "  Log directory: " << GetConst("LogDir") << "\n"
+               << "  Cache directory: " << GetConst("CacheDir") << "\n"
+               << "  Spool directory: " << GetConst("SpoolDir") << "\n"
+               << "  Run directory: " << GetConst("InitRunDir") << "\n"
+               << "\n"
+               << "Older paths (deprecated):" << "\n"
+               << "  Installation root: " << GetConst("PrefixDir") << "\n"
+               << "  Sysconf directory: " << GetConst("SysconfDir") << "\n"
+               << "  Run directory (base): " << GetConst("RunDir") << "\n"
+               << "  Local state directory: " << GetConst("LocalStateDir") << "\n"
+               << "\n"
+               << "Internally used paths:" << "\n"
+               << "  Package data directory: " << GetConst("PkgDataDir") << "\n"
+               << "  State path: " << GetConst("StatePath") << "\n"
+               << "  Modified attributes path: " << GetConst("ModAttrPath") << "\n"
+               << "  Objects path: " << GetConst("ObjectsPath") << "\n"
+               << "  Vars path: " << GetConst("VarsPath") << "\n"
+               << "  PID path: " << GetConst("PidPath") << "\n";
 
        os << "\n"
                << "System information:" << "\n"
@@ -582,7 +594,7 @@ void Application::DisplayBugMessage(std::ostream& os)
 
 String Application::GetCrashReportFilename()
 {
-       return GetLocalStateDir() + "/log/icinga2/crash/report." + Convert::ToString(Utility::GetTime());
+       return GetConst("LogDir") + "/crash/report." + Convert::ToString(Utility::GetTime());
 }
 
 
@@ -732,7 +744,7 @@ void Application::SigUsr2Handler(int)
         */
        Application::Ptr instance = GetInstance();
        try {
-               instance->UpdatePidFile(GetPidPath(), m_ReloadProcess);
+               instance->UpdatePidFile(GetConst("PidPath"), m_ReloadProcess);
        } catch (const std::exception&) {
                /* abort restart */
                Log(LogCritical, "Application", "Cannot update PID file. Aborting restart operation.");
@@ -1004,10 +1016,10 @@ int Application::Run()
 #endif /* _WIN32 */
 
        try {
-               UpdatePidFile(GetPidPath());
+               UpdatePidFile(GetConst("PidPath"));
        } catch (const std::exception&) {
                Log(LogCritical, "Application")
-                       << "Cannot update PID file '" << GetPidPath() << "'. Aborting.";
+                       << "Cannot update PID file '" << GetConst("PidPath") << "'. Aborting.";
                return EXIT_FAILURE;
        }
 
@@ -1089,7 +1101,7 @@ void Application::ClosePidFile(bool unlink)
 
        if (m_PidFile) {
                if (unlink) {
-                       String pidpath = GetPidPath();
+                       String pidpath = GetConst("PidPath");
                        ::unlink(pidpath.CStr());
                }
 
@@ -1157,310 +1169,37 @@ pid_t Application::ReadPidFile(const String& filename)
        return runningpid;
 }
 
-
-/**
- * Retrieves the path of the installation prefix.
- *
- * @returns The path.
- */
-String Application::GetPrefixDir()
-{
-       return ScriptGlobal::Get("PrefixDir");
-}
-
-/**
- * Sets the path for the installation prefix.
- *
- * @param path The new path.
- */
-void Application::DeclarePrefixDir(const String& path)
-{
-       if (!ScriptGlobal::Exists("PrefixDir"))
-               ScriptGlobal::Set("PrefixDir", path);
-}
-
-/**
- * Retrives the path of the sysconf dir.
- *
- * @returns The path.
- */
-String Application::GetSysconfDir()
-{
-       return ScriptGlobal::Get("SysconfDir");
-}
-
-/**
- * Sets the path of the sysconf dir.
- *
- * @param path The new path.
- */
-void Application::DeclareSysconfDir(const String& path)
-{
-       if (!ScriptGlobal::Exists("SysconfDir"))
-               ScriptGlobal::Set("SysconfDir", path);
-}
-
-/**
- * Retrieves the path for the run dir.
- *
- * @returns The path.
- */
-String Application::GetRunDir()
-{
-       return ScriptGlobal::Get("RunDir");
-}
-
-/**
- * Sets the path of the run dir.
- *
- * @param path The new path.
- */
-void Application::DeclareRunDir(const String& path)
-{
-       if (!ScriptGlobal::Exists("RunDir"))
-               ScriptGlobal::Set("RunDir", path);
-}
-
-/**
- * Retrieves the path for the local state dir.
- *
- * @returns The path.
- */
-String Application::GetLocalStateDir()
-{
-       return ScriptGlobal::Get("LocalStateDir");
-}
-
-/**
- * Sets the path for the local state dir.
- *
- * @param path The new path.
- */
-void Application::DeclareLocalStateDir(const String& path)
-{
-       if (!ScriptGlobal::Exists("LocalStateDir"))
-               ScriptGlobal::Set("LocalStateDir", path);
-}
-
-/**
- * Retrieves the path for the local state dir.
- *
- * @returns The path.
- */
-String Application::GetZonesDir()
-{
-       return ScriptGlobal::Get("ZonesDir", &Empty);
-}
-
-/**
- * Sets the path of the zones dir.
- *
- * @param path The new path.
- */
-void Application::DeclareZonesDir(const String& path)
-{
-       if (!ScriptGlobal::Exists("ZonesDir"))
-               ScriptGlobal::Set("ZonesDir", path);
-}
-
-/**
- * Retrieves the path for the package data dir.
- *
- * @returns The path.
- */
-String Application::GetPkgDataDir()
-{
-       String defaultValue = "";
-       return ScriptGlobal::Get("PkgDataDir", &Empty);
-}
-
-/**
- * Sets the path for the package data dir.
- *
- * @param path The new path.
- */
-void Application::DeclarePkgDataDir(const String& path)
-{
-       if (!ScriptGlobal::Exists("PkgDataDir"))
-               ScriptGlobal::Set("PkgDataDir", path);
-}
-
-/**
- * Retrieves the path for the include conf dir.
- *
- * @returns The path.
- */
-String Application::GetIncludeConfDir()
-{
-       return ScriptGlobal::Get("IncludeConfDir", &Empty);
-}
-
-/**
- * Sets the path for the package data dir.
- *
- * @param path The new path.
- */
-void Application::DeclareIncludeConfDir(const String& path)
-{
-       if (!ScriptGlobal::Exists("IncludeConfDir"))
-               ScriptGlobal::Set("IncludeConfDir", path);
-}
-
-/**
- * Retrieves the path for the state file.
- *
- * @returns The path.
- */
-String Application::GetStatePath()
-{
-       return ScriptGlobal::Get("StatePath", &Empty);
-}
-
-/**
- * Sets the path for the state file.
- *
- * @param path The new path.
- */
-void Application::DeclareStatePath(const String& path)
-{
-       if (!ScriptGlobal::Exists("StatePath"))
-               ScriptGlobal::Set("StatePath", path);
-}
-
-/**
- * Retrieves the path for the modified attributes file.
- *
- * @returns The path.
- */
-String Application::GetModAttrPath()
-{
-       return ScriptGlobal::Get("ModAttrPath", &Empty);
-}
-
-/**
- * Sets the path for the modified attributes file.
- *
- * @param path The new path.
- */
-void Application::DeclareModAttrPath(const String& path)
-{
-       if (!ScriptGlobal::Exists("ModAttrPath"))
-               ScriptGlobal::Set("ModAttrPath", path);
-}
-
-/**
- * Retrieves the path for the objects file.
- *
- * @returns The path.
- */
-String Application::GetObjectsPath()
-{
-       return ScriptGlobal::Get("ObjectsPath", &Empty);
-}
-
-/**
- * Sets the path for the objects file.
- *
- * @param path The new path.
- */
-void Application::DeclareObjectsPath(const String& path)
-{
-       if (!ScriptGlobal::Exists("ObjectsPath"))
-               ScriptGlobal::Set("ObjectsPath", path);
-}
-
-/**
-* Retrieves the path for the vars file.
-*
-* @returns The path.
-*/
-String Application::GetVarsPath()
-{
-       return ScriptGlobal::Get("VarsPath", &Empty);
-}
-
-/**
-* Sets the path for the vars file.
-*
-* @param path The new path.
-*/
-void Application::DeclareVarsPath(const String& path)
-{
-       if (!ScriptGlobal::Exists("VarsPath"))
-               ScriptGlobal::Set("VarsPath", path);
-}
-
-/**
- * Retrieves the path for the PID file.
- *
- * @returns The path.
- */
-String Application::GetPidPath()
-{
-       return ScriptGlobal::Get("PidPath", &Empty);
-}
-
-/**
- * Sets the path for the PID file.
- *
- * @param path The new path.
- */
-void Application::DeclarePidPath(const String& path)
-{
-       if (!ScriptGlobal::Exists("PidPath"))
-               ScriptGlobal::Set("PidPath", path);
-}
-
-/**
- * Retrieves the name of the user.
- *
- * @returns The name.
- */
-String Application::GetRunAsUser()
-{
-       return ScriptGlobal::Get("RunAsUser");
-}
-
 /**
- * Sets the name of the user.
+ * Declares a const with ScriptGlobal
  *
- * @param path The new user name.
+ * @param name The const name.
+ * @param value The new value.
  */
-void Application::DeclareRunAsUser(const String& user)
+void Application::DeclareConst(const String& name, const Value& value)
 {
-       if (!ScriptGlobal::Exists("RunAsUser"))
-               ScriptGlobal::Set("RunAsUser", user);
+       if (!ScriptGlobal::Exists(name))
+               ScriptGlobal::Set(name, value);
 }
 
 /**
- * Retrieves the name of the group.
+ * Returns the value of a const from ScriptGlobal
  *
- * @returns The name.
+ * @param name The const name.
  */
-String Application::GetRunAsGroup()
+Value Application::GetConst(const String& name)
 {
-       return ScriptGlobal::Get("RunAsGroup");
+       return GetConst(name, Empty);
 }
 
 /**
- * Sets the name of the group.
+ * Returns the value of a const from ScriptGlobal with default value
  *
- * @param path The new group name.
+ * @param name The const name.
+ * @param def  The default value.
  */
-void Application::DeclareRunAsGroup(const String& group)
+Value Application::GetConst(const String& name, Value defaultValue)
 {
-       if (!ScriptGlobal::Exists("RunAsGroup"))
-               ScriptGlobal::Set("RunAsGroup", group);
-}
-
-/**
- * Retrieves the file rlimit.
- *
- * @returns The limit.
- */
-int Application::GetRLimitFiles()
-{
-       return ScriptGlobal::Get("RLimitFiles");
+       return ScriptGlobal::Get(name, &defaultValue);
 }
 
 int Application::GetDefaultRLimitFiles()
@@ -1468,80 +1207,16 @@ int Application::GetDefaultRLimitFiles()
        return 16 * 1024;
 }
 
-/**
- * Sets the file rlimit.
- *
- * @param path The new file rlimit.
- */
-void Application::DeclareRLimitFiles(int limit)
-{
-       if (!ScriptGlobal::Exists("RLimitFiles"))
-               ScriptGlobal::Set("RLimitFiles", limit);
-}
-
-/**
- * Retrieves the process rlimit.
- *
- * @returns The limit.
- */
-int Application::GetRLimitProcesses()
-{
-       return ScriptGlobal::Get("RLimitProcesses");
-}
-
 int Application::GetDefaultRLimitProcesses()
 {
        return 16 * 1024;
 }
 
-/**
- * Sets the process rlimit.
- *
- * @param path The new process rlimit.
- */
-void Application::DeclareRLimitProcesses(int limit)
-{
-       if (!ScriptGlobal::Exists("RLimitProcesses"))
-               ScriptGlobal::Set("RLimitProcesses", limit);
-}
-
-/**
- * Retrieves the stack rlimit.
- *
- * @returns The limit.
- */
-int Application::GetRLimitStack()
-{
-       return ScriptGlobal::Get("RLimitStack");
-}
-
 int Application::GetDefaultRLimitStack()
 {
        return 256 * 1024;
 }
 
-/**
- * Sets the stack rlimit.
- *
- * @param path The new stack rlimit.
- */
-void Application::DeclareRLimitStack(int limit)
-{
-       if (!ScriptGlobal::Exists("RLimitStack"))
-               ScriptGlobal::Set("RLimitStack", limit);
-}
-
-/**
- * Sets the concurrency level.
- *
- * @param path The new concurrency level.
- */
-void Application::DeclareConcurrency(int ncpus)
-{
-       if (!ScriptGlobal::Exists("Concurrency"))
-               ScriptGlobal::Set("Concurrency", ncpus);
-}
-
 /**
  * Retrieves the concurrency level.
  *
@@ -1563,17 +1238,6 @@ void Application::SetMaxConcurrentChecks(int maxChecks)
        ScriptGlobal::Set("MaxConcurrentChecks", maxChecks);
 }
 
-/**
- * Sets the max concurrent checks.
- *
- * @param maxChecks The new limit.
- */
-void Application::DeclareMaxConcurrentChecks(int maxChecks)
-{
-       if (!ScriptGlobal::Exists("MaxConcurrentChecks"))
-               ScriptGlobal::Set("MaxConcurrentChecks", maxChecks);
-}
-
 /**
  * Retrieves the max concurrent checks.
  *
index 7722d25f4c31d070c923994b2d7827ef71af795a..dbb14c38d709eba3a3954769875266af148be529 100644 (file)
@@ -85,70 +85,21 @@ public:
 
        static String GetExePath(const String& argv0);
 
-       static String GetPrefixDir();
-       static void DeclarePrefixDir(const String& path);
-
-       static String GetSysconfDir();
-       static void DeclareSysconfDir(const String& path);
-
-       static String GetZonesDir();
-       static void DeclareZonesDir(const String& path);
-
-       static String GetRunDir();
-       static void DeclareRunDir(const String& path);
-
-       static String GetLocalStateDir();
-       static void DeclareLocalStateDir(const String& path);
-
-       static String GetPkgDataDir();
-       static void DeclarePkgDataDir(const String& path);
-
-       static String GetIncludeConfDir();
-       static void DeclareIncludeConfDir(const String& path);
-
-       static String GetStatePath(void);
-       static void DeclareStatePath(const String& path);
-
-       static String GetModAttrPath();
-       static void DeclareModAttrPath(const String& path);
-
-       static String GetObjectsPath();
-       static void DeclareObjectsPath(const String& path);
-
-       static String GetVarsPath();
-       static void DeclareVarsPath(const String& path);
-
-       static String GetPidPath();
-       static void DeclarePidPath(const String& path);
-
-       static String GetRunAsUser();
-       static void DeclareRunAsUser(const String& user);
-
-       static String GetRunAsGroup();
-       static void DeclareRunAsGroup(const String& group);
+       static void DeclareConst(const String& name, const Value& value);
+       static Value GetConst(const String& name);
+       static Value GetConst(const String& name, Value defaultValue);
 
 #ifdef _WIN32
        static bool IsProcessElevated();
 #endif /* _WIN32 */
 
-       static int GetRLimitFiles();
        static int GetDefaultRLimitFiles();
-       static void DeclareRLimitFiles(int limit);
-
-       static int GetRLimitProcesses();
        static int GetDefaultRLimitProcesses();
-       static void DeclareRLimitProcesses(int limit);
-
-       static int GetRLimitStack();
        static int GetDefaultRLimitStack();
-       static void DeclareRLimitStack(int limit);
 
        static int GetConcurrency();
-       static void DeclareConcurrency(int ncpus);
-
        static int GetMaxConcurrentChecks();
        static int GetDefaultMaxConcurrentChecks();
-       static void DeclareMaxConcurrentChecks(int maxChecks);
        static void SetMaxConcurrentChecks(int maxChecks);
 
        static ThreadPool& GetTP();
index c3fe07bd9b57f00c22d91911e0302aebe310a10e..42fc929211912100446732104c8854e64e26cbcb 100644 (file)
@@ -535,7 +535,7 @@ std::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME
 
 String GetIcingaCADir()
 {
-       return Application::GetLocalStateDir() + "/lib/icinga2/ca";
+       return Application::GetConst("DataDir") + "/ca";
 }
 
 std::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
index 8f3de0b1bc50f7acfd6ef30a5ade3089d9fb17a2..65bca61bb74451deff2e09c44871463bd06da42a 100644 (file)
@@ -36,14 +36,14 @@ set_target_properties (
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/checker.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 if(NOT WIN32)
-  install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
-  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/checker.conf\")")
+  install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled\")")
+  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled/checker.conf\")")
 else()
-  install_if_not_exists(${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/checker.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled)
+  install_if_not_exists(${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/checker.conf ${ICINGA2_CONFIGDIR}/features-enabled)
 endif()
 
 set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
index 1b60a2c1a0daf2b8744c55c2df749e0bf19dfb26..a7739227cb9c7657a94e1f38f978a6cec406b5d3 100644 (file)
@@ -40,7 +40,7 @@ using namespace icinga;
 
 String ApiSetupUtility::GetConfdPath()
 {
-       return Application::GetSysconfDir() + "/icinga2/conf.d";
+       return Application::GetConst("ConfigDir") + "/conf.d";
 }
 
 String ApiSetupUtility::GetApiUsersConfPath()
index ba2dade47656659076ab13c97684f24f2c52d574..eda40a7fbfec0135cbf12730c45eec7709273661 100644 (file)
@@ -72,7 +72,7 @@ static bool Daemonize()
                do {
                        Utility::Sleep(0.1);
 
-                       readpid = Application::ReadPidFile(Application::GetPidPath());
+                       readpid = Application::ReadPidFile(Application::GetConst("PidPath"));
                        ret = waitpid(pid, &status, WNOHANG);
                } while (readpid != pid && ret == 0);
 
@@ -193,7 +193,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
                << ")";
 
        if (!vm.count("validate") && !vm.count("reload-internal")) {
-               pid_t runningpid = Application::ReadPidFile(Application::GetPidPath());
+               pid_t runningpid = Application::ReadPidFile(Application::GetConst("PidPath"));
                if (runningpid > 0) {
                        Log(LogCritical, "cli")
                                << "Another instance of Icinga already running with PID " << runningpid;
@@ -204,14 +204,16 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
        std::vector<std::string> configs;
        if (vm.count("config") > 0)
                configs = vm["config"].as<std::vector<std::string> >();
-       else if (!vm.count("no-config"))
-               configs.push_back(Application::GetSysconfDir() + "/icinga2/icinga2.conf");
+       else if (!vm.count("no-config")) {
+               String configDir = Application::GetConst("ConfigDir");
+               configs.push_back(configDir + "/icinga2.conf");
+       }
 
        Log(LogInformation, "cli", "Loading configuration file(s).");
 
        std::vector<ConfigItem::Ptr> newItems;
 
-       if (!DaemonUtility::LoadConfigFiles(configs, newItems, Application::GetObjectsPath(), Application::GetVarsPath()))
+       if (!DaemonUtility::LoadConfigFiles(configs, newItems, Application::GetConst("ObjectsPath"), Application::GetConst("VarsPath")))
                return EXIT_FAILURE;
 
        if (vm.count("validate")) {
@@ -253,7 +255,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
 
        /* restore the previous program state */
        try {
-               ConfigObject::RestoreObjects(Application::GetStatePath());
+               ConfigObject::RestoreObjects(Application::GetConst("StatePath"));
        } catch (const std::exception& ex) {
                Log(LogCritical, "cli")
                        << "Failed to restore state file: " << DiagnosticInformation(ex);
index 432fe3d459adb7a06791f0b2eef0181a73fc1704..62d39c2f44f9e3be37f4675c61bcaeb4dd038454 100644 (file)
@@ -121,7 +121,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
         * unfortunately moving it there is somewhat non-trivial. */
        success = true;
 
-       String zonesEtcDir = Application::GetZonesDir();
+       String zonesEtcDir = Application::GetConst("ZonesDir");
        if (!zonesEtcDir.IsEmpty() && Utility::PathExists(zonesEtcDir))
                Utility::Glob(zonesEtcDir + "/*", std::bind(&IncludeZoneDirRecursive, _1, "_etc", std::ref(success)), GlobDirectory);
 
@@ -130,7 +130,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
 
        /* Load package config files - they may contain additional zones which
         * are authoritative on this node and are checked in HasZoneConfigAuthority(). */
-       String packagesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
+       String packagesVarDir = Application::GetConst("DataDir") + "/api/packages";
        if (Utility::PathExists(packagesVarDir))
                Utility::Glob(packagesVarDir + "/*", std::bind(&IncludePackage, _1, std::ref(success)), GlobDirectory);
 
@@ -138,7 +138,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
                return false;
 
        /* Load cluster synchronized configuration files */
-       String zonesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones";
+       String zonesVarDir = Application::GetConst("DataDir") + "/api/zones";
        if (Utility::PathExists(zonesVarDir))
                Utility::Glob(zonesVarDir + "/*", std::bind(&IncludeNonLocalZone, _1, "_cluster", std::ref(success)), GlobDirectory);
 
index 9056b60fec4ecaf077ee0a81b0daf18cf2a39271..e01834c70ca3216a0f28cbad2ba3d3276b7d3b08 100644 (file)
@@ -31,12 +31,12 @@ using namespace icinga;
 
 String FeatureUtility::GetFeaturesAvailablePath()
 {
-       return Application::GetSysconfDir() + "/icinga2/features-available";
+       return Application::GetConst("ConfigDir") + "/features-available";
 }
 
 String FeatureUtility::GetFeaturesEnabledPath()
 {
-       return Application::GetSysconfDir() + "/icinga2/features-enabled";
+       return Application::GetConst("ConfigDir") + "/features-enabled";
 }
 
 std::vector<String> FeatureUtility::GetFieldCompletionSuggestions(const String& word, bool enable)
index d0289b4fb04574c0be2cf475c9d64a735a292d46..652f70f28396d5cee92755b91455d1d00d1e3019 100644 (file)
@@ -410,7 +410,7 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
        } else {
                /* We cannot retrieve the parent certificate.
                 * Tell the user to manually copy the ca.crt file
-                * into LocalStateDir + "/lib/icinga2/certs"
+                * into DataDir + "/certs"
                 */
                Log(LogWarning, "cli")
                        << "\nNo connection to the parent node was specified.\n\n"
index eb9080b97cbff7f225c1aa6bf604e63baa2aa22a..25998825961ab38b9f00c54f7aab6c182fd05916 100644 (file)
@@ -43,12 +43,12 @@ using namespace icinga;
 
 String NodeUtility::GetConstantsConfPath()
 {
-       return Application::GetSysconfDir() + "/icinga2/constants.conf";
+       return Application::GetConst("ConfigDir") + "/constants.conf";
 }
 
 String NodeUtility::GetZonesConfPath()
 {
-       return Application::GetSysconfDir() + "/icinga2/zones.conf";
+       return Application::GetConst("ConfigDir") + "/zones.conf";
 }
 
 /*
@@ -274,7 +274,7 @@ void NodeUtility::SerializeObject(std::ostream& fp, const Dictionary::Ptr& objec
  */
 bool NodeUtility::UpdateConfiguration(const String& value, bool include, bool recursive)
 {
-       String configurationFile = Application::GetSysconfDir() + "/icinga2/icinga2.conf";
+       String configurationFile = Application::GetConst("ConfigDir") + "/icinga2.conf";
 
        Log(LogInformation, "cli")
                << "Updating '" << value << "' include in '" << configurationFile << "'.";
index b5e143730f83ec117eff473d205fe1a82be0ea8d..11e035aa7231ef230f526461d7c0ed0f4df8ea90 100644 (file)
@@ -392,7 +392,7 @@ wizard_ticket:
        } else {
                /* We cannot retrieve the parent certificate.
                 * Tell the user to manually copy the ca.crt file
-                * into LocalStateDir + "/lib/icinga2/certs"
+                * into DataDir + "/certs"
                 */
 
                std::cout <<  ConsoleColorTag(Console_Bold)
@@ -850,7 +850,7 @@ wizard_global_zone_loop_start:
                }
 
                /* Include api-users.conf */
-               String apiUsersFilePath = Application::GetSysconfDir() + "/icinga2/conf.d/api-users.conf";
+               String apiUsersFilePath = Application::GetConst("ConfigDir") + "/conf.d/api-users.conf";
 
                std::cout << ConsoleColorTag(Console_Bold | Console_ForegroundGreen)
                        << "Checking if the api-users.conf file exists...\n"
index f5e46448cbb2c5b3aa8d6d52b6abf1c7bcf29c64..f5c347eed2f244ecf84d4fb1b386858ae32e7f29 100644 (file)
@@ -67,11 +67,11 @@ void ObjectListCommand::InitParameters(boost::program_options::options_descripti
  */
 int ObjectListCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
 {
-       String objectfile = Application::GetObjectsPath();
+       String objectfile = Application::GetConst("ObjectsPath");
 
        if (!Utility::PathExists(objectfile)) {
                Log(LogCritical, "cli")
-                       << "Cannot open objects file '" << Application::GetObjectsPath() << "'.";
+                       << "Cannot open objects file '" << Application::GetConst("ObjectsPath") << "'.";
                Log(LogCritical, "cli", "Run 'icinga2 daemon -C' to validate config and generate the cache file.");
                return 1;
        }
index aabd9e41a4df28b5a9f50b78aa4fe5ac6e751dd8..6c72e1426b6f417a5e136642baad828d732c6606 100644 (file)
@@ -147,16 +147,26 @@ bool TroubleshootCommand::GeneralInfo(InfoLog& log, const boost::program_options
 
        //Application::DisplayInfoMessage() but formatted
        InfoLogLine(log)
-               << "\tApplication version: " << Application::GetAppVersion() << '\n'
-               << "\tInstallation root: " << Application::GetPrefixDir() << '\n'
-               << "\tSysconf directory: " << Application::GetSysconfDir() << '\n'
-               << "\tRun directory: " << Application::GetRunDir() << '\n'
-               << "\tLocal state directory: " << Application::GetLocalStateDir() << '\n'
-               << "\tPackage data directory: " << Application::GetPkgDataDir() << '\n'
-               << "\tState path: " << Application::GetStatePath() << '\n'
-               << "\tObjects path: " << Application::GetObjectsPath() << '\n'
-               << "\tVars path: " << Application::GetVarsPath() << '\n'
-               << "\tPID path: " << Application::GetPidPath() << '\n';
+               << "\tApplication version: " << Application::GetConst("AppVersion") << '\n'
+               << "\t\n"
+               << "\tConfig directory: " << Application::GetConst("ConfigDir") << "\n"
+               << "\tData directory: " << Application::GetConst("DataDir") << "\n"
+               << "\tLog directory: " << Application::GetConst("LogDir") << "\n"
+               << "\tCache directory: " << Application::GetConst("CacheDir") << "\n"
+               << "\tRun directory: " << Application::GetConst("InitRunDir") << "\n"
+               << "\t\n"
+               << "Older paths (deprecated):" << "\n"
+               << "\tInstallation root: " << Application::GetConst("PrefixDir") << '\n'
+               << "\tSysconf directory: " << Application::GetConst("SysconfDir") << '\n'
+               << "\tRun directory: " << Application::GetConst("RunDir") << '\n'
+               << "\tLocal state directory: " << Application::GetConst("LocalStateDir") << '\n'
+               << "\t\n"
+               << "Internally used paths:" << "\n"
+               << "\tPackage data directory: " << Application::GetConst("PkgDataDir") << '\n'
+               << "\tState path: " << Application::GetConst("StatePath") << '\n'
+               << "\tObjects path: " << Application::GetConst("ObjectsPath") << '\n'
+               << "\tVars path: " << Application::GetConst("VarsPath") << '\n'
+               << "\tPID path: " << Application::GetConst("PidPath") << '\n';
 
        InfoLogLine(log)
                << '\n';
@@ -176,7 +186,7 @@ bool TroubleshootCommand::ObjectInfo(InfoLog& log, const boost::program_options:
        InfoLogLine(log, Console_ForegroundBlue)
                << std::string(14, '=') << " OBJECT INFORMATION " << std::string(14, '=') << "\n\n";
 
-       String objectfile = Application::GetObjectsPath();
+       String objectfile = Application::GetConst("ObjectsPath");
        std::set<String> configs;
 
        if (!Utility::PathExists(objectfile)) {
@@ -252,14 +262,14 @@ bool TroubleshootCommand::ConfigInfo(InfoLog& log, const boost::program_options:
        InfoLogLine(log)
                << "A collection of important configuration files follows, please make sure to remove any sensitive data such as credentials, internal company names, etc\n";
 
-       if (!PrintFile(log, Application::GetSysconfDir() + "/icinga2/icinga2.conf")) {
+       if (!PrintFile(log, Application::GetConst("ConfigDir") + "/icinga2.conf")) {
                InfoLogLine(log, 0, LogWarning)
                        << "icinga2.conf not found, therefore skipping validation.\n"
                        << "If you are using an icinga2.conf somewhere but the default path please validate it via 'icinga2 daemon -C -c \"path\to/icinga2.conf\"'\n"
                        << "and provide it with your support request.\n";
        }
 
-       if (!PrintFile(log, Application::GetSysconfDir() + "/icinga2/zones.conf")) {
+       if (!PrintFile(log, Application::GetConst("ConfigDir") + "/zones.conf")) {
                InfoLogLine(log, 0, LogWarning)
                        << "zones.conf not found.\n"
                        << "If you are using a zones.conf somewhere but the default path please provide it with your support request\n";
@@ -370,7 +380,7 @@ void TroubleshootCommand::GetLatestReport(const String& filename, time_t& bestTi
 
 bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
 {
-       String spath = Application::GetLocalStateDir() + "/log/icinga2/crash/report.*";
+       String spath = Application::GetConst("LogDir") + "/crash/report.*";
        time_t bestTimestamp = 0;
        String bestFilename;
 
@@ -383,7 +393,7 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
                if (int const * err = boost::get_error_info<errinfo_win32_error>(ex)) {
                        if (*err != 3) {//Error code for path does not exist
                                InfoLogLine(log, 0, LogWarning)
-                                       << Application::GetLocalStateDir() << "/log/icinga2/crash/ does not exist\n";
+                                       << Application::GetConst("LogDir") + "/crash/ does not exist\n";
 
                                return false;
                        }
@@ -396,7 +406,7 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
 #else
        catch (...) {
                InfoLogLine(log, 0, LogWarning) << "Error printing crash reports.\n"
-                       << "Does " << Application::GetLocalStateDir() << "/log/icinga2/crash/ exist?\n";
+                       << "Does " << Application::GetConst("LogDir") + "/crash/ exist?\n";
 
                return false;
        }
@@ -404,7 +414,7 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
 
        if (!bestTimestamp)
                InfoLogLine(log, Console_ForegroundYellow)
-                       << "No crash logs found in " << Application::GetLocalStateDir().CStr() << "/log/icinga2/crash/\n\n";
+                       << "No crash logs found in " << Application::GetConst("LogDir") << "/crash/\n\n";
        else {
                InfoLogLine(log)
                        << "Latest crash report is from " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", Utility::GetTime()) << '\n'
@@ -444,7 +454,9 @@ bool TroubleshootCommand::PrintFile(InfoLog& log, const String& path)
 
 bool TroubleshootCommand::CheckConfig()
 {
-       return DaemonUtility::ValidateConfigFiles({ Application::GetSysconfDir() + "/icinga2/icinga2.conf" }, Application::GetObjectsPath());
+       String configDir = Application::GetConst("ConfigDir");
+       String objectsPath = Application::GetConst("ObjectsPath");
+       return DaemonUtility::ValidateConfigFiles({ configDir + "/icinga2.conf" }, objectsPath);
 }
 
 //print is supposed allow the user to print the object file
@@ -610,10 +622,10 @@ void TroubleshootCommand::InitParameters(boost::program_options::options_descrip
 int TroubleshootCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
 {
 #ifdef _WIN32 //Dislikes ':' in filenames
-       String path = Application::GetLocalStateDir() + "/log/icinga2/troubleshooting-"
+       String path = Application::GetConst("LogDir") + "/troubleshooting-"
                + Utility::FormatDateTime("%Y-%m-%d_%H-%M-%S", Utility::GetTime()) + ".log";
 #else
-       String path = Application::GetLocalStateDir() + "/log/icinga2/troubleshooting-"
+       String path = Application::GetConst("LogDir") + "/troubleshooting-"
                + Utility::FormatDateTime("%Y-%m-%d_%H:%M:%S", Utility::GetTime()) + ".log";
 #endif /*_WIN32*/
 
index 76fa634aa4b3a40c1ea1e086561a7902506e0fb9..8557701480a333843b1d7490934ae38e62103b8b 100644 (file)
@@ -75,7 +75,7 @@ int VariableGetCommand::Run(const boost::program_options::variables_map& vm, con
                return 0;
        }
 
-       String varsfile = Application::GetVarsPath();
+       String varsfile = Application::GetConst("VarsPath");
 
        if (!Utility::PathExists(varsfile)) {
                Log(LogCritical, "cli")
index 9aff1cbea40094c06664350325602ca4cd067437..9ebbadf119c44777faf1a838740cb7170b955308 100644 (file)
@@ -53,7 +53,7 @@ String VariableListCommand::GetShortDescription() const
  */
 int VariableListCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
 {
-       String varsfile = Application::GetVarsPath();
+       String varsfile = Application::GetConst("VarsPath");
 
        if (!Utility::PathExists(varsfile)) {
                Log(LogCritical, "cli")
index 9044a9e9bf161e1da50066a50743eae6f027c991..ed9bd770da202d019163a132b47b00f2df379eae 100644 (file)
@@ -31,7 +31,7 @@ using namespace icinga;
 
 Value VariableUtility::GetVariable(const String& name)
 {
-       String varsfile = Application::GetVarsPath();
+       String varsfile = Application::GetConst("VarsPath");
 
        std::fstream fp;
        fp.open(varsfile.CStr(), std::ios_base::in);
@@ -61,7 +61,7 @@ Value VariableUtility::GetVariable(const String& name)
 
 void VariableUtility::PrintVariables(std::ostream& outfp)
 {
-       String varsfile = Application::GetVarsPath();
+       String varsfile = Application::GetConst("VarsPath");
 
        std::fstream fp;
        fp.open(varsfile.CStr(), std::ios_base::in);
index df4a3e0eb6101015e16f375590218de2a77b80ae..be33add0be4450e8713b1c0cd0a4b9d3711785f8 100644 (file)
@@ -42,21 +42,21 @@ set_target_properties (
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/command.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/compatlog.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/statusdata.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
-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}/spool/icinga2\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_RUNDIR}/icinga2/cmd\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_LOGDIR}/compat/archives\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_SPOOLDIR}\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_INITRUNDIR}/cmd\")")
 
 set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
index 18b3d0ac4e7f55c23e630ea26c8efcbe82dbf2b9..cc558a55341c253ee9dfbcf6fcb8e49f153ac8b8 100644 (file)
@@ -30,7 +30,7 @@ class CheckResultReader : ConfigObject
        activation_priority 100;
 
        [config] String spool_dir {
-               default {{{ return Application::GetLocalStateDir() + "/lib/icinga2/spool/checkresults/"; }}}
+               default {{{ return Application::GetConst("DataDir") + "/spool/checkresults/"; }}}
        };
 };
 
index 322236cd848ff2a921e442c2f9b1e895fcafc64a..4066a72bd27772381bb564c528d9302c35303930 100644 (file)
@@ -30,7 +30,7 @@ class CompatLogger : ConfigObject
        activation_priority 100;
 
        [config] String log_dir {
-               default {{{ return Application::GetLocalStateDir() + "/log/icinga2/compat"; }}}
+               default {{{ return Application::GetConst("LogDir") + "/compat"; }}}
        };
        [config] String rotation_method {
                default {{{ return "HOURLY"; }}}
index baffb7f5111b19323c6c19e61d92bac4dc530637..697b3a0c430c8f2940ccff31868b4ab61cb6edd1 100644 (file)
@@ -30,7 +30,7 @@ class ExternalCommandListener : ConfigObject
        activation_priority 100;
 
        [config] String command_path {
-               default {{{ return Application::GetRunDir() + "/icinga2/cmd/icinga2.cmd"; }}}
+               default {{{ return Application::GetConst("InitRunDir") + "/cmd/icinga2.cmd"; }}}
        };
 };
 
index 407a14d9a727e58659bac5dc8ab1933f445088e6..e5a4578ac3d5cfa5fbc2c1b2bcf3706fdb88bbb0 100644 (file)
@@ -559,7 +559,7 @@ void StatusDataWriter::UpdateObjectsCache()
 {
        CONTEXT("Writing objects.cache file");
 
-       String objectsPath = GetObjectsPath();
+       String objectsPath = Application::GetConst("ObjectsPath");
 
        std::fstream objectfp;
        String tempObjectsPath = Utility::CreateTempFile(objectsPath + ".XXXXXX", 0644, objectfp);
index 5ac2969a914df976c7219daae0224a79968096f6..846834f31b16cb39171c558fe4ac5576dcf1192b 100644 (file)
@@ -30,10 +30,10 @@ class StatusDataWriter : ConfigObject
        activation_priority 100;
 
        [config] String status_path {
-               default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/status.dat"; }}}
+               default {{{ return Application::GetConst("CacheDir") + "/status.dat"; }}}
        };
        [config] String objects_path {
-               default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache"; }}}
+               default {{{ return Application::GetConst("CacheDir") + "/objects.cache"; }}}
        };
        [config] double update_interval {
                default {{{ return 15; }}}
index e2061286059c73722ccb38bff387e7cb4a405b17..af2afd01791e38f724ff8adb9b8ea44f7c35a04d 100644 (file)
@@ -577,8 +577,8 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
 
        if (withModAttrs) {
                /* restore modified attributes */
-               if (Utility::PathExists(Application::GetModAttrPath())) {
-                       std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(Application::GetModAttrPath());
+               if (Utility::PathExists(Application::GetConst("ModAttrPath"))) {
+                       std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(Application::GetConst("ModAttrPath"));
 
                        if (expression) {
                                try {
index 1587cbf19af12fe6bc5e07c2b57ec98cb08c91be..30e180f651aba2c0482becf9e484e2ff406a2476 100644 (file)
@@ -38,7 +38,7 @@ set_target_properties (
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/ido-mysql.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install(
index 35f15fab59e3401647aad6bc8861d5c241011cac..b34736e66b916cedb9de7e4cdc34cdd2a5a6d804 100644 (file)
@@ -38,7 +38,7 @@ set_target_properties (
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/ido-pgsql.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install(
index 454c78d6d03f097ecbc4fa0421047c899aea5c6c..6ac00aa60646b7930e8c1e46b90ed536af294435 100644 (file)
@@ -156,13 +156,13 @@ static void PersistModAttrHelper(std::fstream& fp, ConfigObject::Ptr& previousOb
 
 void IcingaApplication::DumpProgramState()
 {
-       ConfigObject::DumpObjects(GetStatePath());
+       ConfigObject::DumpObjects(GetConst("StatePath"));
        DumpModifiedAttributes();
 }
 
 void IcingaApplication::DumpModifiedAttributes()
 {
-       String path = GetModAttrPath();
+       String path = GetConst("ModAttrPath");
 
        std::fstream fp;
        String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0644, fp);
index 51216a02c38892c3afa1a02ff53c92b244cdb14b..eac7f5903357bea00d01903eccfd74d5f36d03ed 100644 (file)
@@ -46,8 +46,6 @@ public:
 
        static IcingaApplication::Ptr GetInstance();
 
-       String GetPidPath() const;
-
        bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Value *result) const override;
 
        String GetNodeName() const;
index e93e2624ba6fd5b38e2eb88dd1ce387122cd4ca0..9b657645f18569a4c56a8b14a1b1c3181017f91f 100644 (file)
@@ -72,9 +72,9 @@ set_target_properties (
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/livestatus.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_RUNDIR}/icinga2/cmd\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_INITRUNDIR}/cmd\")")
 
 set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
index 0742a6fb53898544632ce58f3d1580ea1110fdde..1a4729d5e56ad22a2f8b153dcb512f06e1f7c560 100644 (file)
@@ -32,7 +32,7 @@ class LivestatusListener : ConfigObject {
                default {{{ return "unix"; }}}
        };
        [config] String socket_path {
-               default {{{ return Application::GetRunDir() + "/icinga2/cmd/livestatus"; }}}
+               default {{{ return Application::GetConst("InitRunDir") + "/cmd/livestatus"; }}}
        };
        [config] String bind_host {
                default {{{ return "127.0.0.1"; }}}
@@ -41,7 +41,7 @@ class LivestatusListener : ConfigObject {
                default {{{ return "6558"; }}}
        };
        [config] String compat_log_path {
-               default {{{ return Application::GetLocalStateDir() + "/log/icinga2/compat"; }}}
+               default {{{ return Application::GetConst("LogDir") + "/compat"; }}}
        };
 };
 
index 6c5940b9aef9c2d07750c5c3786f7cf1dfb9a13b..91207ad6d55a7ec11b6bf7906b10fa4df18185e3 100644 (file)
@@ -36,14 +36,14 @@ set_target_properties (
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/notification.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 if(NOT WIN32)
-  install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
-  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/notification.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/notification.conf\")")
+  install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled\")")
+  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/notification.conf \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled/notification.conf\")")
 else()
-  install_if_not_exists(${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/notification.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled)
+  install_if_not_exists(${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/notification.conf ${ICINGA2_CONFIGDIR}/features-enabled)
 endif()
 
 set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
index 7b07804149cd95f20e233deefbdcc39ff90c818e..06a9f7336035f45a01d9b9483b9a04942cbd58dc 100644 (file)
@@ -46,35 +46,35 @@ set_target_properties (
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/gelf.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/graphite.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/influxdb.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/elasticsearch.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/opentsdb.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
 install_if_not_exists(
   ${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/perfdata.conf
-  ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
+  ${ICINGA2_CONFIGDIR}/features-available
 )
 
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2/perfdata\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2/tmp\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_SPOOLDIR}/perfdata\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_SPOOLDIR}/tmp\")")
 
 set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
index c0988f339f38b417a11274a4fd37c413f77807c0..4b6560291099c366f48d49bbaee97f6a25c24e58 100644 (file)
@@ -30,16 +30,16 @@ class PerfdataWriter : ConfigObject
        activation_priority 100;
 
        [config] String host_perfdata_path {
-               default {{{ return Application::GetLocalStateDir() + "/spool/icinga2/perfdata/host-perfdata"; }}}
+               default {{{ return Application::GetConst("SpoolDir") + "/perfdata/host-perfdata"; }}}
        };
        [config] String service_perfdata_path {
-               default {{{ return Application::GetLocalStateDir() + "/spool/icinga2/perfdata/service-perfdata"; }}}
+               default {{{ return Application::GetConst("SpoolDir") + "/perfdata/service-perfdata"; }}}
        };
        [config] String host_temp_path {
-               default {{{ return Application::GetLocalStateDir() + "/spool/icinga2/tmp/host-perfdata"; }}}
+               default {{{ return Application::GetConst("SpoolDir") + "/tmp/host-perfdata"; }}}
        };
        [config] String service_temp_path {
-               default {{{ return Application::GetLocalStateDir() + "/spool/icinga2/tmp/service-perfdata"; }}}
+               default {{{ return Application::GetConst("SpoolDir") + "/tmp/service-perfdata"; }}}
        };
        [config] String host_format_template {
                default {{{
index bb9593c56bd58791dbc06e83488bd90a5e77f68d..61b6523ffbb89024e5f1823ab3d75136d5ca5d2b 100644 (file)
@@ -76,10 +76,10 @@ set_target_properties (
   FOLDER Lib
 )
 
-#install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/api\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/api/log\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/api/zones\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/certs\")")
-install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/certificate-requests\")")
+#install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/api\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/api/log\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/api/zones\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/certs\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/certificate-requests\")")
 
 
index 30a79a35fe05d7352895b8cdce529338e6f98a7d..0c898723721960e2d73d31daf19337005fa61700 100644 (file)
@@ -202,7 +202,7 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const
        if (sumUpdates == 0)
                return;
 
-       String oldDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones/" + zone->GetName();
+       String oldDir = Application::GetConst("DataDir") + "/api/zones/" + zone->GetName();
 
        Log(LogInformation, "ApiListener")
                << "Copying " << sumUpdates << " zone configuration files for zone '" << zone->GetName() << "' to '" << oldDir << "'.";
@@ -240,7 +240,7 @@ void ApiListener::SendConfigUpdate(const JsonRpcConnection::Ptr& aclient)
        Dictionary::Ptr configUpdateV1 = new Dictionary();
        Dictionary::Ptr configUpdateV2 = new Dictionary();
 
-       String zonesDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones";
+       String zonesDir = Application::GetConst("DataDir") + "/api/zones";
 
        for (const Zone::Ptr& zone : ConfigType::GetObjectsByType<Zone>()) {
                String zoneDir = zonesDir + "/" + zone->GetName();
@@ -315,7 +315,7 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D
                        continue;
                }
 
-               String oldDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones/" + zone->GetName();
+               String oldDir = Application::GetConst("DataDir") + "/api/zones/" + zone->GetName();
 
                Utility::MkDirP(oldDir, 0700);
 
index c1546710d0a84b80450a804846c06df391ec8bea..c7ba834b4d168a93f52c8469237df20d82a69090 100644 (file)
@@ -56,22 +56,22 @@ ApiListener::ApiListener()
 
 String ApiListener::GetApiDir()
 {
-       return Application::GetLocalStateDir() + "/lib/icinga2/api/";
+       return Application::GetConst("DataDir") + "/api/";
 }
 
 String ApiListener::GetCertsDir()
 {
-       return Application::GetLocalStateDir() + "/lib/icinga2/certs/";
+       return Application::GetConst("DataDir") + "/certs/";
 }
 
 String ApiListener::GetCaDir()
 {
-       return Application::GetLocalStateDir() + "/lib/icinga2/ca/";
+       return Application::GetConst("DataDir") + "/ca/";
 }
 
 String ApiListener::GetCertificateRequestsDir()
 {
-       return Application::GetLocalStateDir() + "/lib/icinga2/certificate-requests/";
+       return Application::GetConst("DataDir") + "/certificate-requests/";
 }
 
 String ApiListener::GetDefaultCertPath()
index 56ed57f7be27a135a4b1982e9c46bfea750fc67b..19b1022e8d66358d9d42954fcc4277b289631c29 100644 (file)
@@ -30,7 +30,7 @@ using namespace icinga;
 
 String ConfigPackageUtility::GetPackageDir()
 {
-       return Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
+       return Application::GetConst("DataDir") + "/api/packages";
 }
 
 void ConfigPackageUtility::CreatePackage(const String& name)