atomicshop 3.3.20__py3-none-any.whl → 3.3.22__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.

Potentially problematic release.


This version of atomicshop might be problematic. Click here for more details.

atomicshop/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '3.3.20'
4
+ __version__ = '3.3.22'
atomicshop/web.py CHANGED
@@ -1,13 +1,10 @@
1
1
  import os
2
2
  import urllib.request
3
3
  import ssl
4
+ from typing import Any
4
5
  # noinspection PyPackageRequirements
5
6
  import certifi
6
7
 
7
- try:
8
- from importlib.metadata import version, PackageNotFoundError # Python 3.8+
9
- except ImportError: # Python <3.8
10
- from importlib_metadata import version, PackageNotFoundError # backport
11
8
 
12
9
  from .archiver import zips
13
10
  from .urls import url_parser
@@ -102,7 +99,7 @@ def get_page_content(
102
99
  playwright_pdf_format: str = 'A4',
103
100
  playwright_html_txt_convert_to_bytes: bool = True,
104
101
  print_kwargs: dict = None
105
- ) -> any:
102
+ ) -> Any:
106
103
  """
107
104
  Function returns the page content from the given URL.
108
105
 
@@ -187,19 +184,6 @@ def download(
187
184
  else:
188
185
  print_api.print_api(f'Downloaded bytes: {aggregated_bytes_int}', print_end=print_end, **kwargs)
189
186
 
190
- def has_pip_system_certs() -> bool:
191
- try:
192
- version("pip-system-certs") # distribution/project name on PyPI
193
- return True
194
- except PackageNotFoundError:
195
- return False
196
-
197
- if not has_pip_system_certs():
198
- print_api.print_api(
199
- 'Warning: "pip-system-certs" package is not installed. '
200
- 'If "certifi" package is installed, the system\'s CA store will not be used for SSL context. '
201
- 'Install "pip-system-certs" package if you want to use the system\'s CA store.', color='yellow', **kwargs)
202
-
203
187
  # Size of the buffer to read each time from url.
204
188
  buffer_size: int = 4096
205
189
 
@@ -238,7 +222,7 @@ def download(
238
222
  if not is_status_ok(status_code=file_to_download.status, **kwargs):
239
223
  return None
240
224
 
241
- file_size_bytes_int: int = None
225
+ file_size_bytes_int: int | None = None
242
226
  # Get file size. For some reason doesn't show for GitHub branch downloads.
243
227
  if file_to_download.headers['Content-Length']:
244
228
  file_size_bytes_int = int(file_to_download.headers['Content-Length'])
@@ -7,17 +7,5 @@ DEFAULT_KIBANA_PORT: str = '5601'
7
7
  DEFAULT_KIBANA_HOST: str = 'localhost'
8
8
  DEFAULT_KIBANA_URL: str = f"http://{DEFAULT_KIBANA_HOST}:{DEFAULT_KIBANA_PORT}"
9
9
 
10
- ELASTIC_SEARCH_CONFIG_DIRECTORY: str = "/etc/elasticsearch"
11
-
12
- ELASTIC_CONFIG_FILE: str = f"{ELASTIC_SEARCH_CONFIG_DIRECTORY}/elasticsearch.yml"
13
- XPACK_SECURITY_SETTING_NAME: str = "xpack.security.enabled"
14
-
15
- ELASTIC_JVM_OPTIONS_DIRECTORY: str = f"{ELASTIC_SEARCH_CONFIG_DIRECTORY}/jvm.options.d"
16
- ELASTIC_JVM_OPTIONS_4GB_CUSTOM_FILE: str = f"{ELASTIC_JVM_OPTIONS_DIRECTORY}/4gb_memory_heap.options"
17
- ELASTIC_JVM_OPTIONS_4GB_MEMORY_USAGE: list[str] = ['-Xms4g', '-Xmx4g']
18
-
19
- UBUNTU_DEPENDENCY_PACKAGES: list[str] = ['apt-transport-https', 'openjdk-11-jdk', 'wget']
20
- UBUNTU_ELASTIC_PACKAGE_NAME: str = 'elasticsearch'
21
10
  UBUNTU_ELASTIC_SERVICE_NAME: str = 'elasticsearch'
22
- UBUNTU_KIBANA_PACKAGE_NAME: str = 'kibana'
23
11
  UBUNTU_KIBANA_SERVICE_NAME: str = 'kibana'
@@ -32,174 +32,6 @@ def start_kibana_service():
32
32
  ubuntu_terminal.start_service(config_basic.UBUNTU_KIBANA_SERVICE_NAME, sudo=True)
33
33
 
34
34
 
35
- def start_elastic_and_check_service_availability(wait_time_seconds: float = 30, exit_on_error: bool = True):
36
- """
37
- Function starts the Elasticsearch service and checks its availability.
38
- :param wait_time_seconds: float, the time to wait after starting the service before checking
39
- the service availability.
40
- :param exit_on_error: bool, if True, the function will exit the program if the service is not available.
41
- :return:
42
- """
43
-
44
- # Start, enable and check the Elasticsearch service.
45
- ubuntu_terminal.start_enable_service_check_availability(
46
- service_name=config_basic.UBUNTU_ELASTIC_SERVICE_NAME,
47
- wait_time_seconds=wait_time_seconds,
48
- exit_on_error=exit_on_error
49
- )
50
-
51
- # Check if Elasticsearch is running.
52
- if not is_server_available():
53
- if exit_on_error:
54
- sys.exit(1)
55
-
56
-
57
- def start_kibana_and_check_service_availability(wait_time_seconds: float = 30, exit_on_error: bool = True):
58
- """
59
- Function starts the Kibana service and checks its availability.
60
- :param wait_time_seconds: float, the time to wait after starting the service before checking
61
- the service availability.
62
- :param exit_on_error: bool, if True, the function will exit the program if the service is not available.
63
- :return:
64
- """
65
-
66
- # Start, enable and check the Elasticsearch service.
67
- ubuntu_terminal.start_enable_service_check_availability(
68
- service_name=config_basic.UBUNTU_KIBANA_SERVICE_NAME,
69
- wait_time_seconds=wait_time_seconds,
70
- exit_on_error=exit_on_error
71
- )
72
-
73
-
74
- def is_elastic_config_file_exists(
75
- config_file_path: str = None,
76
- exit_on_error: bool = False,
77
- output_message: bool = False
78
- ) -> bool:
79
- """
80
- The function checks if the Elasticsearch configuration file exists.
81
-
82
- :param config_file_path: str, the path to the configuration file.
83
- :param exit_on_error: bool, if True, the function will exit the program if the file does not exist.
84
- :param output_message: bool, if True, the function will print a message if the file does not exist.
85
- :return:
86
- """
87
-
88
- if not config_file_path:
89
- config_file_path = config_basic.ELASTIC_CONFIG_FILE
90
-
91
- # if not ubuntu_terminal.is_sudo_file_exists(config_file_path):
92
- if not filesystem.is_file_exists(config_file_path):
93
- if output_message:
94
- message = f"Configuration file does not exist at {config_file_path}."
95
- print_api(message, color='red', error_type=True)
96
- if exit_on_error:
97
- sys.exit(1)
98
- return False
99
- else:
100
- return True
101
-
102
-
103
- def check_xpack_security_setting(config_file_path: str = None):
104
- """
105
- The function checks if the 'xpack.security.enabled' setting is set to 'false' in the Elasticsearch
106
- configuration file.
107
-
108
- :param config_file_path:
109
- :return:
110
- """
111
-
112
- if not config_file_path:
113
- config_file_path = config_basic.ELASTIC_CONFIG_FILE
114
-
115
- with open(config_file_path, 'r') as file:
116
- # Read the file contents
117
- contents = file.read()
118
- # Check if the specific setting exists
119
- if f"{config_basic.XPACK_SECURITY_SETTING_NAME}: false" in contents:
120
- return False
121
- elif f"{config_basic.XPACK_SECURITY_SETTING_NAME}: true" in contents:
122
- return True
123
- # If the setting doesn't exist, return None.
124
- else:
125
- return None
126
-
127
-
128
- def modify_xpack_security_setting(
129
- config_file_path: str = None,
130
- setting: bool = False,
131
- output_message: bool = True
132
- ):
133
- """
134
- The function modifies the 'xpack.security.enabled' setting in the Elasticsearch configuration file.
135
- :param config_file_path: str, the path to the configuration file.
136
- :param setting: bool, the setting to change to. Will be added, if doesn't exist.
137
- :param output_message: bool, if True, the function will print a message.
138
- :return:
139
- """
140
-
141
- if not config_file_path:
142
- config_file_path = config_basic.ELASTIC_CONFIG_FILE
143
-
144
- # The setting to set in the configuration file.
145
- xpack_setting_to_set: str = f'{config_basic.XPACK_SECURITY_SETTING_NAME}: {str(setting).lower()}'
146
-
147
- # Check if the setting exists in the configuration file and get its value.
148
- current_xpack_security_setting = check_xpack_security_setting(config_file_path)
149
-
150
- # If the setting doesn't exist, add it to the configuration file.
151
- if current_xpack_security_setting is None:
152
- with open(config_file_path, 'a') as file:
153
- file.write(f'{xpack_setting_to_set}\n')
154
- if output_message:
155
- print_api(f"Added [{xpack_setting_to_set}] to the configuration.")
156
- # If the setting exists and is different from the desired setting, change it.
157
- elif current_xpack_security_setting != setting:
158
- with open(config_file_path, 'r') as file:
159
- lines = file.readlines()
160
- with open(config_file_path, 'w') as file:
161
- for line in lines:
162
- if f"{config_basic.XPACK_SECURITY_SETTING_NAME}:" in line:
163
- file.write(f'{xpack_setting_to_set}\n')
164
- else:
165
- file.write(line)
166
- if output_message:
167
- print_api(f"Changed [{config_basic.XPACK_SECURITY_SETTING_NAME}] to [{setting}].")
168
- # If the setting is already set to the desired value, print a message.
169
- elif current_xpack_security_setting == setting:
170
- if output_message:
171
- print_api(f"The setting is already set to [{setting}].")
172
-
173
-
174
- def create_jvm_options_custom_file(file_path: str, options: list):
175
- """
176
- The function creates a custom JVM options file for Elasticsearch.
177
- You can use the default directory path as 'config_basic.ELASTIC_JVM_OPTIONS_DIRECTORY'.
178
- :param file_path: str, the path to the custom JVM options file.
179
- :param options: list, the list of JVM options.
180
- :return:
181
- """
182
-
183
- # Write the options to the file.
184
- with open(file_path, 'w') as file:
185
- for option in options:
186
- file.write(f"{option}\n")
187
-
188
-
189
- def create_jvm_options_custom_4gb_memory_heap_file(file_path: str = None):
190
- """
191
- The function creates a custom JVM options file with 4GB memory heap usage.
192
- The 4GB memory usage options are needed for the Elasticsearch to work properly and not to crash.
193
- :param file_path: str, the path to the custom JVM options file.
194
- :return:
195
- """
196
-
197
- if not file_path:
198
- file_path = config_basic.ELASTIC_JVM_OPTIONS_4GB_CUSTOM_FILE
199
-
200
- create_jvm_options_custom_file(file_path, config_basic.ELASTIC_JVM_OPTIONS_4GB_MEMORY_USAGE)
201
-
202
-
203
35
  def is_server_available(
204
36
  max_attempts: int = 5,
205
37
  wait_between_attempts_seconds: float = 10,
@@ -241,25 +73,3 @@ def is_server_available(
241
73
 
242
74
  print_api("Elasticsearch did not start within the expected time.", color='red', **print_kwargs)
243
75
  return False
244
-
245
-
246
- def is_4gb_memory_heap_options_applied_on_server() -> bool:
247
- """
248
- The function checks if the 4GB memory heap options are applied on the Elasticsearch server.
249
- :return: bool.
250
- """
251
-
252
- # Send a GET request
253
- response = requests.get(config_basic.DEFAULT_ELASTIC_URL_JVM_OPTIONS)
254
- response.raise_for_status() # Raise an exception for HTTP errors
255
-
256
- # Load JSON data from the response
257
- jvm_data = response.json()
258
-
259
- # Check if memory heap options are applied in 'input_arguments' key.
260
- for node in jvm_data['nodes'].values():
261
- # Get the JVM input arguments values.
262
- input_arguments = node['jvm']['input_arguments']
263
-
264
- # Check that the 4GB memory heap options are applied.
265
- return all(options in input_arguments for options in config_basic.ELASTIC_JVM_OPTIONS_4GB_MEMORY_USAGE)
@@ -392,12 +392,12 @@ class GitHubWrapper:
392
392
  def get_latest_release_url(
393
393
  self,
394
394
  asset_pattern: str,
395
- exclude_pattern: str = None,
395
+ exclude_string: str = None,
396
396
  **kwargs):
397
397
  """
