From c7a87f96c19e69232a52aa002959166a113e1a88 Mon Sep 17 00:00:00 2001 From: lgromero Date: Thu, 7 Nov 2024 16:58:06 +0100 Subject: [PATCH] refs #1055 adds ogadmeClient template and use ogcore ip to generate ogAdmClient.cfg to the client --- etc/ogAdmClient.cfg | 5 ----- etc/ogAdmClient.cfg.tmpl | 5 +++++ installer/ogboot_installer.py | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) delete mode 100644 etc/ogAdmClient.cfg create mode 100644 etc/ogAdmClient.cfg.tmpl diff --git a/etc/ogAdmClient.cfg b/etc/ogAdmClient.cfg deleted file mode 100644 index b15e740..0000000 --- a/etc/ogAdmClient.cfg +++ /dev/null @@ -1,5 +0,0 @@ -ServidorAdm=SERVERIP -PUERTO=2008 -PATHINTERFACE=/opt/opengnsys/interfaceAdm -UrlMenu=OPENGNSYSURL/varios/menubrowser.php -UrlMsg=http://localhost/cgi-bin/httpd-log.sh \ No newline at end of file diff --git a/etc/ogAdmClient.cfg.tmpl b/etc/ogAdmClient.cfg.tmpl new file mode 100644 index 0000000..3ab06bc --- /dev/null +++ b/etc/ogAdmClient.cfg.tmpl @@ -0,0 +1,5 @@ +ServidorAdm=__OGCOREIP__ +PUERTO=2008 +PATHINTERFACE=/opt/opengnsys/interfaceAdm +UrlMenu=OGCOREURL/varios/menubrowser.php +UrlMsg=http://localhost/cgi-bin/httpd-log.sh \ No newline at end of file diff --git a/installer/ogboot_installer.py b/installer/ogboot_installer.py index 628a6cb..4abb7c6 100755 --- a/installer/ogboot_installer.py +++ b/installer/ogboot_installer.py @@ -443,12 +443,38 @@ def copyClientFiles(): logger.error(f"Error while copying engine files") errstatus = 1 + # Creación del archivo ogAdmClient.cfg + try: + template_path = os.path.join(REPO_DIR, "etc/ogAdmClient.cfg.tmpl") + output_path = os.path.join(INSTALL_OGBOOT_TARGET, "client/etc/ogAdmClient.cfg") + + # Construcción de la URL de la consola + console_url = f"https://{OGCORE_IP}/opengnsys" + + # Leer la plantilla y realizar los reemplazos + with open(template_path, 'r') as template_file: + content = template_file.read() + content = content.replace("__OGCOREIP__", OGCORE_IP) + content = content.replace("__OGCOREURL__", console_url) + + # Crear el archivo de configuración resultante + os.makedirs(os.path.dirname(output_path), mode=0o775, exist_ok=True) + with open(output_path, 'w') as config_file: + config_file.write(content) + + logger.info("Configuration file ogAdmClient.cfg created successfully.") + + except Exception as e: + logger.error(f"Error creating ogAdmClient.cfg: {e}") + errstatus = 1 + if errstatus == 0: logger.info(f"Client copy files success.") else: logger.error(f"Client copy files with errors") return not errstatus + def get_first_network_interface_with_traffic(): with open('/proc/net/dev') as f: for line in f: