From 44d630f7a70863d6c7749b6b404b3f6e70ef48ae Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 10 Nov 2025 16:35:46 +0000 Subject: [PATCH] feat(cli): Add function to retrieve all web panel settings --- core/cli_api.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/core/cli_api.py b/core/cli_api.py index 1ce7922..edc382e 100644 --- a/core/cli_api.py +++ b/core/cli_api.py @@ -733,6 +733,31 @@ def get_webpanel_api_token() -> str | None: '''Gets the API token of WebPanel.''' return run_cmd(['bash', Command.SHELL_WEBPANEL.value, 'api-token']) +def get_webpanel_env_config() -> dict[str, Any]: + '''Retrieves the current configuration for the WebPanel service from its .env file.''' + try: + if not os.path.exists(WEBPANEL_ENV_FILE): + return {} + + env_vars = dotenv_values(WEBPANEL_ENV_FILE) + config = {} + + config['DOMAIN'] = env_vars.get('DOMAIN') + config['ROOT_PATH'] = env_vars.get('ROOT_PATH') + + port_val = env_vars.get('PORT') + if port_val and port_val.isdigit(): + config['PORT'] = int(port_val) + + exp_val = env_vars.get('EXPIRATION_MINUTES') + if exp_val and exp_val.isdigit(): + config['EXPIRATION_MINUTES'] = int(exp_val) + + return config + except Exception as e: + print(f"Error reading WebPanel .env file: {e}") + return {} + def reset_webpanel_credentials(new_username: str | None = None, new_password: str | None = None): '''Resets the WebPanel admin username and/or password.''' if not new_username and not new_password: