refs #1629 add ogGrubOgliveDefaultEntry
parent
680ccd868e
commit
10745c1ca1
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import ogGlobals
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBootLoaderOgliveDefaultEntry
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBootLoaderOgliveDefaultEntry', ogGlobals.lang.MSG_SEE+' ogGrubOgliveDefaultEntry', [])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogBootLoaderOgliveDefaultEntry (args.disk, args.par)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrubOgliveDefaultEntry
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrubOgliveDefaultEntry', 'ogGrubOgliveDefaultEntry int_ndiskSecondStage int_partitionSecondStage', ['ogGrubOgliveDefaultEntry 1 6'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGrubOgliveDefaultEntry (args.disk, args.par)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -12,6 +12,7 @@ import tempfile
|
|||
import subprocess
|
||||
import shutil
|
||||
import glob
|
||||
import inspect
|
||||
|
||||
import ogGlobals
|
||||
import SystemLib
|
||||
|
@ -713,12 +714,6 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@see ogBootLoaderHidePartitions
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBurgHidePartitions num_disk num_part
|
||||
#@brief ver ogBootLoaderHidePartitions
|
||||
#@see ogBootLoaderHidePartitions
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBootLoaderHidePartitions num_disk num_part
|
||||
#@brief Configura el grub/burg para que oculte las particiones de windows que no se esten iniciando.
|
||||
|
@ -737,18 +732,6 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@see ogBootLoaderDeleteEntry
|
||||
#*/
|
||||
|
||||
#/**
|
||||
# ogBurgDeleteEntry num_disk num_part num_disk_delete num_part_delete
|
||||
#@brief ver ogBootLoaderDeleteEntry
|
||||
#@see ogBootLoaderDeleteEntry
|
||||
#*/
|
||||
|
||||
#/**
|
||||
# ogRefindDeleteEntry num_disk_delete num_part_delete
|
||||
#@brief ver ogBootLoaderDeleteEntry
|
||||
#@see ogBootLoaderDeleteEntry
|
||||
#*/
|
||||
|
||||
#/**
|
||||
# ogBootLoaderDeleteEntry num_disk num_part num_part_delete
|
||||
#@brief Borra en el grub las entradas para el inicio en una particion.
|
||||
|
@ -756,44 +739,19 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@param 2 Numero de particion donde esta el grub
|
||||
#@param 3 Numero del disco del que borramos las entradas
|
||||
#@param 4 Numero de la particion de la que borramos las entradas
|
||||
#@note Tiene que ser llamada desde ogGrubDeleteEntry, ogBurgDeleteEntry o ogRefindDeleteEntry
|
||||
#@note Tiene que ser llamada desde ogGrubDeleteEntry
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Use ogGrubDeleteEntry or ogBurgDeleteEntry.
|
||||
#@exception OG_ERR_FORMAT Use ogGrubDeleteEntry
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND No existe archivo de configuracion del grub.
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBurgInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG
|
||||
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||
#@brief Instala y actualiza el gestor grub en el MBR del disco duro donde se encuentra el fichero grub.cfg. Admite sistemas Windows.
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Partición no soportada
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogGrubDefaultEntry int_disk_GRUGCFG int_partition_GRUBCFG int_disk_default_entry int_npartition_default_entry
|
||||
#@brief ver ogBootLoaderDefaultEntry
|
||||
#@see ogBootLoaderDefaultEntry
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBurgDefaultEntry int_disk_BURGCFG int_partition_BURGCFG int_disk_default_entry int_npartition_default_entry
|
||||
#@brief ver ogBootLoaderDefaultEntry
|
||||
#@see ogBootLoaderDefaultEntry
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogRefindDefaultEntry int_disk_default_entry int_npartition_default_entry
|
||||
#@brief ver ogBootLoaderDefaultEntry
|
||||
#@see ogBootLoaderDefaultEntry
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBootLoaderDefaultEntry int_disk_CFG int_partition_CFG int_disk_default_entry int_npartition_default_entry
|
||||
#@brief Configura la entrada por defecto de Burg
|
||||
|
@ -813,19 +771,8 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@brief ver ogBootLoaderOgliveDefaultEntry
|
||||
#@see ogBootLoaderOgliveDefaultEntry
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBurgOgliveDefaultEntry num_disk num_part
|
||||
#@brief ver ogBootLoaderOgliveDefaultEntry
|
||||
#@see ogBootLoaderOgliveDefaultEntry
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogRefindOgliveDefaultEntry
|
||||
#@brief ver ogBootLoaderOgliveDefaultEntry
|
||||
#@see ogBootLoaderOgliveDefaultEntry
|
||||
#*/ ##
|
||||
def ogGrubOgliveDefaultEntry (disk, par):
|
||||
return ogBootLoaderOgliveDefaultEntry (disk, par)
|
||||
|
||||
|
||||
#/**
|
||||
|
@ -839,6 +786,48 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: burg.cfg.
|
||||
#@exception OG_ERR_NOTFOUND Entrada de OgLive no encontrada en burg.cfg.
|
||||
#*/ ##
|
||||
def ogBootLoaderOgliveDefaultEntry (disk, par):
|
||||
func = inspect.stack()[1][3]
|
||||
print (f'nati func ({func})')
|
||||
|
||||
PART = FileSystemLib.ogMount (disk, par)
|
||||
if not PART: return None
|
||||
|
||||
if 'ogGrubOgliveDefaultEntry' == func:
|
||||
cfgfile = f'{PART}/boot/grubMBR/boot/grub/grub.cfg'
|
||||
else:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'Use ogGrubOgliveDefaultEntry')
|
||||
return None
|
||||
|
||||
print (f'nati cfgfile ({cfgfile})')
|
||||
if not os.path.exists (cfgfile):
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, cfgfile)
|
||||
return None
|
||||
|
||||
numentry = 0
|
||||
with open (cfgfile, 'r') as fd:
|
||||
while True:
|
||||
l = fd.readline()
|
||||
if not l: break
|
||||
if l.startswith ('menuentry'):
|
||||
numentry += 1
|
||||
if 'OpenGnsys Live' in l: break
|
||||
|
||||
print (f'nati numentry ({numentry})')
|
||||
if not numentry:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'menuentry OpenGnsys Live in {cfgfile}')
|
||||
return None
|
||||
|
||||
numentry -= 1
|
||||
subprocess.run (['sed', '--regexp-extended', '-i', f's/"set default=\"?[0-9]+\"?"/"set default=\"{numentry}\""/g', cfgfile])
|
||||
|
||||
MSG = f'ogGlobals.lang.MSG_HELP_{func}'
|
||||
try: MSG = eval (MSG)
|
||||
except: MSG = ''
|
||||
if '.' == MSG[-1]: MSG=MSG[0:-1]
|
||||
|
||||
print (f'{MSG}: {disk} {par}')
|
||||
return True
|
||||
|
||||
|
||||
#/**
|
||||
|
@ -861,19 +850,6 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@see ogBootLoaderSetTheme
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBurgSetTheme num_disk num_part str_theme
|
||||
#@brief ver ogBootLoaderSetTheme
|
||||
#@see ogBootLoaderSetTheme
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogRefindSetTheme str_theme
|
||||
#@brief ver ogBootLoaderSetTheme
|
||||
#@see ogBootLoaderSetTheme
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogBootLoaderSetTheme
|
||||
|
@ -896,12 +872,6 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@see ogBootLoaderSetTheme
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBurgSetAdminKeys num_disk num_part str_bolean
|
||||
#@brief ver ogBootLoaderSetAdminKeys
|
||||
#@see ogBootLoaderSetAdminKeys
|
||||
#*/ ##
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
|
@ -925,19 +895,6 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@see ogBootLoaderSetTimeOut
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBurgSetTimeOut num_disk num_part str_bolean
|
||||
#@brief ver ogBootLoaderSetTimeOut
|
||||
#@see ogBootLoaderSetTimeOut
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogRefindSetTimeOut int_timeout_second
|
||||
#@brief ver ogBootLoaderSetTimeOut
|
||||
#@see ogBootLoaderSetTimeOut
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBootLoaderSetTimeOut
|
||||
#@brief Define el tiempo (segundos) que se muestran las opciones de inicio
|
||||
|
@ -958,12 +915,6 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@see ogBootLoaderSetResolution
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogBurgSetResolution num_disk num_part str_bolean
|
||||
#@brief ver ogBootLoaderSetResolution
|
||||
#@see ogBootLoaderSetResolution
|
||||
#*/ ##
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
|
@ -992,18 +943,6 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||
#*/ ##
|
||||
|
||||
# ogRefindInstall bool_autoconfig
|
||||
#@brief Instala y actualiza el gestor rEFInd en la particion EFI
|
||||
#@param bolean_Check__auto_config true | false[default]
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND No se encuentra la partición ESP.
|
||||
#@exception OG_ERR_NOTFOUND No se encuentra shimx64.efi.signed.
|
||||
#@exception OG_ERR_NOTFOUND No se encuentra refind-install o refind en OGLIB
|
||||
#@exception OG_ERR_PARTITION No se puede montar la partición ESP.
|
||||
#@note Refind debe estar instalado en el ogLive o compartido en OGLIB
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogGrub4dosInstallMbr int_ndisk
|
||||
#@brief Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux.
|
||||
|
|
|
@ -66,11 +66,11 @@ def ogEcho (logtypes, loglevel, msg):
|
|||
#@return Salida de ejecución del comando.
|
||||
#@note str_logfile = { LOG, SESSION, COMMAND }
|
||||
#*/
|
||||
#ogHelp (str_logfile ... str_command ...",
|
||||
#ogHelp ([], ogMyLib.ogSomeMethod, *args, **kwargs)
|
||||
#ogHelp ('command', ogMyLib.ogSomeMethod, *args, **kwargs)
|
||||
#ogHelp (['command'], ogMyLib.ogSomeMethod, *args, **kwargs)
|
||||
#ogHelp (['log', 'command'], ogMyLib.ogSomeMethod, *args, **kwargs)
|
||||
#ogExecAndLog (str_logfile ... str_command ...",
|
||||
#ogExecAndLog ([], ogMyLib.ogSomeMethod, *args, **kwargs)
|
||||
#ogExecAndLog ('command', ogMyLib.ogSomeMethod, *args, **kwargs)
|
||||
#ogExecAndLog (['command'], ogMyLib.ogSomeMethod, *args, **kwargs)
|
||||
#ogExecAndLog (['log', 'command'], ogMyLib.ogSomeMethod, *args, **kwargs)
|
||||
def ogExecAndLog (logtypes, fun, *args, **kwargs):
|
||||
logfiles = ['/dev/stdout']
|
||||
if type (logtypes) is list:
|
||||
|
|
Loading…
Reference in New Issue