source: client/engine/Inventory.lib @ 202d6a3

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-instalacion
Last change on this file since 202d6a3 was c0c7fa3, checked in by Ramón M. Gómez <ramongomez@…>, 6 years ago

#920: Truncate a long serial number.

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