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