]> granicus.if.org Git - icinga2/commitdiff
Remove need for init.conf 5850/head
authorJean Flach <jean-marcel.flach@icinga.com>
Mon, 29 Jan 2018 13:23:53 +0000 (14:23 +0100)
committerJean Flach <jean-marcel.flach@icinga.com>
Tue, 20 Feb 2018 13:16:43 +0000 (14:16 +0100)
doc/17-language-reference.md
etc/CMakeLists.txt
etc/icinga2/init.conf.cmake [deleted file]
icinga-app/icinga.cpp

index 93991a7a2cd109bb4ba03e0e438cf4ce44d9a26b..e288c611a99885453a18b4eed3a581853f416491 100644 (file)
@@ -389,8 +389,8 @@ ObjectsPath         |**Read-write.** Contains the path of the Icinga 2 objects f
 PidPath             |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to RunDir + "/icinga2/icinga2.pid".
 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. Used in the `init.conf` configuration file.
-RunAsGroup          |**Read-write.** Defines the group the Icinga 2 daemon is running as. Used in the `init.conf` configuration file.
+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".
@@ -407,9 +407,9 @@ Variable            |Description
 --------------------|-------------------
 EventEngine         |**Read-write.** The name of the socket event engine, can be `poll` or `epoll`. The epoll interface is only supported on Linux.
 AttachDebugger      |**Read-write.** Whether to attach a debugger when Icinga 2 crashes. Defaults to `false`.
-RLimitFiles         |**Read-write.** Defines the resource limit for RLIMIT_NOFILE that should be set at start-up. Value cannot be set lower than the default `16 * 1024`. 0 disables the setting. Used in the `init.conf` configuration file.
-RLimitProcesses     |**Read-write.** Defines the resource limit for RLIMIT_NPROC that should be set at start-up. Value cannot be set lower than the default `16 * 1024`. 0 disables the setting. Used in the `init.conf` configuration file.
-RLimitStack         |**Read-write.** Defines the resource limit for RLIMIT_STACK that should be set at start-up. Value cannot be set lower than the default `256 * 1024`. 0 disables the setting. Used in the `init.conf` configuration file.
+RLimitFiles         |**Read-write.** Defines the resource limit for RLIMIT_NOFILE that should be set at start-up. Value cannot be set lower than the default `16 * 1024`. 0 disables the setting. Set in Icinga 2 sysconfig.
+RLimitProcesses     |**Read-write.** Defines the resource limit for RLIMIT_NPROC that should be set at start-up. Value cannot be set lower than the default `16 * 1024`. 0 disables the setting. Set in Icinga 2 sysconfig.
+RLimitStack         |**Read-write.** Defines the resource limit for RLIMIT_STACK that should be set at start-up. Value cannot be set lower than the default `256 * 1024`. 0 disables the setting. Set in Icinga 2 sysconfig.
 
 ## Apply <a id="apply"></a>
 
index bce13366b3a29e5e5a4a7ab86a84176a80e6e4ce..bffca3016ade3d16cd3bafe16efcf1fc0b7270c8 100644 (file)
@@ -15,8 +15,6 @@
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-configure_file(icinga2/init.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2/init.conf @ONLY)
-
 if(NOT WIN32)
   configure_file(icinga2/constants.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2/constants.conf @ONLY)
 endif()
@@ -25,8 +23,6 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   configure_file(logrotate.d/icinga2.cmake ${CMAKE_CURRENT_BINARY_DIR}/logrotate.d/icinga2 @ONLY)
 endif()
 
-install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/icinga2/init.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
-
 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)
diff --git a/etc/icinga2/init.conf.cmake b/etc/icinga2/init.conf.cmake
deleted file mode 100644 (file)
index 22406a9..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * This file is read by Icinga 2 before the main
- * configuration file (icinga2.conf) is processed.
- */
-
index f40a135419e91dfa0baf2402cbce27199f6bd786..af8a1dda98ef36785d036fc60d5f8ebb8a18e409 100644 (file)
@@ -155,21 +155,62 @@ static int Main()
 
        Application::DeclareZonesDir(Application::GetSysconfDir() + "/icinga2/zones.d");
 