398
398
  This function will return the latest release url.
399
399
  :param asset_pattern: str, the string pattern to search in the latest release. Wildcards can be used.
400
- :param exclude_pattern: str, the string to exclude from the search. No wildcards can be used.
400
+ :param exclude_string: str, the string to exclude from the search. No wildcards can be used.
401
401
  :param kwargs: dict, the print arguments for the 'print_api' function.
402
402
  :return: str, the latest release url.
403
403
  """
@@ -411,9 +411,9 @@ class GitHubWrapper:
411
411
  download_urls.append(single_dict['browser_download_url'])
412
412
 
413
413
  # Exclude urls against 'exclude_string'.
414
- if exclude_pattern:
414
+ if exclude_string:
415
415
  for download_url in download_urls:
416
- if exclude_pattern in download_url:
416
+ if exclude_string in download_url:
417
417
  download_urls.remove(download_url)
418
418
 
419
419
  # Find urls against 'asset_pattern'.
@@ -115,7 +115,7 @@ def update_system_packages():
115
115
  Function updates the system packages.
116
116
  :return:
117
117
  """
118
- subprocess.check_call(['sudo', 'apt-get', 'update'])
118
+ subprocess.check_call(['sudo', 'apt', 'update'])
119
119
 
120
120
 
121
121
  def upgrade_system_packages(apt_update: bool = True):
