def run(force_setup=False): if sys.version_info[0] == 2: CLI.colored_print("╔═══════════════════════════════════════════════════════════════╗", CLI.COLOR_ERROR) CLI.colored_print("║ DEPRECATION: Python 2.7 has reached the end of its life on ║", CLI.COLOR_ERROR) CLI.colored_print("║ January 1st, 2020. Please upgrade your Python as Python 2.7 ║", CLI.COLOR_ERROR) CLI.colored_print("║ is not maintained anymore. ║", CLI.COLOR_ERROR) CLI.colored_print("║ A future version of KoBoInstall will drop support for it. ║", CLI.COLOR_ERROR) CLI.colored_print("╚═══════════════════════════════════════════════════════════════╝", CLI.COLOR_ERROR) if not platform.system() in ["Linux", "Darwin"]: CLI.colored_print("Not compatible with this OS", CLI.COLOR_ERROR) else: config = Config() current_config = config.get_config() if config.first_time: force_setup = True if force_setup: current_config = config.build() Setup.clone_kobodocker(config) Template.render(config) config.init_letsencrypt() Setup.update_hosts(current_config) else: if config.auto_detect_network(): Template.render(config) Setup.update_hosts(current_config) Command.start()
def post_update(cls, cron): config = Config() # When `cron` is True, we want to bypass question and just recreate # YML and environment files from new templates if cron is True: current_dict = config.get_template() current_dict.update(config.get_dict()) config.set_config(current_dict) Template.render(config, force=True) sys.exit(0) message = ('After an update, it is strongly recommended to run\n' '`python3 run.py --setup` to regenerate environment files.') CLI.framed_print(message, color=CLI.COLOR_INFO) response = CLI.yes_no_question('Do you want to proceed?') if response is True: current_dict = config.build() Template.render(config) config.init_letsencrypt() Setup.update_hosts(current_dict) question = 'Do you want to (re)start containers?' response = CLI.yes_no_question(question) if response is True: Command.start()
def run(force_setup=False): if not platform.system() in ['Linux', 'Darwin']: CLI.colored_print('Not compatible with this OS', CLI.COLOR_ERROR) else: config = Config() dict_ = config.get_dict() if config.first_time: force_setup = True if force_setup: dict_ = config.build() Template.render(config) support = Support() support.copy_support_scripts() # # config.init_letsencrypt() # # Setup.update_hosts(dict_) else: print("Running smoothly") # if config.auto_detect_network(): # Template.render(config) # Setup.update_hosts(dict_) Command.start()
def run(force_setup=False): if sys.version_info[0] == 2: message = ( 'DEPRECATION: Python 2.7 has reached the end of its life on ' 'January 1st, 2020. Please upgrade your Python as Python 2.7 is ' 'not maintained anymore.\n\n' 'A future version of KoBoInstall will drop support for it.') CLI.framed_print(message) if not platform.system() in ['Linux', 'Darwin']: CLI.colored_print('Not compatible with this OS', CLI.COLOR_ERROR) else: config = Config() dict_ = config.get_dict() if config.first_time: force_setup = True if force_setup: dict_ = config.build() Setup.clone_kobodocker(config) Template.render(config) config.init_letsencrypt() Setup.update_hosts(dict_) else: if config.auto_detect_network(): Template.render(config) Setup.update_hosts(dict_) Command.start()
def test_toggle_frontend(): config_object = read_config() Command.start(frontend_only=True) mock_docker = MockDocker() expected_containers = MockDocker.FRONTEND_CONTAINERS + \ MockDocker.LETSENCRYPT assert sorted(mock_docker.ps()) == sorted(expected_containers) Command.stop() assert len(mock_docker.ps()) == 0 del mock_docker
def test_toggle_no_letsencrypt(): config_object = read_config() config_object._Config__config['use_letsencrypt'] = Config.FALSE Command.start() mock_docker = MockDocker() expected_containers = MockDocker.FRONTEND_CONTAINERS + \ MockDocker.PRIMARY_BACKEND_CONTAINERS assert sorted(mock_docker.ps()) == sorted(expected_containers) Command.stop() assert len(mock_docker.ps()) == 0 del mock_docker
def test_toggle_trivial(): config_object = read_config() Command.start() mock_docker = MockDocker() expected_containers = MockDocker.FRONTEND_CONTAINERS + \ MockDocker.PRIMARY_BACKEND_CONTAINERS + \ MockDocker.LETSENCRYPT assert sorted(mock_docker.ps()) == sorted(expected_containers) Command.stop() assert len(mock_docker.ps()) == 0 del mock_docker
def test_toggle_primary_backend(): config_object = read_config() config_object._Config__config['backend_server_role'] = 'primary' config_object._Config__config['server_role'] = 'backend' config_object._Config__config['multi'] = Config.TRUE Command.start() mock_docker = MockDocker() expected_containers = MockDocker.PRIMARY_BACKEND_CONTAINERS assert sorted(mock_docker.ps()) == sorted(expected_containers) Command.stop() assert len(mock_docker.ps()) == 0 del mock_docker
def test_toggle_secondary_backend(): config_object = read_config() config_object._Config__dict['backend_server_role'] = 'secondary' config_object._Config__dict['server_role'] = 'backend' config_object._Config__dict['multi'] = True mock_docker = MockDocker() Command.start() expected_containers = MockDocker.SECONDARY_BACKEND_CONTAINERS assert sorted(mock_docker.ps()) == sorted(expected_containers) Command.stop() assert len(mock_docker.ps()) == 0 del mock_docker
def run(force_setup=False): if not platform.system() in ["Linux", "Darwin"]: CLI.colored_print("Not compatible with this OS", CLI.COLOR_ERROR) else: config = Config() current_config = config.get_config() if not current_config: force_setup = True if force_setup: current_config = config.build() Setup.run(current_config) Template.render(config) Setup.update_hosts(current_config) else: if config.auto_detect_network(): Template.render(config) Setup.update_hosts(current_config) Command.start()
def run(force_setup=False): if not platform.system() in ['Linux', 'Darwin']: CLI.colored_print('Not compatible with this OS', CLI.COLOR_ERROR) else: config = Config() dict_ = config.get_dict() if config.first_time: force_setup = True if force_setup: dict_ = config.build() Setup.clone_kobodocker(config) Template.render(config) Setup.update_hosts(dict_) else: if config.auto_detect_network(): Template.render(config) Setup.update_hosts(dict_) config.validate_passwords() Command.start(force_setup=force_setup)
def post_update(cls, cron): config_object = Config() # When `cron` is True, we want to bypass question and just recreate # YML and environment files from new templates if cron is True: current_config = config_object.get_config_template() current_config.update(config_object.get_config()) config_object.set_config(current_config) Template.render(config_object, force=True) sys.exit(0) CLI.colored_print("╔═════════════════════════════════════════════════════╗", CLI.COLOR_WARNING) CLI.colored_print("║ After an update, it's strongly recommended to run ║", CLI.COLOR_WARNING) CLI.colored_print("║ `./run.py --setup` to regenerate environment files. ║", CLI.COLOR_WARNING) CLI.colored_print("╚═════════════════════════════════════════════════════╝", CLI.COLOR_WARNING) CLI.colored_print("Do you want to proceed?", CLI.COLOR_SUCCESS) CLI.colored_print("\t1) Yes") CLI.colored_print("\t2) No") response = CLI.get_response([Config.TRUE, Config.FALSE], Config.TRUE) if response == Config.TRUE: current_config = config_object.build() Template.render(config_object) config_object.init_letsencrypt() Setup.update_hosts(current_config) CLI.colored_print("Do you want to (re)start containers?", CLI.COLOR_SUCCESS) CLI.colored_print("\t1) Yes") CLI.colored_print("\t2) No") response = CLI.get_response([Config.TRUE, Config.FALSE], Config.TRUE) if response == Config.TRUE: Command.start()
def test_toggle_maintenance(): config_object = read_config() mock_docker = MockDocker() Command.start() expected_containers = MockDocker.FRONTEND_CONTAINERS + \ MockDocker.PRIMARY_BACKEND_CONTAINERS + \ MockDocker.LETSENCRYPT assert sorted(mock_docker.ps()) == sorted(expected_containers) config_object._Config__config['maintenance_enabled'] = True Command.start() maintenance_containers = MockDocker.PRIMARY_BACKEND_CONTAINERS + \ MockDocker.MAINTENANCE_CONTAINERS + \ MockDocker.LETSENCRYPT assert sorted(mock_docker.ps()) == sorted(maintenance_containers) config_object._Config__config['maintenance_enabled'] = False Command.start() assert sorted(mock_docker.ps()) == sorted(expected_containers) Command.stop() assert len(mock_docker.ps()) == 0 del mock_docker