#!/usr/bin/env python3 import sys import resource import logging import NetLib import ogGlobals import SystemLib import DiskLib from GitLib import OpengnsysGitLibrary, NTFSImplementation, OgProgressPrinterWeb if __name__ == "__main__": 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}") 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.")