def main(): """Install process.""" parser = argparse.ArgumentParser() parser.add_argument("--debug", action="store_true", default=False, help="Enable debug output") parser.add_argument("--force", action="store_true", default=False, help="Force installation") parser.add_argument("hostname", type=str, help="The hostname of your future mail server") args = parser.parse_args() if args.debug: utils.ENV["debug"] = True utils.printcolor("Welcome to Modoboa installer!", utils.GREEN) config = configparser.SafeConfigParser() with open("installer.cfg") as fp: config.readfp(fp) if not config.has_section("general"): config.add_section("general") config.set("general", "hostname", args.hostname) utils.printcolor( "Your mail server {} will be installed with the following components:". format(args.hostname), utils.BLUE) components = [] for section in config.sections(): if section in [ "general", "database", "mysql", "postgres", "certificate", "letsencrypt" ]: continue if (config.has_option(section, "enabled") and not config.getboolean(section, "enabled")): continue components.append(section) utils.printcolor(" ".join(components), utils.YELLOW) if not args.force: answer = utils.user_input("Do you confirm? (Y/n) ") if answer.lower().startswith("n"): return config.set("general", "force", str(args.force)) utils.printcolor( "The process can be long, feel free to take a coffee " "and come back later ;)", utils.BLUE) utils.printcolor("Starting...", utils.GREEN) package.backend.install("sudo") ssl_backend = ssl.get_backend(config) if ssl_backend: ssl_backend.create() scripts.install("modoboa", config) scripts.install("postfix", config) scripts.install("amavis", config) scripts.install("dovecot", config) utils.printcolor( "Congratulations! You can enjoy Modoboa at https://{} (admin:password)" .format(args.hostname), utils.GREEN)
def main(input_args): """Install process.""" parser = argparse.ArgumentParser() versions = (["latest"] + list(compatibility_matrix.COMPATIBILITY_MATRIX.keys())) parser.add_argument("--debug", action="store_true", default=False, help="Enable debug output") parser.add_argument("--force", action="store_true", default=False, help="Force installation") parser.add_argument("--configfile", default="installer.cfg", help="Configuration file to use") parser.add_argument("--version", default="latest", choices=versions, help="Modoboa version to install") parser.add_argument( "--stop-after-configfile-check", action="store_true", default=False, help="Check configuration, generate it if needed and exit") parser.add_argument( "--interactive", action="store_true", default=False, help="Generate configuration file with user interaction") parser.add_argument("domain", type=str, help="The main domain of your future mail server") args = parser.parse_args(input_args) if args.debug: utils.ENV["debug"] = True utils.printcolor("Welcome to Modoboa installer!\n", utils.GREEN) utils.check_config_file(args.configfile, args.interactive) if args.stop_after_configfile_check: return config = configparser.SafeConfigParser() with open(args.configfile) as fp: config.readfp(fp) if not config.has_section("general"): config.add_section("general") config.set("general", "domain", args.domain) config.set("dovecot", "domain", args.domain) config.set("modoboa", "version", args.version) utils.printcolor( "Warning:\n" "Before you start the installation, please make sure the following " "DNS records exist for domain '{}':\n" " mail IN A <IP ADDRESS OF YOUR SERVER>\n" " IN MX {}.\n".format(args.domain, config.get("general", "hostname")), utils.CYAN) utils.printcolor( "Your mail server will be installed with the following components:", utils.BLUE) components = [] for section in config.sections(): if section in [ "general", "database", "mysql", "postgres", "certificate", "letsencrypt" ]: continue if (config.has_option(section, "enabled") and not config.getboolean(section, "enabled")): continue components.append(section) utils.printcolor(" ".join(components), utils.YELLOW) if not args.force: answer = utils.user_input("Do you confirm? (Y/n) ") if answer.lower().startswith("n"): return config.set("general", "force", str(args.force)) utils.printcolor( "The process can be long, feel free to take a coffee " "and come back later ;)", utils.BLUE) utils.printcolor("Starting...", utils.GREEN) package.backend.install_many(["sudo", "wget"]) ssl_backend = ssl.get_backend(config) if ssl_backend: ssl_backend.create() scripts.install("amavis", config) scripts.install("modoboa", config) scripts.install("automx", config) scripts.install("uwsgi", config) scripts.install("nginx", config) scripts.install("postfix", config) scripts.install("dovecot", config) utils.printcolor( "Congratulations! You can enjoy Modoboa at https://{} (admin:password)" .format(config.get("general", "hostname")), utils.GREEN)
def main(input_args): """Install process.""" parser = argparse.ArgumentParser() versions = (["latest"] + list(compatibility_matrix.COMPATIBILITY_MATRIX.keys())) parser.add_argument("--debug", action="store_true", default=False, help="Enable debug output") parser.add_argument("--force", action="store_true", default=False, help="Force installation") parser.add_argument("--configfile", default="installer.cfg", help="Configuration file to use") parser.add_argument("--version", default="latest", choices=versions, help="Modoboa version to install") parser.add_argument( "--stop-after-configfile-check", action="store_true", default=False, help="Check configuration, generate it if needed and exit") parser.add_argument( "--interactive", action="store_true", default=False, help="Generate configuration file with user interaction") parser.add_argument("--upgrade", action="store_true", default=False, help="Run the installer in upgrade mode") parser.add_argument( "--beta", action="store_true", default=False, help="Install latest beta release of Modoboa instead of the stable one" ) parser.add_argument("domain", type=str, help="The main domain of your future mail server") args = parser.parse_args(input_args) if args.debug: utils.ENV["debug"] = True utils.printcolor("Welcome to Modoboa installer!\n", utils.GREEN) utils.check_config_file(args.configfile, args.interactive, args.upgrade) if args.stop_after_configfile_check: return config = configparser.ConfigParser() with open(args.configfile) as fp: config.read_file(fp) if not config.has_section("general"): config.add_section("general") config.set("general", "domain", args.domain) config.set("dovecot", "domain", args.domain) config.set("modoboa", "version", args.version) config.set("modoboa", "install_beta", str(args.beta)) # Display disclaimerpython 3 linux distribution if not args.upgrade: installation_disclaimer(args, config) else: upgrade_disclaimer(config) # Show concerned components components = [] for section in config.sections(): if section in [ "general", "database", "mysql", "postgres", "certificate", "letsencrypt" ]: continue if (config.has_option(section, "enabled") and not config.getboolean(section, "enabled")): continue components.append(section) utils.printcolor(" ".join(components), utils.YELLOW) if not args.force: answer = utils.user_input("Do you confirm? (Y/n) ") if answer.lower().startswith("n"): return config.set("general", "force", str(args.force)) utils.printcolor( "The process can be long, feel free to take a coffee " "and come back later ;)", utils.BLUE) utils.printcolor("Starting...", utils.GREEN) package.backend.prepare_system() package.backend.install_many(["sudo", "wget"]) ssl_backend = ssl.get_backend(config) if ssl_backend and not args.upgrade: ssl_backend.generate_cert() scripts.install("amavis", config, args.upgrade) scripts.install("modoboa", config, args.upgrade) scripts.install("automx", config, args.upgrade) scripts.install("radicale", config, args.upgrade) scripts.install("uwsgi", config, args.upgrade) scripts.install("nginx", config, args.upgrade) scripts.install("opendkim", config, args.upgrade) scripts.install("postfix", config, args.upgrade) scripts.install("dovecot", config, args.upgrade) system.restart_service("cron") package.backend.restore_system() utils.printcolor( "Congratulations! You can enjoy Modoboa at https://{} (admin:password)" .format(config.get("general", "hostname")), utils.GREEN)