diff --git a/interfaceAdm/CrearImagenGit.py b/interfaceAdm/CrearImagenGit.py deleted file mode 100755 index 0375d92..0000000 --- a/interfaceAdm/CrearImagenGit.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python3 -import os -import subprocess -import sys -import time -import resource - - - -soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) -try: - # Usamos el mínimo entre 65536 y el límite hard disponible - new_limit = min(65536, hard) - resource.setrlimit(resource.RLIMIT_NOFILE, (new_limit, hard)) - print(f"RLIMIT_NOFILE establecido a: {resource.getrlimit(resource.RLIMIT_NOFILE)}") -except ValueError as e: - print(f"No se pudo aumentar el límite de archivos abiertos: {e}") - -# Añadir rutas personalizadas de forma segura -extra_paths = [ - "/opt/opengnsys/interfaceAdm/git/", - "/opt/opengnsys/ogrepository/oggit/lib/" -] - - -# Si estás completamente seguro de que esta ruta no interfiere con la stdlib -# y contiene todos los módulos necesarios, puedes añadirla AL FINAL del path. -path_maybe_problematic = "/opt/oglive/rootfs/opt/opengnsys/lib/python3/" -if os.path.isdir(path_maybe_problematic): - sys.path.append(path_maybe_problematic) - - for path in extra_paths: - if os.path.isdir(path): - sys.path.append(path) - - -import NetLib -import ogGlobals -import SystemLib -import logging -import DiskLib -import NetLib - - - -from GitLib import OpengnsysGitLibrary, NTFSImplementation, OgProgressPrinterWeb - - -def create_image(disk_num, partition_num, repo, image_name, tagName): - - ntfs_impl = NTFSImplementation.NTFS3G - og_git = OpengnsysGitLibrary(ntfs_implementation = ntfs_impl) - og_git.progress_callback = OgProgressPrinterWeb() - - device = DiskLib.ogDiskToDev(disk_num, partition_num) - if og_git.initRepo(device, image_name): - return 0 - #if tagName: - # og_git.tag(device = device, tagName = tagName, commit = "HEAD", message = "Image created") - else: - return 1 - - -def main(): - if len(sys.argv) != 6: - sys.exit(SystemLib.ogRaiseError([], ogGlobals.OG_ERR_FORMAT, "Incorrect number of arguments. Usage: CrearImagenGit.py disk_num partition_num image_name repo tag")) - - # repo - repositorio, ip address. Opcional porque oglive lo recibe como parametro de kernel - # tag - tag a crear automaticamente. Opcional, no necesitamos crear un tag siempre. - - - disk_num, partition_num, image_name, repo, tag = sys.argv[1:6] - - - opengnsys_log_dir = "/opt/opengnsys/log" - ip_address = NetLib.ogGetIpAddress() - logFilePath = f"{opengnsys_log_dir}/{ip_address}.log" - - fileLog = logging.FileHandler(logFilePath) - fileLog.setLevel(logging.DEBUG) - - formatter = logging.Formatter('%(asctime)s - %(name)24s - [%(levelname)5s] - %(message)s') - - fileLog.setFormatter(formatter) - - logger = logging.getLogger(__package__) - logger.setLevel(logging.DEBUG) - logger.addHandler(fileLog) - - logger.info("Starting CrearImagenGit") - - - retval = create_image(disk_num, partition_num, repo, image_name, tag) - - - - sys.exit(retval) - -if __name__ == "__main__": - main() diff --git a/interfaceAdm/ModificarImagenGit.py b/interfaceAdm/ModificarImagenGit.py deleted file mode 100644 index e0a58b5..0000000 --- a/interfaceAdm/ModificarImagenGit.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python3 -import os -import subprocess -import sys -import time -import resource - - - -soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) -try: - # Usamos el mínimo entre 65536 y el límite hard disponible - new_limit = min(65536, hard) - resource.setrlimit(resource.RLIMIT_NOFILE, (new_limit, hard)) - print(f"RLIMIT_NOFILE establecido a: {resource.getrlimit(resource.RLIMIT_NOFILE)}") -except ValueError as e: - print(f"No se pudo aumentar el límite de archivos abiertos: {e}") - -# Añadir rutas personalizadas de forma segura -extra_paths = [ - "/opt/opengnsys/interfaceAdm/git/", - "/opt/opengnsys/ogrepository/oggit/lib/" -] - - -# Si estás completamente seguro de que esta ruta no interfiere con la stdlib -# y contiene todos los módulos necesarios, puedes añadirla AL FINAL del path. -path_maybe_problematic = "/opt/oglive/rootfs/opt/opengnsys/lib/python3/" -if os.path.isdir(path_maybe_problematic): - sys.path.append(path_maybe_problematic) - - for path in extra_paths: - if os.path.isdir(path): - sys.path.append(path) - - -import NetLib -import ogGlobals -import SystemLib -import logging -import DiskLib -import NetLib - - - -from GitLib import OpengnsysGitLibrary, NTFSImplementation, OgProgressPrinterWeb - - -def commit_image(disk_num, partition_num, repo, image_name, msg): - - ntfs_impl = NTFSImplementation.NTFS3G - og_git = OpengnsysGitLibrary(ntfs_implementation = ntfs_impl) - og_git.progress_callback = OgProgressPrinterWeb() - - device = DiskLib.ogDiskToDev(disk_num, partition_num) - og_git.initRepo(device, image_name) - og_git.commit(device, msg) - og_git.push() - -def main(): - if len(sys.argv) != 6: - sys.exit(SystemLib.ogRaiseError([], ogGlobals.OG_ERR_FORMAT, "Incorrect number of arguments. Usage: ModificarImagenGit.py disk_num partition_num image_name repo msg")) - - # repo - repositorio, ip address. Opcional porque oglive lo recibe como parametro de kernel - # tag - tag a crear automaticamente. Opcional, no necesitamos crear un tag siempre. - - - disk_num, partition_num, image_name, repo, msg = sys.argv[1:6] - - - opengnsys_log_dir = "/opt/opengnsys/log" - ip_address = NetLib.ogGetIpAddress() - logFilePath = f"{opengnsys_log_dir}/{ip_address}.log" - - fileLog = logging.FileHandler(logFilePath) - fileLog.setLevel(logging.DEBUG) - - formatter = logging.Formatter('%(asctime)s - %(name)24s - [%(levelname)5s] - %(message)s') - - fileLog.setFormatter(formatter) - - logger = logging.getLogger(__package__) - logger.setLevel(logging.DEBUG) - logger.addHandler(fileLog) - - logger.info("Starting ModificarImagenGit") - - - retval = commit_image(disk_num, partition_num, repo, image_name, msg) - - - - sys.exit(retval) - -if __name__ == "__main__": - main() diff --git a/interfaceAdm/RestaurarImagenGit.py b/interfaceAdm/RestaurarImagenGit.py deleted file mode 100755 index 802dd2d..0000000 --- a/interfaceAdm/RestaurarImagenGit.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python3 -import sys -import subprocess -import resource -import os -import logging - - - -soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) -try: - # Usamos el mínimo entre 65536 y el límite hard disponible - new_limit = min(65536, hard) - resource.setrlimit(resource.RLIMIT_NOFILE, (new_limit, hard)) - print(f"RLIMIT_NOFILE establecido a: {resource.getrlimit(resource.RLIMIT_NOFILE)}") -except ValueError as e: - print(f"No se pudo aumentar el límite de archivos abiertos: {e}") - -# Añadir rutas personalizadas de forma segura -extra_paths = [ - "/opt/opengnsys/interfaceAdm/git/", - "/opt/opengnsys/ogrepository/oggit/lib/" -] - - -# Si estás completamente seguro de que esta ruta no interfiere con la stdlib -# y contiene todos los módulos necesarios, puedes añadirla AL FINAL del path. -path_maybe_problematic = "/opt/oglive/rootfs/opt/opengnsys/lib/python3/" -if os.path.isdir(path_maybe_problematic): - sys.path.append(path_maybe_problematic) - - for path in extra_paths: - if os.path.isdir(path): - sys.path.append(path) - - -import NetLib -import ogGlobals -import SystemLib -import DiskLib - -from GitLib import OpengnsysGitLibrary, NTFSImplementation, OgProgressPrinterWeb - -if __name__ == "__main__": - if len(sys.argv) < 6: - print("Usage: python RestaurarImagenGit.py ") - sys.exit(1) - - disk = sys.argv[1] - partition = sys.argv[2] - repo = sys.argv[3] - ipaddr = sys.argv[4] - gitref = sys.argv[5] - proto = sys.argv[6] - - opengnsys_log_dir = "/opt/opengnsys/log" - ip_address = NetLib.ogGetIpAddress() - logFilePath = f"{opengnsys_log_dir}/{ip_address}.log" - - fileLog = logging.FileHandler(logFilePath) - fileLog.setLevel(logging.DEBUG) - - formatter = logging.Formatter('%(asctime)s - %(name)24s - [%(levelname)5s] - %(message)s') - - fileLog.setFormatter(formatter) - - logger = logging.getLogger(__package__) - logger.setLevel(logging.DEBUG) - logger.addHandler(fileLog) - - logger.info("Starting RestaurarImagenGit") - - - - - ntfs_impl = NTFSImplementation.NTFS3G - og_git = OpengnsysGitLibrary(ntfs_implementation = ntfs_impl) - og_git.progress_callback = OgProgressPrinterWeb() - - device = DiskLib.ogDiskToDev(disk, partition) - - og_git.cloneRepo(repo, device, device) - - logger.info("RestaurarImagenGit Finished.") - -