refs #1674 add interfaceAdm/RestaurarImagen.py
parent
7ef88ab486
commit
ca23788600
|
@ -1,19 +1,29 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/python3
|
||||
#_______________________________________________________________________________________________________________________________
|
||||
#
|
||||
# PARAMETROS RECIBIDOS DESDE EL CLIENTE:
|
||||
# $1 disco
|
||||
# $2 par=Número de particion
|
||||
# $3 Nombre canónico de la imagen
|
||||
# $4 Dirección IP del repositorio
|
||||
# $5 Protocolo UNICAST MULTICAST TORRENT
|
||||
# $6 Opciones del protocolo
|
||||
#_______________________________________________________________________________________________________________________________
|
||||
|
||||
# Llamar al script de despliegue "deployImage".
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 7:
|
||||
print("Usage: python RestaurarImagen.py <disk> <partition> <image_name> <ip> <protocol> <protocol_options> [additional_args...]")
|
||||
sys.exit(1)
|
||||
import ogGlobals
|
||||
|
||||
disk = sys.argv[1]
|
||||
partition = sys.argv[2]
|
||||
image_name = sys.argv[3]
|
||||
ip = sys.argv[4]
|
||||
protocol = sys.argv[5]
|
||||
protocol_options = sys.argv[6]
|
||||
additional_args = sys.argv[7:]
|
||||
if __name__ == '__main__':
|
||||
prog = sys.argv[0]
|
||||
if len (sys.argv) < 7:
|
||||
print (f'Usage: {prog} <disk> <partition> <image_name> <repo_ip> <protocol> <protocol_options> [additional_args...]')
|
||||
sys.exit (1)
|
||||
|
||||
exit_code = deploy_image(ip, image_name, disk, partition, protocol, protocol_options, *additional_args)
|
||||
sys.exit(exit_code)
|
||||
disk, par, imgname, repo, proto, protoopt, *extra = sys.argv[1:]
|
||||
|
||||
rc = subprocess.run ([f'{ogGlobals.OGSCRIPTS}/deployImage.py', repo, imgname, disk, par, proto, protoopt] + extra).returncode
|
||||
sys.exit (rc)
|
||||
|
|
|
@ -653,11 +653,14 @@ def ogGrubInstallPartition (disk, par, checkos='FALSE', kernelparam=''):
|
|||
with open (f'{secondstage}{prefixsecondstage}/boot/grub/grub.cfg', 'a') as fd:
|
||||
fd.write (out + '\n')
|
||||
|
||||
#Instalar el grub
|
||||
eval = subprocess.run (['grub-install', '--force'] + efioptgrub + [f'--root-directory={secondstage}{prefixsecondstage}', firststage]).returncode
|
||||
|
||||
if InventoryLib.ogIsEfiActive(): # Movemos el grubx64.efi
|
||||
# Movemos el grubx64.efi
|
||||
if InventoryLib.ogIsEfiActive():
|
||||
for b in (glob.glob (f'{efisecondstage}/EFI/{efisubdir}/EFI/BOOT/*')):
|
||||
os.rename (f'{efisecondstage}/EFI/{efisubdir}/EFI/BOOT/{b}', f'{efisecondstage}/EFI/{efisubdir}/Boot/{b}')
|
||||
bn = os.path.basename (b)
|
||||
os.rename (f'{efisecondstage}/EFI/{efisubdir}/EFI/BOOT/{bn}', f'{efisecondstage}/EFI/{efisubdir}/Boot/{bn}')
|
||||
shutil.rmtree (f'{efisecondstage}/EFI/{efisubdir}/EFI')
|
||||
shutil.copy2 ('/usr/lib/shim/shimx64.efi.signed', f'{efisecondstage}/EFI/{efisubdir}/Boot/shimx64.efi')
|
||||
# Nombre OpenGnsys para cargador
|
||||
|
|
|
@ -294,7 +294,7 @@ def ogGetFsSize (disk, par, unit='KB'):
|
|||
return
|
||||
|
||||
# Obtener el tamaño del sistema de archivo (si no está formateado; tamaño = 0).
|
||||
mnt = FileSystemLib.ogMount (disk, par)
|
||||
mnt = ogMount (disk, par)
|
||||
if mnt:
|
||||
result = subprocess.run(["df", "-BK", mnt], capture_output=True, text=True)
|
||||
val = result.stdout.split("\n")[1].split()[1]
|
||||
|
@ -894,7 +894,7 @@ def ogGetFreeSize(disk, part, unit='KB'):
|
|||
kk
|
||||
factor = unit2factor[unit.lower()]
|
||||
|
||||
particion = FileSystemLib.ogMount (disk, part)
|
||||
particion = ogMount (disk, part)
|
||||
if not particion:
|
||||
kk
|
||||
df = subprocess.run (['df'], capture_output=True, text=True).stdout
|
||||
|
|
|
@ -295,11 +295,11 @@ def ogIsRepoLocked():
|
|||
# FUNCNAME = ogCheckProgram.__name__
|
||||
#
|
||||
# if not program or not isinstance(program, str):
|
||||
# SystemLib.ogRaiseError ("session", ogGlobals.OG_ERR_FORMAT, f"Error: {ogGlobals.lang.MSG_ERR_FORMAT} {FUNCNAME} \"program\"")
|
||||
# ogRaiseError ("session", ogGlobals.OG_ERR_FORMAT, f"Error: {ogGlobals.lang.MSG_ERR_FORMAT} {FUNCNAME} \"program\"")
|
||||
# return
|
||||
#
|
||||
# if not shutil.which(program):
|
||||
# SystemLib.ogRaiseError ( "session", ogGlobals.OG_ERR_NOTEXEC, f"Error: The program '{program}' is not available on the system.")
|
||||
# ogRaiseError ( "session", ogGlobals.OG_ERR_NOTEXEC, f"Error: The program '{program}' is not available on the system.")
|
||||
# return
|
||||
#
|
||||
# return 0
|
||||
|
|
|
@ -428,7 +428,7 @@ def ogRestoreEfiBootLoader (disk, par):
|
|||
return
|
||||
|
||||
osversion = InventoryLib.ogGetOsVersion (disk, par)
|
||||
if 'Windows 1' in osversion:
|
||||
if osversion and 'Windows 1' in osversion:
|
||||
bootlabel = f'Part-{int(disk):02d}-{int(par):02d}'
|
||||
loader = FileLib.ogGetPath (file=f'{mntdir}/ogBoot/bootmgfw.efi')
|
||||
if not loader:
|
||||
|
|
Loading…
Reference in New Issue