Warn in case of failed conf.d exclusion

refs #4508
This commit is contained in:
Jean Flach 2018-05-02 15:10:44 +02:00 committed by Michael Friedrich
parent 58f923f5f7
commit a43cf8e9ef
3 changed files with 11 additions and 3 deletions

View File

@ -270,8 +270,9 @@ void NodeUtility::SerializeObject(std::ostream& fp, const Dictionary::Ptr& objec
* include = true, will add an include statement or uncomment a statement if one is existing
* resursive = false, will search for a non-resursive include statement
* recursive = true, will search for a resursive include statement
* Returns true on success, false if option was not found
*/
void NodeUtility::UpdateConfiguration(const String& value, const bool& include, const bool& recursive)
bool NodeUtility::UpdateConfiguration(const String& value, const bool& include, const bool& recursive)
{
String configurationFile = Application::GetSysconfDir() + "/icinga2/icinga2.conf";
@ -331,6 +332,8 @@ void NodeUtility::UpdateConfiguration(const String& value, const bool& include,
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(configurationFile));
}
return (found || include);
}
void NodeUtility::UpdateConstant(const String& name, const String& value)

View File

@ -44,7 +44,7 @@ public:
static bool WriteNodeConfigObjects(const String& filename, const Array::Ptr& objects);
static void UpdateConfiguration(const String& value, const bool& include, const bool& recursive);
static bool UpdateConfiguration(const String& value, const bool& include, const bool& recursive);
static void UpdateConstant(const String& name, const String& value);
/* node setup helpers */

View File

@ -631,7 +631,12 @@ wizard_global_zone_loop_start:
<< "Disable the inclusion of the conf.d directory...\n"
<< ConsoleColorTag(Console_Normal);
NodeUtility::UpdateConfiguration("\"conf.d\"", false, true);
if(!NodeUtility::UpdateConfiguration("\"conf.d\"", false, true)) {
std::cout << ConsoleColorTag(Console_Bold | Console_ForegroundRed)
<< "Failed to disable conf.d inclusion, it may already be disabled."
<< ConsoleColorTag(Console_Normal);
}
}
return 0;