-       String icinga_user = Utility::GetFromSysconfig("ICINGA2_USER");
-       if (icinga_user.IsEmpty())
-               icinga_user = ICINGA_USER;
-
-       String icinga_group = Utility::GetFromSysconfig("ICINGA2_GROUP");
-       if (icinga_group.IsEmpty())
-               icinga_group = ICINGA_GROUP;
-
-       Application::DeclareRunAsUser(icinga_user);
-       Application::DeclareRunAsGroup(icinga_group);
-#ifdef __linux__
-       Application::DeclareRLimitFiles(Application::GetDefaultRLimitFiles());
-       Application::DeclareRLimitProcesses(Application::GetDefaultRLimitProcesses());
-       Application::DeclareRLimitStack(Application::GetDefaultRLimitStack());
-#endif /* __linux__ */
+       String icingaUser = Utility::GetFromSysconfig("ICINGA2_USER");
+       if (icingaUser.IsEmpty())
+               icingaUser = ICINGA_USER;
+
+       String icingaGroup = Utility::GetFromSysconfig("ICINGA2_GROUP");
+       if (icingaGroup.IsEmpty())
+               icingaGroup = ICINGA_GROUP;
+
+       Application::DeclareRunAsUser(icingaUser);
+       Application::DeclareRunAsGroup(icingaGroup);
+
+#ifdef RLIMIT_NOFILE
+       String rLimitFiles = Utility::GetFromSysconfig("ICINGA2_RLIMIT_FILES");
+       if (rLimitFiles.IsEmpty())
+               Application::DeclareRLimitFiles(Application::GetDefaultRLimitFiles());
+       else {
+               try {
+                       Application::DeclareRLimitFiles(Convert::ToLong(rLimitFiles));
+               } catch (const std::invalid_argument& ex) {
+                       std::cout
+                               << "Error while parsing \"ICINGA2_RLIMIT_FILES\" from sysconfig: " << ex.what() << '\n';
+                       return EXIT_FAILURE;
+               }
+       }
+#endif /* RLIMIT_NOFILE */
+
+#ifdef RLIMIT_NPROC
+       String rLimitProcesses = Utility::GetFromSysconfig("ICINGA2_RLIMIT_PROCESSES");
+       if (rLimitProcesses.IsEmpty())
+               Application::DeclareRLimitProcesses(Application::GetDefaultRLimitProcesses());
+       else {
+               try {
+                       Application::DeclareRLimitProcesses(Convert::ToLong(rLimitProcesses));
+               } catch (const std::invalid_argument& ex) {
+                       std::cout
+                               << "Error while parsing \"ICINGA2_RLIMIT_PROCESSES\" from sysconfig: " << ex.what() << '\n';
+                       return EXIT_FAILURE;
+               }
+       }
+#endif /* RLIMIT_NPROC */
+
+#ifdef RLIMIT_STACK
+       String rLimitStack = Utility::GetFromSysconfig("ICINGA2_RLIMIT_STACK");
+       if (rLimitStack.IsEmpty())
+               Application::DeclareRLimitStack(Application::GetDefaultRLimitStack());
+       else {
+               try {
+                       Application::DeclareRLimitStack(Convert::ToLong(rLimitStack));
+               } catch (const std::invalid_argument& ex) {
+                       std::cout
+                               << "Error while parsing \"ICINGA2_RLIMIT_STACK\" from sysconfig: " << ex.what() << '\n';
+                       return EXIT_FAILURE;
+               }
+       }
+#endif /* RLIMIT_STACK */
+
        Application::DeclareConcurrency(std::thread::hardware_concurrency());
        Application::DeclareMaxConcurrentChecks(Application::GetDefaultMaxConcurrentChecks());
 
@@ -185,21 +226,6 @@ static int Main()
        ScriptGlobal::Set("BuildCompilerName", ICINGA_BUILD_COMPILER_NAME);
        ScriptGlobal::Set("BuildCompilerVersion", ICINGA_BUILD_COMPILER_VERSION);
 
-       String initconfig = Application::GetSysconfDir() + "/icinga2/init.conf";
-
-       if (Utility::PathExists(initconfig)) {
-               std::unique_ptr<Expression> expression;
-               try {
-                       expression = ConfigCompiler::CompileFile(initconfig);
-
-                       ScriptFrame frame(true);
-                       expression->Evaluate(frame);
-               } catch (const std::exception& ex) {
-                       Log(LogCritical, "config", DiagnosticInformation(ex));
-                       return EXIT_FAILURE;
-               }
-       }
-
        if (!autocomplete)
                Application::SetResourceLimits();