source: client/engine/Inventory.lib @ 8ecc409

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 8ecc409 was 8a2b568, checked in by Ramón M. Gómez <ramongomez@…>, 5 years ago

#920: Remove white spaces when obtaining the client serial number.

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