source: client/engine/Inventory.lib @ d43640a

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since d43640a was 58718f5, checked in by ramon <ramongomez@…>, 7 years ago

Cerrar #823: Métodos más rápido para localizar ficheros y para obtener versión en Windows; cambiar Mac OS... por macOS... en función ogGetOsVersion.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5576 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 18.7 KB
RevLine 
[b550747]1#!/bin/bash
2#/**
3#@file    Inventory.lib
4#@brief   Librería o clase Inventory
5#@class   Inventory
6#@brief   Funciones para recogida de datos de inventario de hardware y software de los clientes.
[304533c]7#@version 1.1.0
[b550747]8#@warning License: GNU GPLv3+
9#*/
10
11
12#/**
[cb5997b]13#         ogGetArch
14#@brief   Devuelve el tipo de arquitectura del cliente.
15#@return  str_arch - Arquitectura (i386 para 32 bits, x86_64 para 64 bits).
16#@version 0.9.2 - Primera versión para OpenGnSys.
17#@author  Ramon Gomez, ETSII Universidad de Sevilla
18#@date    2010-07-17
19#*/
[e4dafd6]20function ogGetArch ()
21{
22if [ "$*" == "help" ]; then
23    ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME  =>  x86_64"
24    return
25fi
26
27[ -d /lib64 ] && echo "x86_64" || echo "i386"
[cb5997b]28}
29
30
31#/**
[045fd2d]32#         ogGetOsType int_ndisk int_npartition
33#@brief   Devuelve el tipo del sistema operativo instalado.
34#@param   int_ndisk      nº de orden del disco
35#@param   int_npartition nº de orden de la partición
36#@return  OSType - Tipo de sistema operativo.
37#@see     ogGetOsVersion
38#*/ ##
39function ogGetOsType ()
40{
41# Si se solicita, mostrar ayuda.
42if [ "$*" == "help" ]; then
43    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
44           "$FUNCNAME 1 2  =>  Linux"
45    return
46fi
47ogGetOsVersion "$@" | cut -sf1 -d:
48}
49
50
51#/**
[73c42522]52#         ogGetOsUuid int_ndisk int_nfilesys
53#@brief   Devuelve el UUID del sistema operativo instalado en un sistema de archivos.
54#@param   int_ndisk      nº de orden del disco
55#@param   int_nfilesys   nº de orden de la partición
56#@return  str_uuid -     UUID del sistema operativo.
57#@exception OG_ERR_FORMAT    Formato incorrecto.
58#@exception OG_ERR_NOTFOUND  Disco o partición no corresponden con un dispositiv
59#@version 1.1.0 - Primera versión para OpenGnsys
60#@author  Ramon Gomez, ETSII Universidad de Sevilla
61#@date    2015-09-09
62#*/ ##
63function ogGetOsUuid ()
64{
65# Variables locales.
66local MNTDIR
67# Si se solicita, mostrar ayuda.
68if [ "$*" == "help" ]; then
69    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \
70           "$FUNCNAME 1 2  =>  540e47c6-8e78-4178-aa46-042e4803fb16"
71    return
72fi
73# Error si no se reciben 2 parametros.
74[ $# = 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
75
76# Montar la particion, si no lo estaba previamente.
77MNTDIR=$(ogMount $1 $2) || return $?
78
79# Obtener UUID según el tipo de sistema operativo.
80case "$(ogGetOsType $1 $2)" in
81    Linux)
82        # Leer el UUID del sistema de ficheros raíz o el fichero de identificador.
83        findmnt -no UUID $MNTDIR 2>/dev/null || cat $MNTDIR/etc/machine-id 2>/dev/null
84        ;;
85    Windows)
86        # Leer identificador en clave de registro.
87        ogGetRegistryValue $MNTDIR SOFTWARE '\Microsoft\Cryptography\MachineGuid' 2>/dev/null
88        ;;
89esac
90}
91
92
93#/**
[4d2b852]94#         ogGetOsVersion int_ndisk int_nfilesys
[1d531f9]95#@brief   Devuelve la versión del sistema operativo instalado en un sistema de archivos.
[42669ebf]96#@param   int_ndisk      nº de orden del disco
[4d2b852]97#@param   int_nfilesys   nº de orden de la partición
[f35fadc]98#@return  OSType:OSVersion - tipo y versión del sistema operativo.
[4d2b852]99#@note    OSType = { Android, BSD, GrubLoader, Hurd, Linux, MacOS, Solaris, Windows, WinLoader }
[1d531f9]100#@note    Requisitos: awk, head, chroot
101#@exception OG_ERR_FORMAT    Formato incorrecto.
102#@exception OG_ERR_NOTFOUND  Disco o partición no corresponden con un dispositiv
103#@exception OG_ERR_PARTITION Fallo al montar el sistema de archivos.
[f35fadc]104#@version 0.9 - Primera versión para OpenGnSys
[1d531f9]105#@author  Ramon Gomez, ETSII Universidad de Sevilla
106#@date    2009-09-15
[f35fadc]107#@version 1.0.4 - Incluir tipos BSD, MacOS y Solaris.
108#@author  Ramon Gomez, ETSII Universidad de Sevilla
109#@date    2012-06-29
[4d2b852]110#@version 1.0.5 - Incluir tipos GrubLoader, Hurd y WinLoader, leer por defecto fichero /etc/os-release.
[988438f]111#@author  Ramon Gomez, ETSII Universidad de Sevilla
[6f4e407]112#@date    2013-10-07
[1a2fa9d8]113#@version 1.0.6 - Detectar GrubLoader al final y sistemas basados en EFI.
[5acde60]114#@author  Ramon Gomez, ETSII Universidad de Sevilla
115#@date    2014-08-27
[1e7eaab]116#*/ ##
[42669ebf]117function ogGetOsVersion ()
118{
[1d531f9]119# Variables locales.
[988438f]120local MNTDIR TYPE DISTRIB VERSION IS64BIT FILE
[42669ebf]121# Si se solicita, mostrar ayuda.
[be74e2d]122if [ "$*" == "help" ]; then
[4d2b852]123    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \
124           "$FUNCNAME 1 2  =>  Linux:Ubuntu precise (12.04 LTS) 64 bits"
[1d531f9]125    return
126fi
[42669ebf]127# Error si no se reciben 2 parametros.
[055adcf]128[ $# = 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
[1d531f9]129
130# Montar la particion, si no lo estaba previamente.
131MNTDIR=$(ogMount $1 $2) || return $?
132
[988438f]133# Buscar tipo de sistema operativo.
134# Para GNU/Linux: leer descripción.
135TYPE="Linux"
[825dd06]136FILE="$MNTDIR/etc/os-release"
137[ -r $FILE ] && VERSION="$(awk -F= '$1~/PRETTY_NAME/ {gsub(/\"/,"",$2); print $2}' $FILE)"
[988438f]138# Si no se puede obtener, buscar en ficheros del sistema.
139if [ -z "$VERSION" ]; then
140    FILE="$MNTDIR/etc/lsb-release"
[825dd06]141    [ -r $FILE ] && VERSION="$(awk -F= '$1~/DESCRIPTION/ {gsub(/\"/,"",$2); print $2}' $FILE)"
[988438f]142    for DISTRIB in redhat SuSE mandrake gentoo; do
143        FILE="$MNTDIR/etc/${DISTRIB}-release"
[f35fadc]144        [ -r $FILE ] && VERSION="$(head -1 $FILE)"
[988438f]145    done
146    FILE="$MNTDIR/etc/arch-release"
147    [ -r $FILE ] && VERSION="Arch Linux"
148    FILE="$MNTDIR/etc/slackware-version"
149    [ -r $FILE ] && VERSION="Slackware $(cat $FILE)"
150fi
[825dd06]151# Si no se encuentra, intentar ejecutar "lsb_release".
152[ -z "$VERSION" ] && VERSION=$(chroot $MNTDIR lsb_release -d 2>/dev/null | awk -F":\t" '{print $2}')
153# Comprobar Linux de 64 bits.
154[ -n "$VERSION" ] && [ -e $MNTDIR/lib64 ] && IS64BIT="$MSG_64BIT"
[988438f]155# Para Android, leer fichero de propiedades.
156if [ -z "$VERSION" ]; then
157    TYPE="Android"
158    FILE="$MNTDIR/android*/system/build.prop"
159    [ -r $FILE ] && VERSION="Android $(awk -F= '$1~/(product.brand|build.version.release)/ {print $2}' $FILE | tr '\n' ' ')"
160    [ -e $MNTDIR/lib64 ] && IS64BIT="$MSG_64BIT"
161fi
162# Para GNU/Hurd, comprobar fichero de inicio (basado en os-prober).
163if [ -z "$VERSION" ]; then
164    TYPE="Hurd"
165    FILE="$MNTDIR/hurd/init"
166    [ -r $FILE ] && VERSION="GNU/Hurd"
167fi
168# Para Windows: leer la version del registro.
169if [ -z "$VERSION" ]; then
170    TYPE="Windows"
[58718f5]171    FILE="$(ogGetHivePath $MNTDIR SOFTWARE)"
172    if [ -n "$FILE" ]; then
173        # Nuevo método más rápido para acceder al registro de Windows..
174        VERSION=$(echo $(hivexsh << EOT 2>/dev/null
175load $FILE
176cd \Microsoft\Windows NT\CurrentVersion
177lsval ProductName
178lsval ReleaseId
179EOT
180        ))
181        [ -n "$(reglookup -H -p "Microsoft/Windows/CurrentVersion/ProgramW6432Dir" "$FILE" 2>/dev/null)" ] && IS64BIT="$MSG_64BIT"
182        if [ -z "$VERSION" ]; then
183            # Compatibilidad con métrodo antiguo y más lento de acceder al registro.
184            VERSION=$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows NT\CurrentVersion\ProductName' 2>/dev/null)
185            [ -n "$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows\CurrentVersion\ProgramW6432Dir' 2>/dev/null)" ] && IS64BIT="$MSG_64BIT"
186        fi
187    fi
[988438f]188fi
189# Para cargador Windows: buscar versión en fichero BCD (basado en os-prober).
190if [ -z "$VERSION" ]; then
191    TYPE="WinLoader"
192    FILE="$(ogGetPath $MNTDIR/boot/bcd)"
[1a2fa9d8]193    [ -z "$FILE" ] && FILE="$(ogGetPath $MNTDIR/EFI/Microsoft/boot/bcd)"
[988438f]194    if [ -n "$FILE" ]; then
[1a2fa9d8]195        for DISTRIB in "Windows Recovery" "Windows Boot"; do
[1e4000f]196            if grep -aqs "$(echo "$DISTRIB" | sed 's/./&./g')" $FILE; then
[1a2fa9d8]197                VERSION="$DISTRIB loader"
[988438f]198            fi
199        done
200    fi
201fi
[58718f5]202# Para macOS: detectar kernel y completar con fichero plist de información del sistema.
[988438f]203if [ -z "$VERSION" ]; then
204    TYPE="MacOS"
[045fd2d]205    # Kernel de Mac OS (no debe ser fichero de texto).
[6f4e407]206    FILE="$MNTDIR/mach_kernel"
[045fd2d]207    if [ -z "$(file -b $FILE | grep 'text')" ]; then
208        # Obtener tipo de kernel.
[58718f5]209        [ -n "$(file -b $FILE | grep 'Mach-O')" ] && VERSION="macOS"
[045fd2d]210        [ -n "$(file -b $FILE | grep 'Mach-O 64-bit')" ] && IS64BIT="$MSG_64BIT"
211        # Datos de configuración de versión de Mac OS.
212        FILE="$MNTDIR/System/Library/CoreServices/SystemVersion.plist"
213        [ -r $FILE ] && VERSION=$(awk -F"[<>]" '
214                                      /ProductName/ {getline;s=$3}
215                                      /ProductVersion/ {getline;v=$3}
216                                      END {print s,v}' $FILE)
[58718f5]217        # Datos de recuperación de macOS.
[045fd2d]218        FILE="$MNTDIR/com.apple.recovery.boot"
219        [ -r $FILE -a -n "$VERSION" ] && VERSION="$VERSION recovery"
220    fi
[988438f]221fi
222# Para FreeBSD: obtener datos del Kernel.
223### TODO Revisar solución.
224if [ -z "$VERSION" ]; then
225    TYPE="BSD"
226    FILE="$MNTDIR/boot/kernel/kernel"
227    if [ -r $FILE ]; then
[c7dcb94]228        VERSION="$(strings $FILE|awk '/@.*RELEASE/ {sub(/@\(#\)/,""); print $1,$2}')"
[988438f]229        [ -n "$(file -b $FILE | grep 'x86-64')" ] && IS64BIT="$MSG_64BIT"
230    fi
231fi
232# Para Solaris: leer el fichero de versión.
233### TODO Revisar solución.
234if [ -z "$VERSION" ]; then
235    TYPE="Solaris"
236    FILE="$MNTDIR/etc/release"
237    [ -r $FILE ] && VERSION="$(head -1 $FILE)"
238fi
[5acde60]239# Para cargador GRUB, comprobar fichero de configuración.
240if [ -z "$VERSION" ]; then
241    TYPE="GrubLoader"
242    for FILE in $MNTDIR/{,boot/}grub/menu.lst; do
243        [ -r $FILE ] && VERSION="GRUB Loader"
244    done
245    for FILE in $MNTDIR/{,boot/}{grub{,2},EFI/*}/grub.cfg; do
246        [ -r $FILE ] && VERSION="GRUB2 Loader"
247    done
248fi
[1d531f9]249
[42669ebf]250# Mostrar resultado y salir sin errores.
[988438f]251[ -n "$VERSION" ] && echo "$TYPE:$VERSION $IS64BIT"
[d071d9b]252return 0
[1d531f9]253}
254
255
256#/**
[304533c]257#         ogGetSerialNumber
258#@brief   Obtiene el nº de serie del cliente.
259#@version 1.1.0 - Primeras versión con OpenGnsys
260#@author  Ramon Gomez, ETSII Universidad de Sevilla
261#@date    2015-06-08
262function ogGetSerialNumber ()
263{
264# Si se solicita, mostrar ayuda.
265if [ "$*" == "help" ]; then
266    ogHelp "$FUNCNAME" "$FUNCNAME"
267    return
268fi
269
270# Obtener nº de serie (ignorar los no especificados)
[7a59012]271dmidecode -s system-serial-number | egrep -vi "(^[ 0]+$|not specified|filled by o.e.m.)"
[304533c]272}
273
274
275#/**
[b550747]276#         ogListHardwareInfo
277#@brief   Lista el inventario de hardware de la máquina cliente.
278#@return  TipoDispositivo:Modelo    (por determinar)
279#@warning Se ignoran los parámetros de entrada.
[304533c]280#@note    TipoDispositivo = { bio, boa, bus, cha, cdr, cpu, dis, fir, mem, mod, mul, net, sto, usb, vga }
281#@note    Requisitos: dmidecode, lshw, awk
[f35fadc]282#@version 0.1 - Primeras pruebas con OpenGnSys
[b550747]283#@author  Ramon Gomez, ETSII Universidad de Sevilla
284#@date    2009-07-28
[304533c]285#@version 1.1.0 - Incluir nuevos componentes al inventario.
286#@author  Ramon Gomez, ETSII Universidad de Sevilla
287#@date    2014-04-23
[1e7eaab]288#*/ ##
[42669ebf]289function ogListHardwareInfo ()
290{
291# Si se solicita, mostrar ayuda.
[be74e2d]292if [ "$*" == "help" ]; then
[b550747]293    ogHelp "$FUNCNAME" "$FUNCNAME"
294    return
295fi
296
[aaf5f9f]297# Recopilación de dispositivos procesando la salida de \c lshw
[b550747]298ogEcho info "$MSG_HARDWAREINVENTORY}"
[6dedc02]299echo "cha=$(dmidecode -s chassis-type)" | grep -v "Other"
300[ -e /sys/firmware/efi ] && echo "boo=UEFI" || echo "boo=BIOS"
[b550747]301lshw | awk 'BEGIN {type="mod";}
[304533c]302       /product:/ {sub(/ *product: */,"");  prod=$0;}
303       /vendor:/  {sub(/ *vendor: */,"");   vend=$0;}
304       /version:/ {sub(/ *version: */,"v.");vers=$0;}
305       /size:/    {size=$2;}
306       /clock:/   {clock=$2;}
307       /slot:/    {sub(/ *slot: */,"");     slot=$0;}
308       /\*-/      {if (type=="mem"){
[42d268a4]309                     if (size!=""){
310                       numbank++;
311                       print type"="vend,prod,size,clock" ("slot")";}
[304533c]312                   }else{
[42d268a4]313                     if (type=="totalmem"){
314                       if (size!=""){
315                          totalmemory="mem="size;}
316                     }else{
317                       if (type!="" && prod!=""){
318                         if (prod=="v."vers)
319                           vers="";
320                         print type"="vend,prod,size,vers;} }
[aaf5f9f]321                   }
[304533c]322                   type=prod=vend=vers=size=clock=slot="";}
323       $1~/-core/    {type="boa";}
324       $1~/-firmware/ {type="bio";}
325       $1~/-cpu/     {type="cpu";}
326       $1~/-bank/    {type="mem";}
[aaf5f9f]327       $1~/-memory/  {type="totalmem";}
[304533c]328       $1~/-ide/     {type="ide";}
329       $1~/-storage/ {type="sto";}
330       $1~/-disk/    {type="dis";}
331       $1~/-cdrom/   {type="cdr";}
332       $1~/-display/ {type="vga";}
333       $1~/-network/ {type="net";}
334       $1~/-multimedia/ {type="mul";}
335       $1~/-usb/     {type="usb";}
336       $1~/-firewire/ {type="fir";}
337       $1~/-serial/  {type="bus";}
338       END           {if (type!="" && prod!="")
[aaf5f9f]339                        print type"="vend,prod,size,vers;
[42d268a4]340                      if (length(numbank)==0 && length(totalmemory)>=4)
[aaf5f9f]341                        print totalmemory; }
[b550747]342      '
[42669ebf]343# */ (comentario para Doxygen)
[b550747]344}
345
346
[50a094c]347#/**
[42669ebf]348#         ogListSoftware int_ndisk int_npartition
[50a094c]349#@brief   Lista el inventario de software instalado en un sistema operativo.
[42669ebf]350#@param   int_ndisk      nº de orden del disco
351#@param   int_npartition nº de orden de la partición
352#@return  programa versión ...
[50a094c]353#@warning Se ignoran los parámetros de entrada.
354#@note    Requisitos: ...
355#@todo    Detectar software en Linux
[f35fadc]356#@version 0.1 - Primeras pruebas con OpenGnSys
[50a094c]357#@author  Ramon Gomez, ETSII Universidad de Sevilla
358#@date    2009-09-23
[89a5166]359#@version 1.0.5 - Aproximación para inventario de software de Mac OS.
360#@author  Ramon Gomez, ETSII Universidad de Sevilla
361#@date    2013-10-08
[38e2328]362#@version 1.0.6 - Proceso depende del tipo de SO y soporte para FreeBSD.
[bc2279a]363#@author  Ramon Gomez, ETSII Universidad de Sevilla
364#@date    2014-11-13
[38e2328]365#@version 1.1.0 - Se muestra el sistema operativo en la primera línea de la salida
366#@author  Irina Gomez, ETSII Universidad de Sevilla
367#@date    2016-04-26
[1e7eaab]368#*/ ##
[42669ebf]369function ogListSoftware ()
370{
[50a094c]371# Variables locales.
[2f3d0532]372local MNTDIR TYPE DPKGDIR RPMDIR PACMANDIR k
[50a094c]373
[42669ebf]374# Si se solicita, mostrar ayuda.
[be74e2d]375if [ "$*" == "help" ]; then
[50a094c]376    ogHelp "$FUNCNAME" "$FUNCNAME 1 1"
377    return
378fi
[42669ebf]379# Error si no se reciben 2 parametros.
[50a094c]380[ $# = 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
381
[42669ebf]382# Obtener tipo de sistema de archivos y montarlo.
[50a094c]383MNTDIR=$(ogMount $1 $2) || return $?
[bc2279a]384TYPE=$(ogGetOsType $1 $2) || return $?
[50a094c]385
[38e2328]386# Sistema Operativo en la primera línea de la salida
387ogGetOsVersion $1 $2 | awk -F ':'  '{print $2}'
388
[50a094c]389case "$TYPE" in
[bc2279a]390    Linux)          # Software de GNU/Linux.
[c2b03eb]391        # Procesar paquetes dpkg.
392        DPKGDIR="${MNTDIR}/var/lib/dpkg"
393        if [ -r $DPKGDIR ]; then
394            # Proceso de fichero en sistemas de 64 bits.
[304533c]395            awk '/Package:/ {if (pack!="") print pack,vers;
396                             sub(/-dev$/,"",$2);
397                             pack=$2}
398                 /Version:/ {sub(/^.*:/,"",$2); sub(/-.*$/,"",$2);
399                             vers=$2}
400                 /Status:/  {if ($2!="install") pack=vers=""}
401                 END        {if (pack!="") print pack,vers}
402                ' $DPKGDIR/status | sort | uniq
[c2b03eb]403        fi
404        # Procesar paquetes RPM.
405        RPMDIR="${MNTDIR}/var/lib/rpm"
406        if [ -r $RPMDIR ]; then
[bc2279a]407            # Listar si está instalado el paquete "rpm" en el cliente.
408            if which rpm &>/dev/null; then
409                rm -f ${RPMDIR}/__db.*
410                rpm --dbpath $RPMDIR -qa --qf "%{NAME} %{VERSION}\n" 2>/dev/null | \
411                    awk '$1!~/-devel$/ {sub(/-.*$/,"",$2); print $0}' | sort | uniq
412                rm -f ${RPMDIR}/__db.*
413            else
[246bf13b]414                # Obtener el nombre de cada paquete en la BD de RPM.
415                python <<<"
416import re;
417import bsddb;
418db=bsddb.hashopen('$RPMDIR/Name','r');
419for k in db.keys():
[5cc5560f]420    print re.sub('-devel$','',k);" | sort | uniq
[bc2279a]421            fi
[c2b03eb]422        fi
[2e472ef3]423        # Procesar paquetes pacman.
424        PACMANDIR="${MNTDIR}/var/lib/pacman/local"
425        if [ -r $PACMANDIR ]; then
[526bbf8]426            ls $PACMANDIR | awk -F- '/-/ {print gensub(/-/, " ", NF-2);}'
[2e472ef3]427        fi
[c2b03eb]428        ;;
[bc2279a]429    Windows)        # Software de Windows.
[2f3d0532]430        # Comprobar tipo de proceso del registro de Windows.
431        if which hivexregedit &>/dev/null; then
432            # Nuevo proceso más rápido basado en "hivexregedit".
433            local HIVE TMPFILE
434            HIVE=$(ogGetHivePath $MNTDIR software 2>/dev/null)
435            if [ -n "$HIVE" ]; then
436                # Claves de registro para programas instalados.
437                TMPFILE=/tmp/tmp$$
438                trap "rm -f $TMPFILE" 1 2 3 9 15
439                hivexregedit --unsafe-printable-strings --export "$HIVE" '\Microsoft\Windows\CurrentVersion\Uninstall' > $TMPFILE 2>/dev/null
440                hivexregedit --unsafe-printable-strings --export "$HIVE" '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' >> $TMPFILE 2>/dev/null
441                # Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave.
442                awk -F\" '$1~/^\[/ {n=""}
443                          $2~/DisplayName/ {n=$4}
444                          $2~/DisplayVersion/ {print n,$4}
445                         ' $TMPFILE | sort | uniq
446                rm -f $TMPFILE
[c2b03eb]447            fi
[2f3d0532]448        else
449            # Compatibilidad con clientes ogLive antiguos.
450            local KEYS KEYS32 PROG VERS
451            # Claves de registro para programas instalados: formato "{clave}".
452            KEYS=$(ogListRegistryKeys $MNTDIR software '\Microsoft\Windows\CurrentVersion\Uninstall')
453            KEYS32=$(ogListRegistryKeys $MNTDIR software '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
454            # Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave.
455            (for k in $KEYS; do
456                PROG=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName")
457                if [ -n "$PROG" ]; then
458                    VERS=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion")
459                    echo "$PROG $VERS"
460                fi
461             done
462             for k in $KEYS32; do
463                PROG=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName")
464                if [ -n "$PROG" ]; then
465                    VERS=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion")
466                    echo "$PROG $VERS"
467                fi
468             done) | sort | uniq
469        fi
[c2b03eb]470        ;;
[bc2279a]471    MacOS)          # Software de Mac OS.
[4ff56c5]472        # Listar directorios de aplicaciones e intentar obtener la versión del fichero .plist (tanto original como descomprimido).
[89a5166]473        find "${MNTDIR}/Applications" -type d -name "*.app" -prune -print | \
474                while read k; do
[4ff56c5]475                    FILE="$k/Contents/version.plist"
476                    [ -s "$FILE" ] || FILE="$k/Contents/version.plist.uncompress"
477                    [ -s "$FILE" ] && VERSION=$(awk -F"[<>]" '/ShortVersionString/ {getline;v=$3}
478                                                              END {print v}' "$FILE")
479                    echo "$(basename "$k" .app) $VERSION"
[89a5166]480                done | sort
481        ;;
[bc2279a]482    BSD)            # Software de FreeBSD.
483        sqlite3 $MNTDIR/var/db/pkg/local.sqlite <<<"SELECT name FROM pkg_search;" 2>/dev/null | \
484                sed 's/\(.*\)-\(.*\)/\1 \2/g' | sort
485        ;;
[c2b03eb]486    *)  ogRaiseError $OG_ERR_PARTITION "$1, $2"
[50a094c]487        return $? ;;
488esac
489}
Note: See TracBrowser for help on using the repository browser.