@@ -129,7 +129,7 @@ def upgrade_system_packages(apt_update: bool = True):
129
129
  if apt_update:
130
130
  update_system_packages()
131
131
 
132
- subprocess.check_call(['sudo', 'apt-get', 'upgrade', '-y'])
132
+ subprocess.check_call(['sudo', 'apt', 'upgrade', '-y'])
133
133
 
134
134
 
135
135
  def is_service_running(service_name: str, user_mode: bool = False, return_false_on_error: bool = False) -> bool:
@@ -216,26 +216,25 @@ def start_service(service_name: str, sudo: bool = False, user_mode: bool = False
216
216
  def start_enable_service_check_availability(
217
217
  service_name: str,
218
218
  wait_time_seconds: float = 30,
219
- exit_on_error: bool = True,
220
219
  start_service_bool: bool = True,
221
220
  enable_service_bool: bool = True,
222
221
  check_service_running: bool = True,
223
222
  user_mode: bool = False,
224
223
  sudo: bool = True
225
- ):
224
+ ) -> int:
226
225
  """
227
226
  Function starts and enables a service and checks its availability.
228
227
 
229
228
  :param service_name: str, the service name.
230
229
  :param wait_time_seconds: float, the time to wait after starting the service before checking the service
231
230
  availability.
232
- :param exit_on_error: bool, if True, the function will exit the program if the service is not available.
233
231
  :param start_service_bool: bool, if True, the service will be started.
234
232
  :param enable_service_bool: bool, if True, the service will be enabled.
235
233
  :param check_service_running: bool, if True, the function will check if the service is running.
236
234
  :param user_mode: bool, if True, the service will be started and enabled in user mode.
237
235
  :param sudo: bool, if True, the command will be executed with sudo.
238
- :return:
236
+
237
+ :return: int, 0 if the service is running, 1 if the service is not running.
239
238
  """
