refs #1166 add ogSetPartitionActive()
parent
4be9f566a6
commit
410f47fba2
|
@ -18,6 +18,7 @@ import ogGlobals
|
|||
import SystemLib
|
||||
import CacheLib
|
||||
import FileSystemLib
|
||||
import InventoryLib
|
||||
|
||||
# Función ficticia para lanzar parted con timeout, evitando cuelgues del programa.
|
||||
def parted(*args):
|
||||
|
@ -1290,29 +1291,18 @@ def ogLockDisk(*args):
|
|||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo.
|
||||
#@note Requisitos: parted
|
||||
#*/ ##
|
||||
def ogSetPartitionActive(*args):
|
||||
# Variables locales
|
||||
DISK = None
|
||||
PART = None
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if len(args) == 1 and args[0] == "help":
|
||||
SystemLib.ogHelp('ogSetPartitionActive', 'ogSetPartitionActive int_ndisk int_npartition', 'ogSetPartitionActive 1 1')
|
||||
def ogSetPartitionActive (disk, par):
|
||||
if InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogEcho (['session', 'log'], 'warning', f'EFI: {ogGlobals.lang.MSG_DONTUSE} {ogSetPartitionActive}')
|
||||
return
|
||||
|
||||
# Error si no se reciben 2 parámetros.
|
||||
if len(args) != 2:
|
||||
SystemLib.ogRaiseError(OG_ERR_FORMAT)
|
||||
return
|
||||
DISK = ogDiskToDev (disk)
|
||||
if DISK is None: return
|
||||
|
||||
# Comprobar que el disco existe y activar la partición indicada.
|
||||
DISK = ogDiskToDev(args[0])
|
||||
if DISK is None:
|
||||
return
|
||||
PART = ogDiskToDev(args[0], args[1])
|
||||
if PART is None:
|
||||
return
|
||||
subprocess.run(["parted", "-s", DISK, "set", args[1], "boot", "on"], stderr=subprocess.DEVNULL)
|
||||
PART = ogDiskToDev (disk, par)
|
||||
if PART is None: return
|
||||
|
||||
subprocess.run (["parted", "-s", DISK, "set", par, "boot", "on"])
|
||||
return
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue