#!/usr/bin/python3 import os import glob import subprocess from InventoryLib import ogGetSerialNumber, ogGetOsVersion, ogIsEfiActive from DiskLib import ogDiskToDev, ogGetPartitionsNumber, ogGetPartitionTableType, ogGetDiskSize, ogGetPartitionId, ogGetPartitionSize from FileSystemLib import ogMount, ogGetMountPoint, ogGetFsType ser = ogGetSerialNumber() fwt = 'UEFI' if ogIsEfiActive() else 'BIOS' print (f'ser={ser}\nfwt={fwt}') disks = len (ogDiskToDev()) if disks: for dsk in range (1, disks+1): # Tipo de tabla de particiones: 1=MSDOS, 2=GPT ptt = ogGetPartitionTableType (dsk) ptt_map = { 'MSDOS': 1, 'GPT': 2, 'LVM': 3, 'ZPOOL': 4, } ptt = ptt_map.get (ptt, 0) # Información de disco (partición 0) s = ogGetDiskSize (dsk) print (f'disk={dsk}\tpar=0\tcpt={ptt}\tfsi=\tsoi=\ttam={s}\tuso=0') particiones = ogGetPartitionsNumber (dsk) particiones = int (particiones) if particiones else 0 for par in range (1, particiones+1): # Código del identificador de tipo de partición cod = ogGetPartitionId (dsk, par) # Tipo del sistema de ficheros fsi = ogGetFsType (dsk, par) if not fsi: fsi = 'EMPTY' # Tamaño de la particón tam = ogGetPartitionSize (dsk, par) if not tam: tam = '0' # Sistema operativo instalado y porcentaje de uso soi = '' uso = '0' if fsi not in ['', 'EMPTY', 'LINUX-SWAP', 'LINUX-LVM', 'ZVOL']: if ogMount (dsk, par): soi = ogGetOsVersion (dsk, par) # Hacer un 2º intento para algunos casos especiales. if not soi: soi = ogGetOsVersion (dsk, par) if not soi: soi = '' if soi: soi = soi.split (':')[1] # Sistema de archivos para datos (sistema operativo "DATA") if not soi and fsi not in ['EMPTY', 'CACHE']: soi = 'DATA' mntpt = ogGetMountPoint (dsk, par) uso = subprocess.run (['df', mntpt], capture_output=True, text=True).stdout.splitlines()[-1].split()[4].replace ('%', '') if not uso: uso = '0' else: soi = '' uso = '0' print (f'disk={dsk}\tpar={par}\tcpt={cod}\tfsi={fsi}\tsoi={soi}\ttam={tam}\tuso={uso}') else: print ('disk=1\tpar=0\tcpt=0\tfsi=\tsoi=\ttam=0\tuso=0') # Crear el menú por defecto a partir del fichero generado (no dar ninguna salida). # requiere /tmp/getconfig pero este script ya no lo crea #subprocess.run ([f'{ogGlobals.OGSCRIPTS}/generateMenuDefault']) # Borramos marcas de arranque de Windows for f in glob.glob ('/mnt/*/ogboot.*') + glob.glob ('/mnt/*/*/ogboot.*'): try: os.unlink (f) except: pass