240
239
 
241
240
  if not start_service_bool and not enable_service_bool:
@@ -256,11 +255,12 @@ def start_enable_service_check_availability(
256
255
 
257
256
  if not is_service_running(service_name, user_mode=user_mode):
258
257
  console.print(f"[{service_name}] service failed to start.", style='red', markup=False)
259
- if exit_on_error:
260
- sys.exit(1)
258
+ return 1
261
259
  else:
262
260
  console.print(f"[{service_name}] service is running.", style='green', markup=False)
263
261
 
262
+ return 0
263
+
264
264
 
265
265
  def add_path_to_bashrc(as_regular_user: bool = False):
266
266
  """Add $HOME/bin to the PATH in .bashrc if it's not already present.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atomicshop
3
- Version: 3.3.20
3
+ Version: 3.3.22
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=daEPG7zh_ZCHpm4Sog8_z2pIN4ZbXwTH33VIscF97Dk,123
1
+ atomicshop/__init__.py,sha256=CwR_3jqYkF_a_nmrM3h4bWwuqn_DXHc7ThZPhoeOZoE,123
2
2
  atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
3
3
  atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
4
4
  atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
@@ -48,11 +48,10 @@ atomicshop/uuids.py,sha256=JSQdm3ZTJiwPQ1gYe6kU0TKS_7suwVrHc8JZDGYlydM,2214
48
48
  atomicshop/venvs.py,sha256=D9lwOoObkYoRx-weuoAmbvN-RdSHhVm4DE9TVl-utAs,903
49
49
  atomicshop/versioning.py,sha256=e5W6m9AF3__M5nntqI9CqNAeHqkwY9JhlnpYeZ1CEus,970
50
50
  atomicshop/virtualization.py,sha256=LPP4vjE0Vr10R6DA4lqhfX_WaNdDGRAZUW0Am6VeGco,494
51
- atomicshop/web.py,sha256=dqnOX2Y4kQktAaU2xzfT-U-emPcqN4z50rQ0UoOgiBc,13828
51
+ atomicshop/web.py,sha256=zceiDUNIJfSSOKXNaKthvQJpIkU_sTTCWDEBbIQ_K5g,13068
52
52
  atomicshop/websocket_parse.py,sha256=aLHWyKqaYqEn_MRBWm2L6rIl6QPmqbVrjEXE_rBzwCw,16711
53
53
  atomicshop/a_installs/ubuntu/docker_rootless.py,sha256=9IPNtGZYjfy1_n6ZRt7gWz9KZgR6XCgevjqq02xk-o0,281
54
54
  atomicshop/a_installs/ubuntu/docker_sudo.py,sha256=JzayxeyKDtiuT4Icp2L2LyFRbx4wvpyN_bHLfZ-yX5E,281
55
- atomicshop/a_installs/ubuntu/elastic_search_and_kibana.py,sha256=yRB-l1zBxdiN6av-FwNkhcBlaeu4zrDPjQ0uPGgpK2I,244
56
55
  atomicshop/a_mains/dns_gateway_setting.py,sha256=ncc2rFQCChxlNP59UshwmTonLqC6MWblrVAzbbz-13M,149
57
56
  atomicshop/a_mains/github_wrapper.py,sha256=F-PoZknVCxWPN0PTO6l7ZNiaYvo7OVFKFI_zlPt56ps,169
58
57
  atomicshop/a_mains/msi_unpacker.py,sha256=5hrkqETYt9HIqR_3PMf32_q06kCrIcsdm_RJV9oY438,188
@@ -188,7 +187,7 @@ atomicshop/wrappers/astw.py,sha256=VkYfkfyc_PJLIOxByT6L7B8uUmKY6-I8XGZl4t_z828,4
188
187
  atomicshop/wrappers/configparserw.py,sha256=JwDTPjZoSrv44YKwIRcjyUnpN-FjgXVfMqMK_tJuSgU,22800
189
188
  atomicshop/wrappers/cryptographyw.py,sha256=QEUpDn8vUvMg3ADz6-4oC2kbDNC_woDlw7C0zU7qFVM,14233
190
189
  atomicshop/wrappers/ffmpegw.py,sha256=wcq0ZnAe0yajBOuTKZCCaKI7CDBjkq7FAgdW5IsKcVE,6031
191
- atomicshop/wrappers/githubw.py,sha256=bds_8fgyFyHXKwty6-SBS3H3Ueta2IMM5UQFpiFmgHQ,27554
190
+ atomicshop/wrappers/githubw.py,sha256=PpG0U1MRoDY2LLYpLxnoUbSb8Pz9d47HtwBnOwxMaRY,27550
192
191
  atomicshop/wrappers/netshw.py,sha256=8WE_576XiiHykwFuE-VkCx5CydMpFlztX4frlEteCtI,6350
193
192
  atomicshop/wrappers/numpyw.py,sha256=sBV4gSKyr23kXTalqAb1oqttzE_2XxBooCui66jbAqc,1025
194
193
  atomicshop/wrappers/olefilew.py,sha256=biD5m58rogifCYmYhJBrAFb9O_Bn_spLek_9HofLeYE,2051
@@ -196,7 +195,7 @@ atomicshop/wrappers/pipw.py,sha256=mu4jnHkSaYNfpBiLZKMZxEX_E2LqW5BVthMZkblPB_c,1
196
195
  atomicshop/wrappers/process_wrapper_pbtk.py,sha256=ycPmBRnv627RWks6N8OhxJQe8Gu3h3Vwj-4HswPOw0k,599
197
196
  atomicshop/wrappers/pyopensslw.py,sha256=pklvXEbi0fHu5n1eRKKHEDLN_nsIqCTXv5Lv0bzReTo,7071
198
197
  atomicshop/wrappers/sysmonw.py,sha256=CdawuWuy_uUi3ALCm6lKP7pSyKeTk1MXyzOaTMbBSO8,5346
199
- atomicshop/wrappers/ubuntu_terminal.py,sha256=hHXsr_jEHU4frCwgo1XWS5Gb5nmg-Q06tiem4N8RYeE,12316
198
+ atomicshop/wrappers/ubuntu_terminal.py,sha256=XHM6NkzNV9x57yuPWNijLDK9ayk1-KT0n3qcv31BoSc,12215
200
199
  atomicshop/wrappers/certauthw/certauth.py,sha256=qLo593_MLU8VfbhYoNQ3J5BvtZuE71aFQROysEt6_dk,12225
201
200
  atomicshop/wrappers/certauthw/certauthw.py,sha256=4WvhjANI7Kzqrr_nKmtA8Kf7B6rute_5wfP65gwQrjw,8082
202
201
  atomicshop/wrappers/ctyping/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -216,10 +215,9 @@ atomicshop/wrappers/dockerw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
216
215
  atomicshop/wrappers/dockerw/dockerw.py,sha256=GgPSvXxJj15kZ-LPiaHLl8aekof53sSP_U-vUMUe7_8,10639
217
216
  atomicshop/wrappers/dockerw/install_docker.py,sha256=9fjbx3GtpnNA4d4YU2ziPynqANXxo-x-Sq90SUSQEPg,18448
218
217
  atomicshop/wrappers/elasticsearchw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
219
- atomicshop/wrappers/elasticsearchw/config_basic.py,sha256=fDujtrjEjbWiYh_WQ3OcYp_8mXhXPYeKLy4wSPL5qM0,1177
220
- atomicshop/wrappers/elasticsearchw/elastic_infra.py,sha256=at0sD-SFtmEvfGyIU_YBEKoU-MNeVtDQSNscPm0JWLc,10368
218
+ atomicshop/wrappers/elasticsearchw/config_basic.py,sha256=vTXnOYFTT5ggZIIdiw2vhTSr9WMmJg0-QP3pt3AT9R0,515
219
+ atomicshop/wrappers/elasticsearchw/elastic_infra.py,sha256=EiPMUufu6ZGVGFNW7lzQI8zzb0cDJCjx5pBkuahJl88,2807
221
220
  atomicshop/wrappers/elasticsearchw/elasticsearchw.py,sha256=nkjUuW6dhJf65w3JiGIxUFxSO_oNFCFw9fFR0xH_SCU,9152
222
- atomicshop/wrappers/elasticsearchw/install_elastic.py,sha256=m77uAkfEkjwTf0CfWBHal1C7gcQDwry7LcWN331KZOI,8640
223
221
  atomicshop/wrappers/elasticsearchw/queries/__init__.py,sha256=KBjT-bAt75CJsx1Apko9mpuFU4pfZV8DcGWQvpX65RU,78
224
222
  atomicshop/wrappers/elasticsearchw/queries/aggregation.py,sha256=N9a5yMMnb10sMa_x1qJBFQpgyJ49UWo8_vxuqmUtZ1A,1742
225
223
  atomicshop/wrappers/elasticsearchw/queries/info.py,sha256=P_VhhBo8MvRI4Shi-bh4RsYtlYNRKRBzScXPC64Up_Q,2900
@@ -316,8 +314,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=_gA8bMX6Sw_UCXKi2y9wNAwlqif
316
314
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
317
315
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
318
316
  atomicshop/wrappers/winregw/winreg_network.py,sha256=ih0BVNwByLvf9F_Lac4EdmDYYJA3PzMvmG0PieDZrsE,9905
319
- atomicshop-3.3.20.dist-info/licenses/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
320
- atomicshop-3.3.20.dist-info/METADATA,sha256=I5gi1E_luKNMlPHr-A7P1-K5fNsHguRj1RejizN80sE,9312
321
- atomicshop-3.3.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
322
- atomicshop-3.3.20.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
323
- atomicshop-3.3.20.dist-info/RECORD,,
317
+ atomicshop-3.3.22.dist-info/licenses/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
318
+ atomicshop-3.3.22.dist-info/METADATA,sha256=XyMxJFTTJwHywcPPUpS42MjToQQiaXSP6vjxpdphYH0,9312
319
+ atomicshop-3.3.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
320
+ atomicshop-3.3.22.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
321
+ atomicshop-3.3.22.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- #! /usr/bin/env python3
2
- from atomicshop.wrappers.elasticsearchw import install_elastic
3
-
4
-
5
- def main():
6
- install_elastic.install_elastic_kibana_ubuntu(install_elastic=True, install_kibana=True)
7
-
8
-
9
- if __name__ == '__main__':
10
- main()
@@ -1,233 +0,0 @@
1
- import sys
2
-
3
- from ...print_api import print_api
4
- from ... import process
5
- from ...permissions import permissions
6
- from .. import ubuntu_terminal
7
- from . import config_basic, elastic_infra
8
-
9
-
10
- def install_elastic_kibana_ubuntu(install_elastic: bool = True, install_kibana: bool = True):
11
- """
12
- The function will install docker on ubuntu.
13
-
14
- :param install_elastic: bool, if True, install Elasticsearch.
15
- :param install_kibana: bool, if True, install Kibana.
16
-
17
- Usage in main.py (run with sudo):
18
- from atomicshop.wrappers.elasticw import install_elastic
19
-
20
-
21
- def main():
22
- install_elastic.install_elastic_ubuntu()
23
-
24
-
25
- if __name__ == '__main__':
26
- main()
27
- """
28
-
29
- # This is pure bash script.
30
- """
31
- #!/bin/bash
32
-
33
- # Color text in red.
34
- echo_red() {
35
- local color="\e[31m" # Red color
36
- local reset="\e[0m" # Reset formatting
37
- echo -e "${color}$1${reset}"
38
- }
39
-
40
- # Function to check if a service is running
41
- check_service_running() {
42
- local service_name=$1
43
- local status=$(systemctl is-active "$service_name")
44
-
45
- if [ "$status" == "active" ]; then
46
- echo "$service_name service is active and running."
47
- return 0
48
- else
49
- echo_red "$service_name service is not running or has failed. Status: $service_status, Failed: $service_failed"
50
- return 1
51
- fi
52
- }
53
-
54
- # Update and upgrade system packages
55
- sudo apt-get update && sudo apt-get upgrade -y
56
-
57
- # Install necessary dependencies
58
- sudo apt-get install apt-transport-https openjdk-11-jdk wget -y
59
-
60
- # Download and install the GPG signing key
61
- wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --dearmor | sudo tee /usr/share/keyrings/elasticsearch-keyring.gpg > /dev/null
62
-
63
- # Add the Elastic repository to the system
64
- echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
65
-
66
- # Update package index
67
- sudo apt-get update
68
-
69
- # Install Elasticsearch
70
- sudo apt-get install elasticsearch -y
71
-
72
- # Path to the Elasticsearch configuration file
73
- CONFIG_FILE="/etc/elasticsearch/elasticsearch.yml"
74
-
75
- # Check if the configuration file exists
76
- if [ ! -f "$CONFIG_FILE" ]; then
77
- echo "Configuration file does not exist at $CONFIG_FILE."
78
- exit 1
79
- fi
80
-
81
- # Function to check the setting in the configuration file
82
- check_setting() {
83
- if grep -q "^xpack.security.enabled: false" "$CONFIG_FILE"; then
84
- echo "The setting is confirmed to be 'xpack.security.enabled: false'."
85
- else
86
- echo "Failed to set 'xpack.security.enabled: false'."
87
- exit 1
88
- fi
89
- }
90
-
91
- # Check if 'xpack.security.enabled' is set to 'false'
92
- if grep -q "^xpack.security.enabled: false" "$CONFIG_FILE"; then
93
- echo "The setting is already set to false."
94
- elif grep -q "^xpack.security.enabled: true" "$CONFIG_FILE"; then
95
- # If the setting is true, change it to false
96
- sudo sed -i 's/^xpack.security.enabled: true/xpack.security.enabled: false/' "$CONFIG_FILE"
97
- echo "Changed xpack.security.enabled to false."
98
- check_setting
99
- else
100
- # If the setting doesn't exist, add it
101
- echo "xpack.security.enabled: false" | sudo tee -a "$CONFIG_FILE" > /dev/null
102
- echo "Added xpack.security.enabled: false to the configuration."
103
- check_setting
104
- fi
105
-
106
- # Start and enable Elasticsearch service
107
- sudo systemctl start elasticsearch
108
- sudo systemctl enable elasticsearch
109
-
110
- echo "Waiting 30 seconds for program to start before availability check..."
111
- sleep 30
112
-
113
- # Check if Elasticsearch service is running
114
- if ! check_service_running "elasticsearch"; then
115
- echo "Elasticsearch service failed to start. Exiting."
116
- exit 1
117
- fi
118
-
119
- # Function to check if Elasticsearch is up and running
120
- check_elasticsearch() {
121
- max_attempts=5
122
- wait_seconds=10
123
-
124
- for ((i=1; i<=max_attempts; i++)); do
125
- echo "Checking if Elasticsearch is running (Attempt $i/$max_attempts)..."
126
-
127
- # Using curl to get the HTTP status code
128
- status=$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:9200)
129
-
130
- if [ "$status" -eq 200 ]; then
131
- echo "Elasticsearch is up and running."
132
- return 0
133
- else
134
- echo "Elasticsearch is not running. Status code: $status"
135
- fi
136
-
137
- echo "Waiting for Elasticsearch to start..."
138
- sleep $wait_seconds
139
- done
140
-
141
- echo "Elasticsearch did not start within the expected time."
142
- return 1
143
- }
144
-
145
- # Check if Elasticsearch is running
146
- if ! check_elasticsearch; then
147
- echo "Elasticsearch failed to start. Exiting."
148
- exit 1
149
- fi
150
-
151
- # Install Kibana
152
- sudo apt-get install kibana -y
153
-
154
- # Start and enable Kibana service
155
- sudo systemctl start kibana
156
- sudo systemctl enable kibana
157
-
158
- echo "Waiting 30 seconds for program to start before availability check..."
159
- sleep 30
160
-
161
- # Check if Kibana service is running
162
- if ! check_service_running "kibana"; then
163
- echo "Kibana service failed to start. Exiting."
164
- exit 1
165
- fi
166
-
167
- # Print status
168
- echo "Elasticsearch and Kibana installation completed."
169
- echo "Elasticsearch is running on http://localhost:9200"
170
- echo "Kibana is running on http://localhost:5601"
171
- """
172
-
173
- if not install_elastic and not install_kibana:
174
- raise ValueError("At least one of the services (Elasticsearch or Kibana) must be installed.")
175
-
176
- # Update and upgrade system packages.
177
- ubuntu_terminal.update_system_packages()
178
- ubuntu_terminal.upgrade_system_packages()
179
-
180
- # Install necessary dependencies.
181
- ubuntu_terminal.install_packages(config_basic.UBUNTU_DEPENDENCY_PACKAGES)
182
-
183
- # Install the GPG key and add elastic repository.
184
- script = f"""
185
- # Download and install the GPG signing key
186
- wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --dearmor | sudo tee /usr/share/keyrings/elasticsearch-keyring.gpg > /dev/null
187
-
188
- # Add the Elastic repository to the system
189
- echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
190
- """
191
- process.execute_script(script, shell=True)
192
-
193
- # Update system with elastic search packages.
194
- ubuntu_terminal.update_system_packages()
195
-
196
- if install_elastic:
197
- # Install Elasticsearch.
198
- ubuntu_terminal.install_packages([config_basic.UBUNTU_ELASTIC_PACKAGE_NAME])
199
-
200
- if not permissions.is_admin():
201
- print_api("This script requires root privileges...", color='red')
202
- sys.exit(1)
203
-
204
- # Check if the configuration file exists.
205
- elastic_infra.is_elastic_config_file_exists(exit_on_error=True, output_message=True)
206
-
207
- # Check if the specific setting exists or not and set it to false.
208
- elastic_infra.modify_xpack_security_setting(setting=False, output_message=True)
209
-
210
- # Check if the setting was really set to false.
211
- if elastic_infra.check_xpack_security_setting() is False:
212
- print_api(f"The setting is confirmed to be [{config_basic.XPACK_SECURITY_SETTING_NAME}: false].")
213
- else:
214
- print_api(f"Failed to set [{config_basic.XPACK_SECURITY_SETTING_NAME}: false].")
215
- sys.exit(1)
216
-
217
- elastic_infra.start_elastic_and_check_service_availability()
218
-
219
- print_api("Creating custom JVM options file with 4GB memory usage.")
220
- elastic_infra.create_jvm_options_custom_4gb_memory_heap_file()
221
-
222
- if install_kibana:
223
- # Install Kibana.
224
- ubuntu_terminal.install_packages([config_basic.UBUNTU_KIBANA_PACKAGE_NAME])
225
-
226
- # Start and enable Kibana service.
227
- elastic_infra.start_kibana_and_check_service_availability()
228
-
229
- print_api("Installation completed.", color='green')
230
- if install_elastic:
231
- print_api(f"Default Elasticsearch on {config_basic.DEFAULT_ELASTIC_URL}")
232
- if install_kibana:
233
- print_api(f"Default Kibana on {config_basic.DEFAULT_KIBANA_URL}")