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 sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
if __name__ == "__main__":
|
import ogGlobals
|
||||||
if len(sys.argv) < 7:
|
|
||||||
print("Usage: python RestaurarImagen.py <disk> <partition> <image_name> <ip> <protocol> <protocol_options> [additional_args...]")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
disk = sys.argv[1]
|
if __name__ == '__main__':
|
||||||
partition = sys.argv[2]
|
prog = sys.argv[0]
|
||||||
image_name = sys.argv[3]
|
if len (sys.argv) < 7:
|
||||||
ip = sys.argv[4]
|
print (f'Usage: {prog} <disk> <partition> <image_name> <repo_ip> <protocol> <protocol_options> [additional_args...]')
|
||||||
protocol = sys.argv[5]
|
sys.exit (1)
|
||||||
protocol_options = sys.argv[6]
|
|
||||||
additional_args = sys.argv[7:]
|
|
||||||
|
|
||||||
exit_code = deploy_image(ip, image_name, disk, partition, protocol, protocol_options, *additional_args)
|
disk, par, imgname, repo, proto, protoopt, *extra = sys.argv[1:]
|
||||||
sys.exit(exit_code)
|
|
||||||
|
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:
|
with open (f'{secondstage}{prefixsecondstage}/boot/grub/grub.cfg', 'a') as fd:
|
||||||
fd.write (out + '\n')
|
fd.write (out + '\n')
|
||||||
|
|
||||||
|
#Instalar el grub
|
||||||
eval = subprocess.run (['grub-install', '--force'] + efioptgrub + [f'--root-directory={secondstage}{prefixsecondstage}', firststage]).returncode
|
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/*')):
|
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.rmtree (f'{efisecondstage}/EFI/{efisubdir}/EFI')
|
||||||
shutil.copy2 ('/usr/lib/shim/shimx64.efi.signed', f'{efisecondstage}/EFI/{efisubdir}/Boot/shimx64.efi')
|
shutil.copy2 ('/usr/lib/shim/shimx64.efi.signed', f'{efisecondstage}/EFI/{efisubdir}/Boot/shimx64.efi')
|
||||||
# Nombre OpenGnsys para cargador
|
# Nombre OpenGnsys para cargador
|
||||||
|
|
|
@ -294,7 +294,7 @@ def ogGetFsSize (disk, par, unit='KB'):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Obtener el tamaño del sistema de archivo (si no está formateado; tamaño = 0).
|
# 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:
|
if mnt:
|
||||||
result = subprocess.run(["df", "-BK", mnt], capture_output=True, text=True)
|
result = subprocess.run(["df", "-BK", mnt], capture_output=True, text=True)
|
||||||
val = result.stdout.split("\n")[1].split()[1]
|
val = result.stdout.split("\n")[1].split()[1]
|
||||||
|
@ -894,7 +894,7 @@ def ogGetFreeSize(disk, part, unit='KB'):
|
||||||
kk
|
kk
|
||||||
factor = unit2factor[unit.lower()]
|
factor = unit2factor[unit.lower()]
|
||||||
|
|
||||||
particion = FileSystemLib.ogMount (disk, part)
|
particion = ogMount (disk, part)
|
||||||
if not particion:
|
if not particion:
|
||||||
kk
|
kk
|
||||||
df = subprocess.run (['df'], capture_output=True, text=True).stdout
|
df = subprocess.run (['df'], capture_output=True, text=True).stdout
|
||||||
|
|
|
@ -295,11 +295,11 @@ def ogIsRepoLocked():
|
||||||
# FUNCNAME = ogCheckProgram.__name__
|
# FUNCNAME = ogCheckProgram.__name__
|
||||||
#
|
#
|
||||||
# if not program or not isinstance(program, str):
|
# 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
|
# return
|
||||||
#
|
#
|
||||||
# if not shutil.which(program):
|
# 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
|
||||||
#
|
#
|
||||||
# return 0
|
# return 0
|
||||||
|
|
|
@ -428,7 +428,7 @@ def ogRestoreEfiBootLoader (disk, par):
|
||||||
return
|
return
|
||||||
|
|
||||||
osversion = InventoryLib.ogGetOsVersion (disk, par)
|
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}'
|
bootlabel = f'Part-{int(disk):02d}-{int(par):02d}'
|
||||||
loader = FileLib.ogGetPath (file=f'{mntdir}/ogBoot/bootmgfw.efi')
|
loader = FileLib.ogGetPath (file=f'{mntdir}/ogBoot/bootmgfw.efi')
|
||||||
if not loader:
|
if not loader:
|
||||||
|
|
Loading…
Reference in New Issue