diff --git a/monkey/monkey_island/cc/main.py b/monkey/monkey_island/cc/main.py index 288baae67..5b3bfd794 100644 --- a/monkey/monkey_island/cc/main.py +++ b/monkey/monkey_island/cc/main.py @@ -26,6 +26,7 @@ from monkey_island.cc.resources.monkey_download import MonkeyDownload # noqa: E from monkey_island.cc.server_utils.bootloader_server import BootloaderHttpServer # noqa: E402 from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH # noqa: E402 from monkey_island.cc.server_utils.encryptor import initialize_encryptor # noqa: E402 +from monkey_island.cc.services.initialize import initialize_services # noqa: E402 from monkey_island.cc.services.reporting.exporter_init import populate_exporter_list # noqa: E402 from monkey_island.cc.services.utils.network_utils import local_ip_addresses # noqa: E402 from monkey_island.cc.setup import setup # noqa: E402 @@ -39,6 +40,7 @@ def main(should_setup_only=False, server_config_filename=DEFAULT_SERVER_CONFIG_P data_dir = env_singleton.env.get_config().data_dir_abs_path env_singleton.initialize_from_file(server_config_filename) initialize_encryptor(data_dir) + initialize_services(data_dir) mongo_url = os.environ.get("MONGO_URL", env_singleton.env.get_mongo_url()) bootloader_server_thread = Thread( diff --git a/monkey/monkey_island/cc/services/initialize.py b/monkey/monkey_island/cc/services/initialize.py new file mode 100644 index 000000000..45301946f --- /dev/null +++ b/monkey/monkey_island/cc/services/initialize.py @@ -0,0 +1,9 @@ +from monkey_island.cc.services.post_breach_files import PostBreachFilesService + + +def initialize_services(data_dir): + initialize_post_breach_file_service(data_dir) + + +def initialize_post_breach_file_service(data_dir): + PostBreachFilesService.DATA_DIR = data_dir diff --git a/monkey/monkey_island/cc/services/post_breach_files.py b/monkey/monkey_island/cc/services/post_breach_files.py index aa9065b56..1224f6759 100644 --- a/monkey/monkey_island/cc/services/post_breach_files.py +++ b/monkey/monkey_island/cc/services/post_breach_files.py @@ -5,8 +5,6 @@ import monkey_island.cc.services.config __author__ = "VakarisZ" -import monkey_island.cc.environment.environment_singleton as env_singleton - logger = logging.getLogger(__name__) # Where to find file names in config @@ -15,6 +13,8 @@ PBA_LINUX_FILENAME_PATH = ["monkey", "post_breach", "PBA_linux_filename"] class PostBreachFilesService: + DATA_DIR = None + @staticmethod def remove_PBA_files(): if monkey_island.cc.services.config.ConfigService.get_config(): @@ -31,7 +31,7 @@ class PostBreachFilesService: @staticmethod def _remove_file(file_name): - file_path = os.path.join(env_singleton.env.get_config().data_dir_abs_path, file_name) + file_path = os.path.join(PostBreachFilesService.DATA_DIR, file_name) try: if os.path.exists(file_path): os.remove(file_path)