island: Use config file in ~/.monkey_island if it exists

This commit is contained in:
Mike Salvatore 2021-06-09 14:48:59 -04:00
parent 9131f86215
commit 6aa76497ec
1 changed files with 8 additions and 4 deletions

View File

@ -4,7 +4,7 @@ from monkey_island.cc.arg_parser import IslandCmdArgs
from monkey_island.cc.environment import server_config_handler from monkey_island.cc.environment import server_config_handler
from monkey_island.cc.environment.utils import create_secure_directory from monkey_island.cc.environment.utils import create_secure_directory
from monkey_island.cc.server_utils import file_utils from monkey_island.cc.server_utils import file_utils
from monkey_island.cc.server_utils.consts import DEFAULT_DATA_DIR, DEFAULT_SERVER_CONFIG_PATH from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH
from monkey_island.cc.setup.island_config_options import IslandConfigOptions from monkey_island.cc.setup.island_config_options import IslandConfigOptions
@ -23,8 +23,12 @@ def _setup_config_by_cmd_arg(server_config_path) -> Tuple[IslandConfigOptions, s
def _setup_default_config() -> Tuple[IslandConfigOptions, str]: def _setup_default_config() -> Tuple[IslandConfigOptions, str]:
server_config_path = DEFAULT_SERVER_CONFIG_PATH default_config = server_config_handler.load_server_config_from_file(DEFAULT_SERVER_CONFIG_PATH)
create_secure_directory(DEFAULT_DATA_DIR, create_parent_dirs=False) default_data_dir = default_config.data_dir
server_config_handler.create_default_server_config_file()
create_secure_directory(default_data_dir, create_parent_dirs=False)
server_config_path = server_config_handler.create_default_server_config_file(default_data_dir)
config = server_config_handler.load_server_config_from_file(server_config_path) config = server_config_handler.load_server_config_from_file(server_config_path)
return config, server_config_path return config, server_config_path