]> granicus.if.org Git - icinga2/commitdiff
Only run 'api setup' if the feature was not enabled
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 25 Jun 2015 08:21:18 +0000 (10:21 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 25 Jun 2015 08:21:18 +0000 (10:21 +0200)
It is safe to assume that the user either did run
'node wizard' or 'node setup' in >= 2.3.x before, or
manually enabled the api feature and deployed the
certificates (otherwise Icinga2 wouldn't start either).

In that case we'll skip the api setup to ensure that we
don't override any existing configuration at all.

refs #9471

lib/cli/apisetuputility.cpp

index 5c3d912ee3272416563c4ca315233fb6228ed501..5694d7059d3b15e5804c4c1517871f8458980f4e 100644 (file)
@@ -45,6 +45,16 @@ String ApiSetupUtility::GetConfdPath(void)
 
 int ApiSetupUtility::SetupMaster(void)
 {
+       /* if the 'api' feature is enabled we can safely assume
+        * that either 'api setup' was run, or the user manually
+        * enabled the api including all certificates e.g. by 'node wizard' in <= v2.3.x
+        */
+       if (FeatureUtility::CheckFeatureEnabled("api")) {
+               Log(LogInformation, "cli")
+                   << "'api' feature already enabled, skipping feature enable and master certificate creation.\n";
+               return 0;
+       }
+
        Log(LogInformation, "cli")
            << "Generating new CA.\n";
 
@@ -177,6 +187,5 @@ int ApiSetupUtility::SetupMaster(void)
        enable.push_back("api");
        FeatureUtility::EnableFeatures(enable);
 
-
        return 0;
 }