mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 00:33:37 +05:00
feat: add ipv6 check before installing webclients
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -13,6 +13,7 @@ from typing import List
|
||||
from components.webui_client.base_data import BaseWebClient
|
||||
from core.menus.base_menu import print_back_footer
|
||||
from utils.constants import COLOR_CYAN, COLOR_YELLOW, RESET_FORMAT
|
||||
from utils.logger import DialogType, Logger
|
||||
|
||||
|
||||
def print_moonraker_not_found_dialog():
|
||||
@@ -84,25 +85,35 @@ def print_client_port_select_dialog(name: str, port: int, ports_in_use: List[int
|
||||
print(dialog, end="")
|
||||
|
||||
|
||||
def print_install_client_config_dialog(client: BaseWebClient):
|
||||
def print_install_client_config_dialog(client: BaseWebClient) -> None:
|
||||
name = client.display_name
|
||||
url = client.client_config.repo_url.replace(".git", "")
|
||||
line1 = f"have {name} fully functional and working."
|
||||
line2 = f"The recommended macros for {name} can be seen here:"
|
||||
dialog = textwrap.dedent(
|
||||
f"""
|
||||
/=======================================================\\
|
||||
| It is recommended to use special macros in order to |
|
||||
| {line1:<54}|
|
||||
| |
|
||||
| {line2:<54}|
|
||||
| {url:<54}|
|
||||
| |
|
||||
| If you already use these macros skip this step. |
|
||||
| Otherwise you should consider to answer with 'Y' to |
|
||||
| download the recommended macros. |
|
||||
\\=======================================================/
|
||||
"""
|
||||
)[1:]
|
||||
Logger.print_dialog(
|
||||
DialogType.INFO,
|
||||
[
|
||||
f"It is recommended to use special macros in order to have {name} fully "
|
||||
f"functional and working.",
|
||||
"\n\n",
|
||||
f"The recommended macros for {name} can be seen here:",
|
||||
url,
|
||||
"\n\n",
|
||||
"If you already use these macros skip this step. Otherwise you should "
|
||||
"consider to answer with 'Y' to download the recommended macros.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
print(dialog, end="")
|
||||
|
||||
def print_ipv6_warning_dialog() -> None:
|
||||
Logger.print_dialog(
|
||||
DialogType.WARNING,
|
||||
[
|
||||
"It looks like IPv6 is enabled on this system!",
|
||||
"This may cause issues with the installation of NGINX in the following "
|
||||
"steps! It is recommended to disable IPv6 on your system to avoid this issue.",
|
||||
"\n\n",
|
||||
"If you think this warning is a false alarm, and you are sure that "
|
||||
"IPv6 is disabled, you can continue with the installation.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
@@ -24,6 +24,7 @@ from components.webui_client.client_config.client_config_setup import (
|
||||
from components.webui_client.client_dialogs import (
|
||||
print_client_port_select_dialog,
|
||||
print_install_client_config_dialog,
|
||||
print_ipv6_warning_dialog,
|
||||
print_moonraker_not_found_dialog,
|
||||
)
|
||||
from components.webui_client.client_utils import (
|
||||
@@ -49,6 +50,7 @@ from utils.fs_utils import (
|
||||
from utils.input_utils import get_confirm, get_number_input
|
||||
from utils.logger import Logger
|
||||
from utils.sys_utils import (
|
||||
check_ipv6,
|
||||
cmd_sysctl_service,
|
||||
download_file,
|
||||
get_ipv4_addr,
|
||||
@@ -115,6 +117,13 @@ def install_client(client: BaseWebClient) -> None:
|
||||
)
|
||||
valid_port = is_valid_port(port, ports_in_use)
|
||||
|
||||
# check if ipv6 is enabled, as this may cause issues with nginx
|
||||
if check_ipv6():
|
||||
print_ipv6_warning_dialog()
|
||||
if not get_confirm(f"Continue with {client.display_name} installation?"):
|
||||
Logger.print_info(f"Exiting {client.display_name} installation ...")
|
||||
return
|
||||
|
||||
check_install_dependencies(["nginx", "unzip"])
|
||||
|
||||
try:
|
||||
|
||||
@@ -402,3 +402,34 @@ def log_process(process: Popen) -> None:
|
||||
|
||||
if process.poll() is not None:
|
||||
break
|
||||
|
||||
|
||||
def check_ipv6() -> bool:
|
||||
"""
|
||||
Check if IPv6 is enabled
|
||||
:return: True if IPv6 is enabled, False otherwise
|
||||
"""
|
||||
try:
|
||||
file1 = Path("/proc/sys/net/ipv6/conf/all/disable_ipv6")
|
||||
if file1.exists():
|
||||
with open(file1, "r") as file:
|
||||
if file.read().strip() == "0":
|
||||
return True
|
||||
elif file.read().strip() == "1":
|
||||
return False
|
||||
|
||||
file3 = Path("/etc/sysctl.conf")
|
||||
if file3.exists():
|
||||
with open(file3, "r") as file:
|
||||
for line in file.readlines():
|
||||
if (
|
||||
"net.ipv6.conf.all.disable_ipv6" in line
|
||||
and not line.startswith("#")
|
||||
and line.split("=")[1].strip() == "0"
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
Logger.print_error(f"Error checking IPv6: {e}")
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user