refs #1625 add ogGrubSetTimeOut
parent
cd81c16afb
commit
4e1a188e53
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
import ogGlobals
|
||||||
|
from SystemLib import ogHelp
|
||||||
|
from BootLib import ogBootLoaderSetTimeOut
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser (add_help=False)
|
||||||
|
parser.add_argument ('disk')
|
||||||
|
parser.add_argument ('par')
|
||||||
|
parser.add_argument ('timeout')
|
||||||
|
|
||||||
|
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||||
|
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||||
|
ogHelp ('ogBootLoaderSetTimeOut', ogGlobals.lang.MSG_SEE+' ogGrubSetTimeOut', [])
|
||||||
|
sys.exit (0)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
ret = ogBootLoaderSetTimeOut (args.disk, args.par, args.timeout)
|
||||||
|
|
||||||
|
if ret is not None:
|
||||||
|
if ret == True: sys.exit (0)
|
||||||
|
elif ret == False: sys.exit (1)
|
||||||
|
else: print (ret)
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
from SystemLib import ogHelp
|
||||||
|
from BootLib import ogGrubSetTimeOut
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser (add_help=False)
|
||||||
|
parser.add_argument ('disk')
|
||||||
|
parser.add_argument ('par')
|
||||||
|
parser.add_argument ('timeout')
|
||||||
|
|
||||||
|
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||||
|
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||||
|
ogHelp ('ogGrubSetTimeOut', 'ogGrubSetTimeOut int_ndiskSecondStage int_partitionSecondStage int_timeout_seconds', ['ogGrubSetTimeOut 1 4 50'])
|
||||||
|
sys.exit (0)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
ret = ogGrubSetTimeOut (args.disk, args.par, args.timeout)
|
||||||
|
|
||||||
|
if ret is not None:
|
||||||
|
if ret == True: sys.exit (0)
|
||||||
|
elif ret == False: sys.exit (1)
|
||||||
|
else: print (ret)
|
|
@ -997,22 +997,25 @@ def ogGrubOgliveDefaultEntry (disk, par):
|
||||||
#@exception OG_ERR_NOTFOUND Entrada de OgLive no encontrada en burg.cfg.
|
#@exception OG_ERR_NOTFOUND Entrada de OgLive no encontrada en burg.cfg.
|
||||||
#*/ ##
|
#*/ ##
|
||||||
def ogBootLoaderOgliveDefaultEntry (disk, par):
|
def ogBootLoaderOgliveDefaultEntry (disk, par):
|
||||||
|
# Nombre de la función que llama a esta.
|
||||||
func = inspect.stack()[1][3]
|
func = inspect.stack()[1][3]
|
||||||
|
|
||||||
|
# Error si no puede montar sistema de archivos.
|
||||||
PART = FileSystemLib.ogMount (disk, par)
|
PART = FileSystemLib.ogMount (disk, par)
|
||||||
if not PART: return None
|
if not PART: return None
|
||||||
|
# La función debe ser llamanda desde ogGrubOgliveDefaultEntry, ogBurgOgliveDefaultEntry or ogRefindOgliveDefaultEntry.
|
||||||
if 'ogGrubOgliveDefaultEntry' == func:
|
if 'ogGrubOgliveDefaultEntry' == func:
|
||||||
cfgfile = f'{PART}/boot/grubMBR/boot/grub/grub.cfg'
|
cfgfile = f'{PART}/boot/grubMBR/boot/grub/grub.cfg'
|
||||||
else:
|
else:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'Use ogGrubOgliveDefaultEntry')
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'Use ogGrubOgliveDefaultEntry')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
print (f'nati cfgfile ({cfgfile})')
|
# Comprobamos que exista fichero de configuración
|
||||||
if not os.path.exists (cfgfile):
|
if not os.path.exists (cfgfile):
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, cfgfile)
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, cfgfile)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Detectamos cual es la entrada de ogLive
|
||||||
numentry = 0
|
numentry = 0
|
||||||
with open (cfgfile, 'r') as fd:
|
with open (cfgfile, 'r') as fd:
|
||||||
while True:
|
while True:
|
||||||
|
@ -1022,7 +1025,7 @@ def ogBootLoaderOgliveDefaultEntry (disk, par):
|
||||||
numentry += 1
|
numentry += 1
|
||||||
if 'OpenGnsys Live' in l: break
|
if 'OpenGnsys Live' in l: break
|
||||||
|
|
||||||
print (f'nati numentry ({numentry})')
|
# Si no existe entrada de ogLive nos salimos
|
||||||
if not numentry:
|
if not numentry:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'menuentry OpenGnsys Live in {cfgfile}')
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'menuentry OpenGnsys Live in {cfgfile}')
|
||||||
return None
|
return None
|
||||||
|
@ -1103,6 +1106,8 @@ def ogBootLoaderOgliveDefaultEntry (disk, par):
|
||||||
#@brief ver ogBootLoaderSetTimeOut
|
#@brief ver ogBootLoaderSetTimeOut
|
||||||
#@see ogBootLoaderSetTimeOut
|
#@see ogBootLoaderSetTimeOut
|
||||||
#*/ ##
|
#*/ ##
|
||||||
|
def ogGrubSetTimeOut (disk, par, timeout):
|
||||||
|
return ogBootLoaderSetTimeOut (disk, par, timeout)
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
# ogBootLoaderSetTimeOut
|
# ogBootLoaderSetTimeOut
|
||||||
|
@ -1116,6 +1121,29 @@ def ogBootLoaderOgliveDefaultEntry (disk, par):
|
||||||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||||
#@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg.
|
#@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg.
|
||||||
#*/ ##
|
#*/ ##
|
||||||
|
def ogBootLoaderSetTimeOut (disk, par, timeout):
|
||||||
|
# Nombre de la función que llama a esta.
|
||||||
|
func = inspect.stack()[1][3]
|
||||||
|
|
||||||
|
# Error si no puede montar sistema de archivos.
|
||||||
|
PART = FileSystemLib.ogMount (disk, par)
|
||||||
|
if not PART: return None
|
||||||
|
# La función debe ser llamanda desde ogGrubSetTimeOut, ogBurgSetTimeOut or ogRefindSetTimeOut.
|
||||||
|
if 'ogGrubSetTimeOut' == func:
|
||||||
|
bootloader = 'grub'
|
||||||
|
bootloaderdir = 'boot/grubMBR'
|
||||||
|
cfgfile = f'{PART}/boot/grubMBR/boot/grub/grub.cfg'
|
||||||
|
else:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'Use ogGrubSetTimeOut')
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Comprobamos que exista fichero de configuración
|
||||||
|
if not os.path.exists (cfgfile):
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, cfgfile)
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Asignamos el timeOut.
|
||||||
|
subprocess.run (['sed', '-i', f's/timeout=.*$/timeout={timeout}/g', cfgfile])
|
||||||
|
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
|
|
Loading…
Reference in New Issue