| 607 | } |
| 608 | |
| 609 | int NodeWizardCommand::MasterSetup() const |
| 610 | { |
| 611 | std::string answer; |
| 612 | String choice; |
| 613 | |
| 614 | std::cout << ConsoleColorTag(Console_Bold) << "Starting the Master setup routine...\n\n"; |
| 615 | |
| 616 | /* CN */ |
| 617 | std::cout << ConsoleColorTag(Console_Bold) |
| 618 | << "Please specify the common name" << ConsoleColorTag(Console_Normal) |
| 619 | << " (CN) [" << Utility::GetFQDN() << "]: "; |
| 620 | |
| 621 | std::getline(std::cin, answer); |
| 622 | |
| 623 | if (answer.empty()) |
| 624 | answer = Utility::GetFQDN(); |
| 625 | |
| 626 | String cn = answer; |
| 627 | cn = cn.Trim(); |
| 628 | |
| 629 | std::cout << ConsoleColorTag(Console_Bold | Console_ForegroundGreen) |
| 630 | << "Reconfiguring Icinga...\n" |
| 631 | << ConsoleColorTag(Console_Normal); |
| 632 | |
| 633 | /* check whether the user wants to generate a new certificate or not */ |
| 634 | String existing_path = ApiListener::GetCertsDir() + "/" + cn + ".crt"; |
| 635 | |
| 636 | std::cout << ConsoleColorTag(Console_Normal) |
| 637 | << "Checking for existing certificates for common name '" << cn << "'...\n"; |
| 638 | |
| 639 | if (Utility::PathExists(existing_path)) { |
| 640 | std::cout << "Certificate '" << existing_path << "' for CN '" |
| 641 | << cn << "' already existing. Skipping certificate generation.\n"; |
| 642 | } else { |
| 643 | std::cout << "Certificates not yet generated. Running 'api setup' now.\n"; |
| 644 | ApiSetupUtility::SetupMasterCertificates(cn); |
| 645 | } |
| 646 | |
| 647 | std::cout << ConsoleColorTag(Console_Bold) |
| 648 | << "Generating master configuration for Icinga 2.\n" |
| 649 | << ConsoleColorTag(Console_Normal); |
| 650 | |
| 651 | ApiSetupUtility::SetupMasterApiUser(); |
| 652 | |
| 653 | if (!FeatureUtility::CheckFeatureEnabled("api")) |
| 654 | ApiSetupUtility::SetupMasterEnableApi(); |
| 655 | else |
| 656 | std::cout << "'api' feature already enabled.\n"; |
| 657 | |
| 658 | /* Setup command hardcodes this as FQDN */ |
| 659 | String endpointName = cn; |
| 660 | |
| 661 | /* Different zone name. */ |
| 662 | std::cout << "\nMaster zone name [master]: "; |
| 663 | std::getline(std::cin, answer); |
| 664 | |
| 665 | if (answer.empty()) |
| 666 | answer = "master"; |
nothing calls this directly
no test coverage detected