atomicshop 2.15.11__py3-none-any.whl → 3.10.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atomicshop/__init__.py +1 -1
- atomicshop/{addons/mains → a_mains}/FACT/update_extract.py +3 -2
- atomicshop/a_mains/dns_gateway_setting.py +11 -0
- atomicshop/a_mains/get_local_tcp_ports.py +85 -0
- atomicshop/a_mains/github_wrapper.py +11 -0
- atomicshop/a_mains/install_ca_certificate.py +172 -0
- atomicshop/a_mains/process_from_port.py +119 -0
- atomicshop/a_mains/set_default_dns_gateway.py +90 -0
- atomicshop/a_mains/update_config_toml.py +38 -0
- atomicshop/basics/ansi_escape_codes.py +3 -1
- atomicshop/basics/argparse_template.py +2 -0
- atomicshop/basics/booleans.py +27 -30
- atomicshop/basics/bytes_arrays.py +43 -0
- atomicshop/basics/classes.py +149 -1
- atomicshop/basics/enums.py +2 -2
- atomicshop/basics/exceptions.py +5 -1
- atomicshop/basics/list_of_classes.py +29 -0
- atomicshop/basics/multiprocesses.py +374 -50
- atomicshop/basics/strings.py +72 -3
- atomicshop/basics/threads.py +14 -0
- atomicshop/basics/tracebacks.py +13 -3
- atomicshop/certificates.py +153 -52
- atomicshop/config_init.py +11 -6
- atomicshop/console_user_response.py +7 -14
- atomicshop/consoles.py +9 -0
- atomicshop/datetimes.py +1 -1
- atomicshop/diff_check.py +3 -3
- atomicshop/dns.py +128 -3
- atomicshop/etws/_pywintrace_fix.py +17 -0
- atomicshop/etws/trace.py +40 -42
- atomicshop/etws/traces/trace_dns.py +56 -44
- atomicshop/etws/traces/trace_tcp.py +130 -0
- atomicshop/file_io/csvs.py +27 -5
- atomicshop/file_io/docxs.py +34 -17
- atomicshop/file_io/file_io.py +31 -17
- atomicshop/file_io/jsons.py +49 -0
- atomicshop/file_io/tomls.py +139 -0
- atomicshop/filesystem.py +616 -291
- atomicshop/get_process_list.py +3 -3
- atomicshop/http_parse.py +149 -93
- atomicshop/ip_addresses.py +6 -1
- atomicshop/mitm/centered_settings.py +132 -0
- atomicshop/mitm/config_static.py +207 -0
- atomicshop/mitm/config_toml_editor.py +55 -0
- atomicshop/mitm/connection_thread_worker.py +875 -357
- atomicshop/mitm/engines/__parent/parser___parent.py +4 -17
- atomicshop/mitm/engines/__parent/recorder___parent.py +108 -51
- atomicshop/mitm/engines/__parent/requester___parent.py +116 -0
- atomicshop/mitm/engines/__parent/responder___parent.py +75 -114
- atomicshop/mitm/engines/__reference_general/parser___reference_general.py +10 -7
- atomicshop/mitm/engines/__reference_general/recorder___reference_general.py +5 -5
- atomicshop/mitm/engines/__reference_general/requester___reference_general.py +47 -0
- atomicshop/mitm/engines/__reference_general/responder___reference_general.py +95 -13
- atomicshop/mitm/engines/create_module_template.py +58 -14
- atomicshop/mitm/import_config.py +359 -139
- atomicshop/mitm/initialize_engines.py +160 -80
- atomicshop/mitm/message.py +64 -23
- atomicshop/mitm/mitm_main.py +892 -0
- atomicshop/mitm/recs_files.py +183 -0
- atomicshop/mitm/shared_functions.py +4 -10
- atomicshop/mitm/ssh_tester.py +82 -0
- atomicshop/mitm/statistic_analyzer.py +136 -40
- atomicshop/mitm/statistic_analyzer_helper/moving_average_helper.py +265 -83
- atomicshop/monitor/checks/dns.py +1 -1
- atomicshop/networks.py +671 -0
- atomicshop/on_exit.py +39 -9
- atomicshop/package_mains_processor.py +84 -0
- atomicshop/permissions/permissions.py +22 -0
- atomicshop/permissions/ubuntu_permissions.py +239 -0
- atomicshop/permissions/win_permissions.py +33 -0
- atomicshop/print_api.py +24 -42
- atomicshop/process.py +24 -6
- atomicshop/process_poller/process_pool.py +0 -1
- atomicshop/process_poller/simple_process_pool.py +204 -5
- atomicshop/python_file_patcher.py +1 -1
- atomicshop/python_functions.py +27 -75
- atomicshop/speech_recognize.py +8 -0
- atomicshop/ssh_remote.py +158 -172
- atomicshop/system_resource_monitor.py +61 -47
- atomicshop/system_resources.py +8 -8
- atomicshop/tempfiles.py +1 -2
- atomicshop/urls.py +6 -0
- atomicshop/venvs.py +28 -0
- atomicshop/versioning.py +27 -0
- atomicshop/web.py +98 -27
- atomicshop/web_apis/google_custom_search.py +44 -0
- atomicshop/web_apis/google_llm.py +188 -0
- atomicshop/websocket_parse.py +450 -0
- atomicshop/wrappers/certauthw/certauth.py +1 -0
- atomicshop/wrappers/cryptographyw.py +29 -8
- atomicshop/wrappers/ctyping/etw_winapi/const.py +97 -47
- atomicshop/wrappers/ctyping/etw_winapi/etw_functions.py +178 -49
- atomicshop/wrappers/ctyping/file_details_winapi.py +67 -0
- atomicshop/wrappers/ctyping/msi_windows_installer/cabs.py +2 -1
- atomicshop/wrappers/ctyping/msi_windows_installer/extract_msi_main.py +2 -2
- atomicshop/wrappers/ctyping/setup_device.py +466 -0
- atomicshop/wrappers/ctyping/win_console.py +39 -0
- atomicshop/wrappers/dockerw/dockerw.py +113 -2
- atomicshop/wrappers/elasticsearchw/config_basic.py +0 -12
- atomicshop/wrappers/elasticsearchw/elastic_infra.py +75 -0
- atomicshop/wrappers/elasticsearchw/elasticsearchw.py +2 -20
- atomicshop/wrappers/factw/get_file_data.py +12 -5
- atomicshop/wrappers/factw/install/install_after_restart.py +89 -5
- atomicshop/wrappers/factw/install/pre_install_and_install_before_restart.py +20 -14
- atomicshop/wrappers/githubw.py +537 -54
- atomicshop/wrappers/loggingw/consts.py +1 -1
- atomicshop/wrappers/loggingw/filters.py +23 -0
- atomicshop/wrappers/loggingw/formatters.py +12 -0
- atomicshop/wrappers/loggingw/handlers.py +214 -107
- atomicshop/wrappers/loggingw/loggers.py +19 -0
- atomicshop/wrappers/loggingw/loggingw.py +860 -22
- atomicshop/wrappers/loggingw/reading.py +134 -112
- atomicshop/wrappers/mongodbw/mongo_infra.py +31 -0
- atomicshop/wrappers/mongodbw/mongodbw.py +1324 -36
- atomicshop/wrappers/netshw.py +271 -0
- atomicshop/wrappers/playwrightw/engine.py +34 -19
- atomicshop/wrappers/playwrightw/infra.py +5 -0
- atomicshop/wrappers/playwrightw/javascript.py +7 -3
- atomicshop/wrappers/playwrightw/keyboard.py +14 -0
- atomicshop/wrappers/playwrightw/scenarios.py +172 -5
- atomicshop/wrappers/playwrightw/waits.py +9 -7
- atomicshop/wrappers/powershell_networking.py +80 -0
- atomicshop/wrappers/psutilw/processes.py +37 -1
- atomicshop/wrappers/psutilw/psutil_networks.py +85 -0
- atomicshop/wrappers/pyopensslw.py +9 -2
- atomicshop/wrappers/pywin32w/cert_store.py +116 -0
- atomicshop/wrappers/pywin32w/win_event_log/fetch.py +174 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_create.py +3 -105
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_terminate.py +3 -57
- atomicshop/wrappers/pywin32w/wmis/msft_netipaddress.py +113 -0
- atomicshop/wrappers/pywin32w/wmis/win32_networkadapterconfiguration.py +259 -0
- atomicshop/wrappers/pywin32w/wmis/win32networkadapter.py +112 -0
- atomicshop/wrappers/pywin32w/wmis/wmi_helpers.py +236 -0
- atomicshop/wrappers/socketw/accepter.py +21 -7
- atomicshop/wrappers/socketw/certificator.py +216 -150
- atomicshop/wrappers/socketw/creator.py +190 -50
- atomicshop/wrappers/socketw/dns_server.py +491 -182
- atomicshop/wrappers/socketw/exception_wrapper.py +45 -52
- atomicshop/wrappers/socketw/process_getter.py +86 -0
- atomicshop/wrappers/socketw/receiver.py +144 -102
- atomicshop/wrappers/socketw/sender.py +65 -35
- atomicshop/wrappers/socketw/sni.py +334 -165
- atomicshop/wrappers/socketw/socket_base.py +134 -0
- atomicshop/wrappers/socketw/socket_client.py +137 -95
- atomicshop/wrappers/socketw/socket_server_tester.py +11 -7
- atomicshop/wrappers/socketw/socket_wrapper.py +717 -116
- atomicshop/wrappers/socketw/ssl_base.py +15 -14
- atomicshop/wrappers/socketw/statistics_csv.py +148 -17
- atomicshop/wrappers/sysmonw.py +1 -1
- atomicshop/wrappers/ubuntu_terminal.py +65 -26
- atomicshop/wrappers/win_auditw.py +189 -0
- atomicshop/wrappers/winregw/__init__.py +0 -0
- atomicshop/wrappers/winregw/winreg_installed_software.py +58 -0
- atomicshop/wrappers/winregw/winreg_network.py +232 -0
- {atomicshop-2.15.11.dist-info → atomicshop-3.10.5.dist-info}/METADATA +31 -51
- atomicshop-3.10.5.dist-info/RECORD +306 -0
- {atomicshop-2.15.11.dist-info → atomicshop-3.10.5.dist-info}/WHEEL +1 -1
- atomicshop/_basics_temp.py +0 -101
- atomicshop/a_installs/win/fibratus.py +0 -9
- atomicshop/a_installs/win/mongodb.py +0 -9
- atomicshop/a_installs/win/pycharm.py +0 -9
- atomicshop/addons/a_setup_scripts/install_psycopg2_ubuntu.sh +0 -3
- atomicshop/addons/a_setup_scripts/install_pywintrace_0.3.cmd +0 -2
- atomicshop/addons/mains/__pycache__/install_fibratus_windows.cpython-312.pyc +0 -0
- atomicshop/addons/mains/__pycache__/msi_unpacker.cpython-312.pyc +0 -0
- atomicshop/addons/mains/install_docker_rootless_ubuntu.py +0 -11
- atomicshop/addons/mains/install_docker_ubuntu_main_sudo.py +0 -11
- atomicshop/addons/mains/install_elastic_search_and_kibana_ubuntu.py +0 -10
- atomicshop/addons/mains/install_wsl_ubuntu_lts_admin.py +0 -9
- atomicshop/addons/package_setup/CreateWheel.cmd +0 -7
- atomicshop/addons/package_setup/Setup in Edit mode.cmd +0 -6
- atomicshop/addons/package_setup/Setup.cmd +0 -7
- atomicshop/archiver/_search_in_zip.py +0 -189
- atomicshop/archiver/archiver.py +0 -34
- atomicshop/archiver/search_in_archive.py +0 -250
- atomicshop/archiver/sevenz_app_w.py +0 -86
- atomicshop/archiver/sevenzs.py +0 -44
- atomicshop/archiver/zips.py +0 -293
- atomicshop/file_types.py +0 -24
- atomicshop/mitm/config_editor.py +0 -37
- atomicshop/mitm/engines/create_module_template_example.py +0 -13
- atomicshop/mitm/initialize_mitm_server.py +0 -268
- atomicshop/pbtkmultifile_argparse.py +0 -88
- atomicshop/permissions.py +0 -151
- atomicshop/script_as_string_processor.py +0 -38
- atomicshop/ssh_scripts/process_from_ipv4.py +0 -37
- atomicshop/ssh_scripts/process_from_port.py +0 -27
- atomicshop/wrappers/_process_wrapper_curl.py +0 -27
- atomicshop/wrappers/_process_wrapper_tar.py +0 -21
- atomicshop/wrappers/dockerw/install_docker.py +0 -209
- atomicshop/wrappers/elasticsearchw/infrastructure.py +0 -265
- atomicshop/wrappers/elasticsearchw/install_elastic.py +0 -232
- atomicshop/wrappers/ffmpegw.py +0 -125
- atomicshop/wrappers/fibratusw/install.py +0 -81
- atomicshop/wrappers/mongodbw/infrastructure.py +0 -53
- atomicshop/wrappers/mongodbw/install_mongodb.py +0 -190
- atomicshop/wrappers/msiw.py +0 -149
- atomicshop/wrappers/nodejsw/install_nodejs.py +0 -139
- atomicshop/wrappers/process_wrapper_pbtk.py +0 -16
- atomicshop/wrappers/psutilw/networks.py +0 -45
- atomicshop/wrappers/pycharmw.py +0 -81
- atomicshop/wrappers/socketw/base.py +0 -59
- atomicshop/wrappers/socketw/get_process.py +0 -107
- atomicshop/wrappers/wslw.py +0 -191
- atomicshop-2.15.11.dist-info/RECORD +0 -302
- /atomicshop/{addons/mains → a_mains}/FACT/factw_fact_extractor_docker_image_main_sudo.py +0 -0
- /atomicshop/{addons → a_mains/addons}/PlayWrightCodegen.cmd +0 -0
- /atomicshop/{addons → a_mains/addons}/ScriptExecution.cmd +0 -0
- /atomicshop/{addons → a_mains/addons}/inits/init_to_import_all_modules.py +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/ReadMe.txt +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/compile.cmd +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.dll +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.exp +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.lib +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/process_list.cpp +0 -0
- /atomicshop/{archiver → permissions}/__init__.py +0 -0
- /atomicshop/{wrappers/fibratusw → web_apis}/__init__.py +0 -0
- /atomicshop/wrappers/{nodejsw → pywin32w/wmis}/__init__.py +0 -0
- /atomicshop/wrappers/pywin32w/{wmi_win32process.py → wmis/win32process.py} +0 -0
- {atomicshop-2.15.11.dist-info → atomicshop-3.10.5.dist-info/licenses}/LICENSE.txt +0 -0
- {atomicshop-2.15.11.dist-info → atomicshop-3.10.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import time
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
from ...print_api import print_api
|
|
6
|
+
from ... import filesystem
|
|
7
|
+
from .. import ubuntu_terminal
|
|
8
|
+
from . import config_basic
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def is_elastic_service_running():
|
|
12
|
+
return ubuntu_terminal.is_service_running(config_basic.UBUNTU_ELASTIC_SERVICE_NAME, return_false_on_error=False)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def enable_elastic_service():
|
|
16
|
+
ubuntu_terminal.enable_service(config_basic.UBUNTU_ELASTIC_SERVICE_NAME, sudo=True)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def start_elastic_service():
|
|
20
|
+
ubuntu_terminal.start_service(config_basic.UBUNTU_ELASTIC_SERVICE_NAME, sudo=True)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def is_kibana_service_running():
|
|
24
|
+
return ubuntu_terminal.is_service_running(config_basic.UBUNTU_KIBANA_SERVICE_NAME, return_false_on_error=False)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def enable_kibana_service():
|
|
28
|
+
ubuntu_terminal.enable_service(config_basic.UBUNTU_KIBANA_SERVICE_NAME, sudo=True)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def start_kibana_service():
|
|
32
|
+
ubuntu_terminal.start_service(config_basic.UBUNTU_KIBANA_SERVICE_NAME, sudo=True)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def is_server_available(
|
|
36
|
+
max_attempts: int = 5,
|
|
37
|
+
wait_between_attempts_seconds: float = 10,
|
|
38
|
+
elastic_url: str = None,
|
|
39
|
+
print_kwargs: dict = None
|
|
40
|
+
):
|
|
41
|
+
"""
|
|
42
|
+
The function checks if Elasticsearch server is up and running by sending GET request to the Elasticsearch server.
|
|
43
|
+
:param max_attempts: int, the maximum number of attempts to check if Elasticsearch is running.
|
|
44
|
+
:param wait_between_attempts_seconds: float, the time to wait between attempts.
|
|
45
|
+
:param elastic_url: str, the URL of the Elasticsearch server. If None, the default URL will be used.
|
|
46
|
+
:param print_kwargs: dict, the keyword arguments for the print_api function.
|
|
47
|
+
:return:
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
if not elastic_url:
|
|
51
|
+
elastic_url = config_basic.DEFAULT_ELASTIC_URL
|
|
52
|
+
|
|
53
|
+
if not print_kwargs:
|
|
54
|
+
print_kwargs = dict()
|
|
55
|
+
|
|
56
|
+
for attempt in range(1, max_attempts + 1):
|
|
57
|
+
print_api(f"Checking if Elasticsearch is running (Attempt {attempt}/{max_attempts})...", **print_kwargs)
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
response = requests.get(elastic_url)
|
|
61
|
+
status_code = response.status_code
|
|
62
|
+
|
|
63
|
+
if status_code == 200:
|
|
64
|
+
print_api("Elasticsearch is up and running.", color='green', **print_kwargs)
|
|
65
|
+
return True
|
|
66
|
+
else:
|
|
67
|
+
print_api(f"Elasticsearch is not running. Status code: {status_code}", color='yellow', **print_kwargs)
|
|
68
|
+
except requests.exceptions.RequestException as e:
|
|
69
|
+
print_api(f"Failed to connect to Elasticsearch: {e}", color='yellow', **print_kwargs)
|
|
70
|
+
|
|
71
|
+
print_api("Waiting for Elasticsearch to start...", **print_kwargs)
|
|
72
|
+
time.sleep(wait_between_attempts_seconds)
|
|
73
|
+
|
|
74
|
+
print_api("Elasticsearch did not start within the expected time.", color='red', **print_kwargs)
|
|
75
|
+
return False
|
|
@@ -6,10 +6,8 @@ from typing import Union
|
|
|
6
6
|
from . import config_basic
|
|
7
7
|
from ...basics import dicts
|
|
8
8
|
|
|
9
|
-
ELASTIC_WRAPPER = None
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
def get_elastic_wrapper(url: str = None, overwrite: bool = False):
|
|
10
|
+
def get_elastic_wrapper(url: str = config_basic.DEFAULT_ELASTIC_URL, overwrite: bool = False):
|
|
13
11
|
"""
|
|
14
12
|
The function initializes the Elasticsearch wrapper.
|
|
15
13
|
|
|
@@ -19,25 +17,9 @@ def get_elastic_wrapper(url: str = None, overwrite: bool = False):
|
|
|
19
17
|
|
|
20
18
|
Usage:
|
|
21
19
|
elastic_wrapper = get_elastic_wrapper()
|
|
22
|
-
or after you initialize it once, you can use it like:
|
|
23
|
-
atomicshop.wrappers.elasticsearchw.elasticsearchw.ELASTIC_WRAPPER
|
|
24
20
|
"""
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
if url is None:
|
|
28
|
-
url = config_basic.DEFAULT_ELASTIC_URL
|
|
29
|
-
|
|
30
|
-
# Get the global variable.
|
|
31
|
-
global ELASTIC_WRAPPER
|
|
32
|
-
# If the wrapper is not initialized, initialize it.
|
|
33
|
-
if ELASTIC_WRAPPER is None:
|
|
34
|
-
ELASTIC_WRAPPER = Elasticsearch([url])
|
|
35
|
-
# If the wrapper is already initialized, check if it should be overwritten.
|
|
36
|
-
else:
|
|
37
|
-
if overwrite:
|
|
38
|
-
ELASTIC_WRAPPER = Elasticsearch([url])
|
|
39
|
-
|
|
40
|
-
return ELASTIC_WRAPPER
|
|
22
|
+
return Elasticsearch([url])
|
|
41
23
|
|
|
42
24
|
|
|
43
25
|
def test_connection(elastic_wrapper: Elasticsearch = None):
|
|
@@ -33,11 +33,18 @@ def get_file_data(directory_path: str, firmwares: list = None):
|
|
|
33
33
|
"""
|
|
34
34
|
|
|
35
35
|
if not firmwares:
|
|
36
|
-
firmwares: list = filesystem.
|
|
36
|
+
firmwares: list = filesystem.get_paths_from_directory(
|
|
37
|
+
directory_path, get_file=True, recursive=False, add_file_binary=True, add_file_hash=True)
|
|
37
38
|
|
|
38
39
|
# Add UIDs to the list.
|
|
40
|
+
final_firmwares: list = []
|
|
39
41
|
for firmware in firmwares:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
uid = get_uid_from_file(file_binary=firmware.binary, sha256_hash=firmware.hash)
|
|
43
|
+
final_firmwares.append({
|
|
44
|
+
'path': firmware.path,
|
|
45
|
+
'hash': firmware.hash,
|
|
46
|
+
'binary': firmware.binary,
|
|
47
|
+
'uid': uid
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return final_firmwares
|
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
from typing import Union, Literal
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
|
|
4
|
-
from .... import process,
|
|
4
|
+
from .... import process, print_api
|
|
5
5
|
from .. import config_install
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
PLUGIN_LIST: list = [
|
|
9
|
+
'qemu_exec',
|
|
10
|
+
'binwalk',
|
|
11
|
+
'users_and_passwords',
|
|
12
|
+
'kernel_config',
|
|
13
|
+
'cve_lookup',
|
|
14
|
+
'crypto_hints',
|
|
15
|
+
'input_vectors',
|
|
16
|
+
'cwe_checker',
|
|
17
|
+
'linter',
|
|
18
|
+
'ip_and_uri_finder',
|
|
19
|
+
'device_tree',
|
|
20
|
+
'file_system_metadata',
|
|
21
|
+
'ipc',
|
|
22
|
+
'software_components',
|
|
23
|
+
'architecture_detection',
|
|
24
|
+
'known_vulnerabilities'
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
INSTALLING_STRINGS: list = ['Installing', 'plugin']
|
|
29
|
+
FINISHED_INSTALLING_STRINGS: list = ['Finished installing', 'plugin']
|
|
30
|
+
LOG_FINISHED_STRING: str = 'installation complete'
|
|
31
|
+
|
|
32
|
+
|
|
8
33
|
def install_after_restart(
|
|
9
34
|
installation_directory: str,
|
|
10
|
-
install_type: Union[
|
|
11
|
-
|
|
35
|
+
install_type: Union[
|
|
36
|
+
None,
|
|
37
|
+
Literal['backend', 'frontend', 'db']] = None,
|
|
38
|
+
log_level: Union[
|
|
39
|
+
None,
|
|
40
|
+
Literal['DEBUG', 'INFO', 'WARNING', 'ERROR']] = None,
|
|
41
|
+
log_file: Union[
|
|
42
|
+
None,
|
|
43
|
+
str] = None,
|
|
44
|
+
analyze_log: bool = False
|
|
45
|
+
) -> int:
|
|
12
46
|
"""
|
|
13
47
|
This function will continue the installation the FACT_core after the restart of the computer.
|
|
14
48
|
|
|
@@ -20,7 +54,13 @@ def install_after_restart(
|
|
|
20
54
|
--backend: Distributed setup, Install the FACT_core backend.
|
|
21
55
|
--frontend: Distributed setup, Install the FACT_core frontend.
|
|
22
56
|
--db: Distributed setup, Install the FACT_core database.
|
|
23
|
-
:
|
|
57
|
+
:param log_level: string, the log level to use for the installation.
|
|
58
|
+
The same as using the '--log-level' parameter in the 'install.py' script.
|
|
59
|
+
The default is 'INFO' in the 'install.py' script.
|
|
60
|
+
:param log_file: string, the log file to use for the installation.
|
|
61
|
+
The same as using the '--log-file' parameter in the 'install.py' script.
|
|
62
|
+
:param analyze_log: bool, if True, the log file will be analyzed for plugin installation errors.
|
|
63
|
+
:return: int, 0 if the installation was successful, otherwise 1.
|
|
24
64
|
"""
|
|
25
65
|
|
|
26
66
|
install_command: str = 'python3 "' + str(Path(installation_directory, config_install.INSTALL_FILE_PATH)) + '"'
|
|
@@ -28,8 +68,52 @@ def install_after_restart(
|
|
|
28
68
|
if install_type:
|
|
29
69
|
install_command = install_command + ' --' + install_type
|
|
30
70
|
|
|
71
|
+
if log_level:
|
|
72
|
+
install_command = install_command + ' --log_level ' + log_level
|
|
73
|
+
|
|
74
|
+
if log_file:
|
|
75
|
+
install_command = install_command + ' --log_file "' + log_file + '"'
|
|
76
|
+
|
|
31
77
|
# Install the FACT_core repo.
|
|
32
78
|
process.execute_with_live_output(cmd=install_command, verbose=True)
|
|
79
|
+
|
|
80
|
+
# Analyze the log file for errors.
|
|
81
|
+
if analyze_log and (install_type == 'backend' or install_type is None):
|
|
82
|
+
if not log_file:
|
|
83
|
+
log_file = str(Path.cwd() / config_install.INSTALL_LOG_FILE_NAME)
|
|
84
|
+
|
|
85
|
+
return analyze_log_file(log_file=log_file)
|
|
86
|
+
|
|
33
87
|
# Remove the FACT_core installation log.
|
|
34
|
-
working_directory_path: str = filesystem.get_working_directory()
|
|
88
|
+
# working_directory_path: str = filesystem.get_working_directory()
|
|
35
89
|
# filesystem.remove_file(str(Path(working_directory_path, config_install.INSTALL_LOG_FILE_NAME)))
|
|
90
|
+
|
|
91
|
+
return 0
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def analyze_log_file(log_file: str):
|
|
95
|
+
"""
|
|
96
|
+
This function will analyze the log file for plugin installation errors.
|
|
97
|
+
:param log_file:
|
|
98
|
+
:return:
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
with open(log_file, 'r') as file:
|
|
102
|
+
log_content: str = file.read()
|
|
103
|
+
|
|
104
|
+
for plugin in PLUGIN_LIST:
|
|
105
|
+
if f'{FINISHED_INSTALLING_STRINGS[0]} {plugin} {FINISHED_INSTALLING_STRINGS[1]}' not in log_content:
|
|
106
|
+
message = (f'Error: [{plugin}] plugin missing in the log. Installation failed.\n'
|
|
107
|
+
f'Check the log file: {log_file}\n'
|
|
108
|
+
f'Exiting...')
|
|
109
|
+
print_api.print_api(message, color='red')
|
|
110
|
+
return 1
|
|
111
|
+
|
|
112
|
+
if LOG_FINISHED_STRING not in log_content:
|
|
113
|
+
message = (f'Error: Installation failed.\n'
|
|
114
|
+
f'Check the log file: {log_file}\n'
|
|
115
|
+
f'Exiting...')
|
|
116
|
+
print_api.print_api(message, color='red')
|
|
117
|
+
return 1
|
|
118
|
+
|
|
119
|
+
return 0
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import sys
|
|
2
1
|
import subprocess
|
|
3
2
|
from pathlib import Path
|
|
4
3
|
|
|
5
|
-
from
|
|
6
|
-
from
|
|
4
|
+
from dkarchiver.arch_wrappers import zips
|
|
5
|
+
from dkinst.installers.helpers import docker_installer
|
|
6
|
+
|
|
7
|
+
from .... import filesystem
|
|
8
|
+
from ....permissions import ubuntu_permissions
|
|
7
9
|
from ....print_api import print_api
|
|
8
10
|
from ... import githubw, pipw, ubuntu_terminal
|
|
9
|
-
from ...dockerw import install_docker
|
|
10
11
|
from .. import config_install
|
|
11
12
|
|
|
12
13
|
|
|
@@ -16,7 +17,7 @@ def install_before_restart(
|
|
|
16
17
|
fact_source_archive_path: str = None,
|
|
17
18
|
use_built_in_fact_installer: bool = True,
|
|
18
19
|
print_kwargs: dict = None
|
|
19
|
-
):
|
|
20
|
+
) -> int:
|
|
20
21
|
"""
|
|
21
22
|
This function will install the FACT_core before the restart of the computer.
|
|
22
23
|
:param installation_directory: string, the directory to install the FACT_core to.
|
|
@@ -34,15 +35,15 @@ def install_before_restart(
|
|
|
34
35
|
If False, only the regular prerequisites will be installed, while the user will need to install DOCKER
|
|
35
36
|
and Node.js separately.
|
|
36
37
|
:param print_kwargs: dict, the print kwargs for the print_api function.
|
|
37
|
-
:return:
|
|
38
|
+
:return: int, 0 if the installation was successful, 1 if there was an error.
|
|
38
39
|
"""
|
|
39
40
|
|
|
40
41
|
# if not permissions.is_admin():
|
|
41
42
|
# print_api("This script requires root privileges...", color='red')
|
|
42
|
-
#
|
|
43
|
+
# return 1
|
|
43
44
|
|
|
44
45
|
# # Install docker in rootless mode.
|
|
45
|
-
# with
|
|
46
|
+
# with ubuntu_permissions.temporary_regular_permissions():
|
|
46
47
|
# install_docker.install_docker_ubuntu(
|
|
47
48
|
# use_docker_installer=True, rootless=True, add_current_user_to_docker_group_bool=False)
|
|
48
49
|
|
|
@@ -59,13 +60,13 @@ def install_before_restart(
|
|
|
59
60
|
filesystem.remove_directory(installation_directory)
|
|
60
61
|
|
|
61
62
|
# Since you run the script with sudo, we need to change the permissions to the current user.
|
|
62
|
-
# with
|
|
63
|
+
# with ubuntu_permissions.temporary_regular_permissions():
|
|
63
64
|
# Create the FACT_core directory.
|
|
64
65
|
filesystem.create_directory(installation_directory)
|
|
65
66
|
|
|
66
67
|
if not fact_source_archive_path:
|
|
67
68
|
# Download the FACT_core repo.
|
|
68
|
-
if not filesystem.
|
|
69
|
+
if not filesystem.get_paths_from_directory(installation_directory, get_file=True):
|
|
69
70
|
git_wrapper = githubw.GitHubWrapper(repo_url=config_install.FACT_CORE_GITHUB_URL)
|
|
70
71
|
git_wrapper.build_links_from_repo_url()
|
|
71
72
|
git_wrapper.download_and_extract_branch(
|
|
@@ -78,7 +79,7 @@ def install_before_restart(
|
|
|
78
79
|
remove_first_directory=True, **(print_kwargs or {}))
|
|
79
80
|
|
|
80
81
|
# Set the executable permission on the pre-installation file.
|
|
81
|
-
|
|
82
|
+
ubuntu_permissions.set_executable(fact_core_pre_install_file_path)
|
|
82
83
|
|
|
83
84
|
if use_built_in_fact_installer:
|
|
84
85
|
# Run the shell script
|
|
@@ -86,9 +87,9 @@ def install_before_restart(
|
|
|
86
87
|
|
|
87
88
|
# Install docker. FACT installs the docker, but there can be a problem with permissions, so we need to add
|
|
88
89
|
# the user permissions to the docker group before restart.
|
|
89
|
-
if not
|
|
90
|
+
if not docker_installer.add_current_user_to_docker_group():
|
|
90
91
|
print_api("Docker is installed, but the current user was not added to the docker group.", color='red')
|
|
91
|
-
|
|
92
|
+
return 1
|
|
92
93
|
else:
|
|
93
94
|
message = ("You will need to install DOCKER and NODEJS separately.\n"
|
|
94
95
|
"This was done to enable Rootless docker install and install other version of NodeJS.")
|
|
@@ -107,8 +108,13 @@ def install_before_restart(
|
|
|
107
108
|
# use_docker_installer=True, rootless=True, add_current_user_to_docker_group_bool=False)
|
|
108
109
|
|
|
109
110
|
# Install docker in regular mode.
|
|
110
|
-
|
|
111
|
+
result: int = docker_installer.install_docker_ubuntu(
|
|
111
112
|
use_docker_installer=True, rootless=False, add_current_user_to_docker_group_bool=True)
|
|
113
|
+
if result != 0:
|
|
114
|
+
print_api("Docker installation failed. Please install Docker manually.", color='red')
|
|
115
|
+
return result
|
|
112
116
|
|
|
113
117
|
print_api("FACT_core installation before restart is finished.", color='green')
|
|
114
118
|
print_api("Please restart the computer to continue the installation.", color='red')
|
|
119
|
+
|
|
120
|
+
return 0
|