Implement --no-config option.

Fixes #4998
This commit is contained in:
Gunnar Beutner 2013-11-05 09:13:43 +01:00
parent 614e33e900
commit 3088b9d39d
1 changed files with 6 additions and 3 deletions

View File

@ -66,9 +66,11 @@ static bool LoadConfigFiles(const String& appType, bool validateOnly)
{ {
ConfigCompilerContext::GetInstance()->Reset(); ConfigCompilerContext::GetInstance()->Reset();
if (g_AppParams.count("config") > 0) {
BOOST_FOREACH(const String& configPath, g_AppParams["config"].as<std::vector<String> >()) { BOOST_FOREACH(const String& configPath, g_AppParams["config"].as<std::vector<String> >()) {
ConfigCompiler::CompileFile(configPath); ConfigCompiler::CompileFile(configPath);
} }
}
String name, fragment; String name, fragment;
BOOST_FOREACH(boost::tie(name, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) { BOOST_FOREACH(boost::tie(name, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) {
@ -207,6 +209,7 @@ int main(int argc, char **argv)
("include,I", po::value<std::vector<String> >(), "add include search directory") ("include,I", po::value<std::vector<String> >(), "add include search directory")
("define,D", po::value<std::vector<String> >(), "define a variable") ("define,D", po::value<std::vector<String> >(), "define a variable")
("config,c", po::value<std::vector<String> >(), "parse a configuration file") ("config,c", po::value<std::vector<String> >(), "parse a configuration file")
("no-config,z", "start without a configuration file")
("validate,C", "exit after validating the configuration") ("validate,C", "exit after validating the configuration")
("debug,x", "enable debugging") ("debug,x", "enable debugging")
("daemonize,d", "detach from the controlling terminal") ("daemonize,d", "detach from the controlling terminal")
@ -347,7 +350,7 @@ int main(int argc, char **argv)
} }
} }
if (g_AppParams.count("config") == 0) { if (g_AppParams.count("no-config") == 0 && g_AppParams.count("config") == 0) {
Log(LogCritical, "icinga-app", "You need to specify at least one config file (using the --config option)."); Log(LogCritical, "icinga-app", "You need to specify at least one config file (using the --config option).");
return EXIT_FAILURE; return EXIT_FAILURE;