Log warning when sysconfig file cannot be read

refs #6215

refs #6241
This commit is contained in:
Michael Friedrich 2018-04-19 09:54:29 +02:00
parent 978d707e3b
commit bd2c266bf1
2 changed files with 11 additions and 0 deletions

View File

@ -154,6 +154,13 @@ int Main(void)
Application::DeclareZonesDir(Application::GetSysconfDir() + "/icinga2/zones.d");
#ifndef _WIN32
if (!Utility::PathExists(Application::GetSysconfigFile())) {
Log(LogWarning, "icinga-app")
<< "Sysconfig file '" << Application::GetSysconfigFile() << "' cannot be read. Using default values.";
}
#endif /* _WIN32 */
String icingaUser = Utility::GetFromSysconfig("ICINGA2_USER");
if (icingaUser.IsEmpty())
icingaUser = ICINGA_USER;
@ -468,6 +475,7 @@ int Main(void)
std::cout << visibleDesc << std::endl
<< "Report bugs at <https://github.com/Icinga/icinga2>" << std::endl
<< "Get support: <https://www.icinga.com/support/>" << std::endl
<< "Icinga home page: <https://www.icinga.com/>" << std::endl;
return EXIT_SUCCESS;
}

View File

@ -1958,6 +1958,9 @@ String Utility::GetFromSysconfig(const String& env)
if (sysconf.IsEmpty())
return "";
if (!Utility::PathExists(sysconf))
return "";
String cmdInner = ". " + EscapeShellArg(sysconf) + " 2>&1 >/dev/null;echo \"$" + env + "\"";
String cmd = "sh -c " + EscapeShellArg(cmdInner);