[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] | 20 | function ogGetArch () |
---|
| 21 | { |
---|
| 22 | if [ "$*" == "help" ]; then |
---|
| 23 | ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => x86_64" |
---|
| 24 | return |
---|
| 25 | fi |
---|
| 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 | #*/ ## |
---|
| 39 | function ogGetOsType () |
---|
| 40 | { |
---|
| 41 | # Si se solicita, mostrar ayuda. |
---|
| 42 | if [ "$*" == "help" ]; then |
---|
| 43 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 44 | "$FUNCNAME 1 2 => Linux" |
---|
| 45 | return |
---|
| 46 | fi |
---|
| 47 | ogGetOsVersion "$@" | cut -sf1 -d: |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | #/** |
---|
[4d2b852] | 52 | # ogGetOsVersion int_ndisk int_nfilesys |
---|
[1d531f9] | 53 | #@brief Devuelve la versión del sistema operativo instalado en un sistema de archivos. |
---|
[42669ebf] | 54 | #@param int_ndisk nº de orden del disco |
---|
[4d2b852] | 55 | #@param int_nfilesys nº de orden de la partición |
---|
[f35fadc] | 56 | #@return OSType:OSVersion - tipo y versión del sistema operativo. |
---|
[4d2b852] | 57 | #@note OSType = { Android, BSD, GrubLoader, Hurd, Linux, MacOS, Solaris, Windows, WinLoader } |
---|
[1d531f9] | 58 | #@note Requisitos: awk, head, chroot |
---|
| 59 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 60 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositiv |
---|
| 61 | #@exception OG_ERR_PARTITION Fallo al montar el sistema de archivos. |
---|
[f35fadc] | 62 | #@version 0.9 - Primera versión para OpenGnSys |
---|
[1d531f9] | 63 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 64 | #@date 2009-09-15 |
---|
[f35fadc] | 65 | #@version 1.0.4 - Incluir tipos BSD, MacOS y Solaris. |
---|
| 66 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 67 | #@date 2012-06-29 |
---|
[4d2b852] | 68 | #@version 1.0.5 - Incluir tipos GrubLoader, Hurd y WinLoader, leer por defecto fichero /etc/os-release. |
---|
[988438f] | 69 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[6f4e407] | 70 | #@date 2013-10-07 |
---|
[1a2fa9d8] | 71 | #@version 1.0.6 - Detectar GrubLoader al final y sistemas basados en EFI. |
---|
[5acde60] | 72 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 73 | #@date 2014-08-27 |
---|
[1e7eaab] | 74 | #*/ ## |
---|
[42669ebf] | 75 | function ogGetOsVersion () |
---|
| 76 | { |
---|
[1d531f9] | 77 | # Variables locales. |
---|
[988438f] | 78 | local MNTDIR TYPE DISTRIB VERSION IS64BIT FILE |
---|
[42669ebf] | 79 | # Si se solicita, mostrar ayuda. |
---|
[be74e2d] | 80 | if [ "$*" == "help" ]; then |
---|
[4d2b852] | 81 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \ |
---|
| 82 | "$FUNCNAME 1 2 => Linux:Ubuntu precise (12.04 LTS) 64 bits" |
---|
[1d531f9] | 83 | return |
---|
| 84 | fi |
---|
[42669ebf] | 85 | # Error si no se reciben 2 parametros. |
---|
[055adcf] | 86 | [ $# = 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[1d531f9] | 87 | |
---|
| 88 | # Montar la particion, si no lo estaba previamente. |
---|
| 89 | MNTDIR=$(ogMount $1 $2) || return $? |
---|
| 90 | |
---|
[988438f] | 91 | # Buscar tipo de sistema operativo. |
---|
| 92 | # Para GNU/Linux: leer descripción. |
---|
| 93 | TYPE="Linux" |
---|
[825dd06] | 94 | FILE="$MNTDIR/etc/os-release" |
---|
| 95 | [ -r $FILE ] && VERSION="$(awk -F= '$1~/PRETTY_NAME/ {gsub(/\"/,"",$2); print $2}' $FILE)" |
---|
[988438f] | 96 | # Si no se puede obtener, buscar en ficheros del sistema. |
---|
| 97 | if [ -z "$VERSION" ]; then |
---|
| 98 | FILE="$MNTDIR/etc/lsb-release" |
---|
[825dd06] | 99 | [ -r $FILE ] && VERSION="$(awk -F= '$1~/DESCRIPTION/ {gsub(/\"/,"",$2); print $2}' $FILE)" |
---|
[988438f] | 100 | for DISTRIB in redhat SuSE mandrake gentoo; do |
---|
| 101 | FILE="$MNTDIR/etc/${DISTRIB}-release" |
---|
[f35fadc] | 102 | [ -r $FILE ] && VERSION="$(head -1 $FILE)" |
---|
[988438f] | 103 | done |
---|
| 104 | FILE="$MNTDIR/etc/arch-release" |
---|
| 105 | [ -r $FILE ] && VERSION="Arch Linux" |
---|
| 106 | FILE="$MNTDIR/etc/slackware-version" |
---|
| 107 | [ -r $FILE ] && VERSION="Slackware $(cat $FILE)" |
---|
| 108 | fi |
---|
[825dd06] | 109 | # Si no se encuentra, intentar ejecutar "lsb_release". |
---|
| 110 | [ -z "$VERSION" ] && VERSION=$(chroot $MNTDIR lsb_release -d 2>/dev/null | awk -F":\t" '{print $2}') |
---|
| 111 | # Comprobar Linux de 64 bits. |
---|
| 112 | [ -n "$VERSION" ] && [ -e $MNTDIR/lib64 ] && IS64BIT="$MSG_64BIT" |
---|
[988438f] | 113 | # Para Android, leer fichero de propiedades. |
---|
| 114 | if [ -z "$VERSION" ]; then |
---|
| 115 | TYPE="Android" |
---|
| 116 | FILE="$MNTDIR/android*/system/build.prop" |
---|
| 117 | [ -r $FILE ] && VERSION="Android $(awk -F= '$1~/(product.brand|build.version.release)/ {print $2}' $FILE | tr '\n' ' ')" |
---|
| 118 | [ -e $MNTDIR/lib64 ] && IS64BIT="$MSG_64BIT" |
---|
| 119 | fi |
---|
| 120 | # Para GNU/Hurd, comprobar fichero de inicio (basado en os-prober). |
---|
| 121 | if [ -z "$VERSION" ]; then |
---|
| 122 | TYPE="Hurd" |
---|
| 123 | FILE="$MNTDIR/hurd/init" |
---|
| 124 | [ -r $FILE ] && VERSION="GNU/Hurd" |
---|
| 125 | fi |
---|
| 126 | # Para Windows: leer la version del registro. |
---|
| 127 | if [ -z "$VERSION" ]; then |
---|
| 128 | TYPE="Windows" |
---|
[b762358] | 129 | VERSION=$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows NT\CurrentVersion\ProductName' 2>/dev/null) |
---|
[988438f] | 130 | [ -n "$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows\CurrentVersion\ProgramW6432Dir' 2>/dev/null)" ] && IS64BIT="$MSG_64BIT" |
---|
| 131 | fi |
---|
| 132 | # Para cargador Windows: buscar versión en fichero BCD (basado en os-prober). |
---|
| 133 | if [ -z "$VERSION" ]; then |
---|
| 134 | TYPE="WinLoader" |
---|
| 135 | FILE="$(ogGetPath $MNTDIR/boot/bcd)" |
---|
[1a2fa9d8] | 136 | [ -z "$FILE" ] && FILE="$(ogGetPath $MNTDIR/EFI/Microsoft/boot/bcd)" |
---|
[988438f] | 137 | if [ -n "$FILE" ]; then |
---|
[1a2fa9d8] | 138 | for DISTRIB in "Windows Recovery" "Windows Boot"; do |
---|
[988438f] | 139 | if grep -qs "$(echo "$DISTRIB" | sed 's/./&./g')" $FILE; then |
---|
[1a2fa9d8] | 140 | VERSION="$DISTRIB loader" |
---|
[988438f] | 141 | fi |
---|
| 142 | done |
---|
| 143 | fi |
---|
| 144 | fi |
---|
[6f4e407] | 145 | # Para MacOS: detectar kernel y completar con fichero plist de información del sistema. |
---|
[988438f] | 146 | if [ -z "$VERSION" ]; then |
---|
| 147 | TYPE="MacOS" |
---|
[045fd2d] | 148 | # Kernel de Mac OS (no debe ser fichero de texto). |
---|
[6f4e407] | 149 | FILE="$MNTDIR/mach_kernel" |
---|
[045fd2d] | 150 | if [ -z "$(file -b $FILE | grep 'text')" ]; then |
---|
| 151 | # Obtener tipo de kernel. |
---|
| 152 | [ -n "$(file -b $FILE | grep 'Mach-O')" ] && VERSION="Mac OS" |
---|
| 153 | [ -n "$(file -b $FILE | grep 'Mach-O 64-bit')" ] && IS64BIT="$MSG_64BIT" |
---|
| 154 | # Datos de configuración de versión de Mac OS. |
---|
| 155 | FILE="$MNTDIR/System/Library/CoreServices/SystemVersion.plist" |
---|
| 156 | [ -r $FILE ] && VERSION=$(awk -F"[<>]" ' |
---|
| 157 | /ProductName/ {getline;s=$3} |
---|
| 158 | /ProductVersion/ {getline;v=$3} |
---|
| 159 | END {print s,v}' $FILE) |
---|
| 160 | # Datos de recuperación de Mac OS. |
---|
| 161 | FILE="$MNTDIR/com.apple.recovery.boot" |
---|
| 162 | [ -r $FILE -a -n "$VERSION" ] && VERSION="$VERSION recovery" |
---|
| 163 | fi |
---|
[988438f] | 164 | fi |
---|
| 165 | # Para FreeBSD: obtener datos del Kernel. |
---|
| 166 | ### TODO Revisar solución. |
---|
| 167 | if [ -z "$VERSION" ]; then |
---|
| 168 | TYPE="BSD" |
---|
| 169 | FILE="$MNTDIR/boot/kernel/kernel" |
---|
| 170 | if [ -r $FILE ]; then |
---|
| 171 | VERSION="$(strings $FILE|awk '/@.*RELEASE/ {print $1,$2}')" |
---|
| 172 | [ -n "$(file -b $FILE | grep 'x86-64')" ] && IS64BIT="$MSG_64BIT" |
---|
| 173 | fi |
---|
| 174 | fi |
---|
| 175 | # Para Solaris: leer el fichero de versión. |
---|
| 176 | ### TODO Revisar solución. |
---|
| 177 | if [ -z "$VERSION" ]; then |
---|
| 178 | TYPE="Solaris" |
---|
| 179 | FILE="$MNTDIR/etc/release" |
---|
| 180 | [ -r $FILE ] && VERSION="$(head -1 $FILE)" |
---|
| 181 | fi |
---|
[5acde60] | 182 | # Para cargador GRUB, comprobar fichero de configuración. |
---|
| 183 | if [ -z "$VERSION" ]; then |
---|
| 184 | TYPE="GrubLoader" |
---|
| 185 | for FILE in $MNTDIR/{,boot/}grub/menu.lst; do |
---|
| 186 | [ -r $FILE ] && VERSION="GRUB Loader" |
---|
| 187 | done |
---|
| 188 | for FILE in $MNTDIR/{,boot/}{grub{,2},EFI/*}/grub.cfg; do |
---|
| 189 | [ -r $FILE ] && VERSION="GRUB2 Loader" |
---|
| 190 | done |
---|
| 191 | fi |
---|
[1d531f9] | 192 | |
---|
[42669ebf] | 193 | # Mostrar resultado y salir sin errores. |
---|
[988438f] | 194 | [ -n "$VERSION" ] && echo "$TYPE:$VERSION $IS64BIT" |
---|
[d071d9b] | 195 | return 0 |
---|
[1d531f9] | 196 | } |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | #/** |
---|
[304533c] | 200 | # ogGetSerialNumber |
---|
| 201 | #@brief Obtiene el nº de serie del cliente. |
---|
| 202 | #@version 1.1.0 - Primeras versión con OpenGnsys |
---|
| 203 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 204 | #@date 2015-06-08 |
---|
| 205 | function ogGetSerialNumber () |
---|
| 206 | { |
---|
| 207 | # Si se solicita, mostrar ayuda. |
---|
| 208 | if [ "$*" == "help" ]; then |
---|
| 209 | ogHelp "$FUNCNAME" "$FUNCNAME" |
---|
| 210 | return |
---|
| 211 | fi |
---|
| 212 | |
---|
| 213 | # Obtener nº de serie (ignorar los no especificados) |
---|
| 214 | dmidecode -s system-serial-number | egrep -vi "(not specified|filled by o.e.m.)" |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | #/** |
---|
[b550747] | 219 | # ogListHardwareInfo |
---|
| 220 | #@brief Lista el inventario de hardware de la máquina cliente. |
---|
| 221 | #@return TipoDispositivo:Modelo (por determinar) |
---|
| 222 | #@warning Se ignoran los parámetros de entrada. |
---|
[304533c] | 223 | #@note TipoDispositivo = { bio, boa, bus, cha, cdr, cpu, dis, fir, mem, mod, mul, net, sto, usb, vga } |
---|
| 224 | #@note Requisitos: dmidecode, lshw, awk |
---|
[f35fadc] | 225 | #@version 0.1 - Primeras pruebas con OpenGnSys |
---|
[b550747] | 226 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 227 | #@date 2009-07-28 |
---|
[304533c] | 228 | #@version 1.1.0 - Incluir nuevos componentes al inventario. |
---|
| 229 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 230 | #@date 2014-04-23 |
---|
[1e7eaab] | 231 | #*/ ## |
---|
[42669ebf] | 232 | function ogListHardwareInfo () |
---|
| 233 | { |
---|
| 234 | # Si se solicita, mostrar ayuda. |
---|
[be74e2d] | 235 | if [ "$*" == "help" ]; then |
---|
[b550747] | 236 | ogHelp "$FUNCNAME" "$FUNCNAME" |
---|
| 237 | return |
---|
| 238 | fi |
---|
| 239 | |
---|
[42669ebf] | 240 | # Recopilación de disposibivos procesando la salida de \c lshw |
---|
[b550747] | 241 | ogEcho info "$MSG_HARDWAREINVENTORY}" |
---|
[304533c] | 242 | echo "cha=$(dmidecode -s chassis-type)" |
---|
[b550747] | 243 | lshw | awk 'BEGIN {type="mod";} |
---|
[304533c] | 244 | /product:/ {sub(/ *product: */,""); prod=$0;} |
---|
| 245 | /vendor:/ {sub(/ *vendor: */,""); vend=$0;} |
---|
| 246 | /version:/ {sub(/ *version: */,"v.");vers=$0;} |
---|
| 247 | /size:/ {size=$2;} |
---|
| 248 | /clock:/ {clock=$2;} |
---|
| 249 | /slot:/ {sub(/ *slot: */,""); slot=$0;} |
---|
| 250 | /\*-/ {if (type=="mem"){ |
---|
| 251 | if (size!="") |
---|
| 252 | print type"="vend,prod,size,clock" ("slot")"; |
---|
| 253 | }else{ |
---|
| 254 | if (type!="" && prod!=""){ |
---|
| 255 | if (prod=="v."vers) |
---|
| 256 | vers=""; |
---|
| 257 | print type"="vend,prod,size,vers;} } |
---|
| 258 | type=prod=vend=vers=size=clock=slot="";} |
---|
| 259 | $1~/-core/ {type="boa";} |
---|
| 260 | $1~/-firmware/ {type="bio";} |
---|
| 261 | $1~/-cpu/ {type="cpu";} |
---|
| 262 | $1~/-bank/ {type="mem";} |
---|
| 263 | $1~/-ide/ {type="ide";} |
---|
| 264 | $1~/-storage/ {type="sto";} |
---|
| 265 | $1~/-disk/ {type="dis";} |
---|
| 266 | $1~/-cdrom/ {type="cdr";} |
---|
| 267 | $1~/-display/ {type="vga";} |
---|
| 268 | $1~/-network/ {type="net";} |
---|
| 269 | $1~/-multimedia/ {type="mul";} |
---|
| 270 | $1~/-usb/ {type="usb";} |
---|
| 271 | $1~/-firewire/ {type="fir";} |
---|
| 272 | $1~/-serial/ {type="bus";} |
---|
| 273 | END {if (type!="" && prod!="") |
---|
| 274 | print type"="vend,prod,size,vers;} |
---|
[b550747] | 275 | ' |
---|
[42669ebf] | 276 | # */ (comentario para Doxygen) |
---|
[b550747] | 277 | } |
---|
| 278 | |
---|
| 279 | |
---|
[50a094c] | 280 | #/** |
---|
[42669ebf] | 281 | # ogListSoftware int_ndisk int_npartition |
---|
[50a094c] | 282 | #@brief Lista el inventario de software instalado en un sistema operativo. |
---|
[42669ebf] | 283 | #@param int_ndisk nº de orden del disco |
---|
| 284 | #@param int_npartition nº de orden de la partición |
---|
| 285 | #@return programa versión ... |
---|
[50a094c] | 286 | #@warning Se ignoran los parámetros de entrada. |
---|
| 287 | #@note Requisitos: ... |
---|
| 288 | #@todo Detectar software en Linux |
---|
[f35fadc] | 289 | #@version 0.1 - Primeras pruebas con OpenGnSys |
---|
[50a094c] | 290 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 291 | #@date 2009-09-23 |
---|
[89a5166] | 292 | #@version 1.0.5 - Aproximación para inventario de software de Mac OS. |
---|
| 293 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 294 | #@date 2013-10-08 |
---|
[bc2279a] | 295 | #@version 1.0.6 - Proceso depende del tipo de SO y sporte para FreeBSD. |
---|
| 296 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 297 | #@date 2014-11-13 |
---|
[1e7eaab] | 298 | #*/ ## |
---|
[42669ebf] | 299 | function ogListSoftware () |
---|
| 300 | { |
---|
[50a094c] | 301 | # Variables locales. |
---|
[e4dafd6] | 302 | local MNTDIR TYPE DPKGDIR RPMDIR PACMANDIR KEYS KEYS32 k PROG VERS |
---|
[50a094c] | 303 | |
---|
[42669ebf] | 304 | # Si se solicita, mostrar ayuda. |
---|
[be74e2d] | 305 | if [ "$*" == "help" ]; then |
---|
[50a094c] | 306 | ogHelp "$FUNCNAME" "$FUNCNAME 1 1" |
---|
| 307 | return |
---|
| 308 | fi |
---|
[42669ebf] | 309 | # Error si no se reciben 2 parametros. |
---|
[50a094c] | 310 | [ $# = 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 311 | |
---|
[42669ebf] | 312 | # Obtener tipo de sistema de archivos y montarlo. |
---|
[50a094c] | 313 | MNTDIR=$(ogMount $1 $2) || return $? |
---|
[bc2279a] | 314 | TYPE=$(ogGetOsType $1 $2) || return $? |
---|
[50a094c] | 315 | |
---|
| 316 | case "$TYPE" in |
---|
[bc2279a] | 317 | Linux) # Software de GNU/Linux. |
---|
[c2b03eb] | 318 | # Procesar paquetes dpkg. |
---|
| 319 | DPKGDIR="${MNTDIR}/var/lib/dpkg" |
---|
| 320 | if [ -r $DPKGDIR ]; then |
---|
| 321 | # Proceso de fichero en sistemas de 64 bits. |
---|
[304533c] | 322 | awk '/Package:/ {if (pack!="") print pack,vers; |
---|
| 323 | sub(/-dev$/,"",$2); |
---|
| 324 | pack=$2} |
---|
| 325 | /Version:/ {sub(/^.*:/,"",$2); sub(/-.*$/,"",$2); |
---|
| 326 | vers=$2} |
---|
| 327 | /Status:/ {if ($2!="install") pack=vers=""} |
---|
| 328 | END {if (pack!="") print pack,vers} |
---|
| 329 | ' $DPKGDIR/status | sort | uniq |
---|
[c2b03eb] | 330 | fi |
---|
| 331 | # Procesar paquetes RPM. |
---|
| 332 | RPMDIR="${MNTDIR}/var/lib/rpm" |
---|
| 333 | if [ -r $RPMDIR ]; then |
---|
[bc2279a] | 334 | # Listar si está instalado el paquete "rpm" en el cliente. |
---|
| 335 | if which rpm &>/dev/null; then |
---|
| 336 | rm -f ${RPMDIR}/__db.* |
---|
| 337 | rpm --dbpath $RPMDIR -qa --qf "%{NAME} %{VERSION}\n" 2>/dev/null | \ |
---|
| 338 | awk '$1!~/-devel$/ {sub(/-.*$/,"",$2); print $0}' | sort | uniq |
---|
| 339 | rm -f ${RPMDIR}/__db.* |
---|
| 340 | else |
---|
[246bf13b] | 341 | # Obtener el nombre de cada paquete en la BD de RPM. |
---|
| 342 | python <<<" |
---|
| 343 | import re; |
---|
| 344 | import bsddb; |
---|
| 345 | db=bsddb.hashopen('$RPMDIR/Name','r'); |
---|
| 346 | for k in db.keys(): |
---|
[5cc5560f] | 347 | print re.sub('-devel$','',k);" | sort | uniq |
---|
[bc2279a] | 348 | fi |
---|
[c2b03eb] | 349 | fi |
---|
[2e472ef3] | 350 | # Procesar paquetes pacman. |
---|
| 351 | PACMANDIR="${MNTDIR}/var/lib/pacman/local" |
---|
| 352 | if [ -r $PACMANDIR ]; then |
---|
| 353 | # FIXME Separar nombre y versión de los paquetes |
---|
| 354 | ls -A $PACMANDIR |
---|
| 355 | fi |
---|
[c2b03eb] | 356 | ;; |
---|
[bc2279a] | 357 | Windows) # Software de Windows. |
---|
[c2b03eb] | 358 | # Claves de registro para programas instalados: formato "{clave}". |
---|
| 359 | KEYS=$(ogListRegistryKeys $MNTDIR software '\Microsoft\Windows\CurrentVersion\Uninstall') |
---|
[180f43e] | 360 | KEYS32=$(ogListRegistryKeys $MNTDIR software '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') |
---|
[c2b03eb] | 361 | # Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave. |
---|
| 362 | (for k in $KEYS; do |
---|
| 363 | PROG=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName") |
---|
| 364 | if [ -n "$PROG" ]; then |
---|
| 365 | VERS=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion") |
---|
| 366 | echo "$PROG $VERS" |
---|
| 367 | fi |
---|
[180f43e] | 368 | done |
---|
| 369 | for k in $KEYS32; do |
---|
| 370 | PROG=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName") |
---|
| 371 | if [ -n "$PROG" ]; then |
---|
| 372 | VERS=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion") |
---|
| 373 | echo "$PROG $VERS" |
---|
| 374 | fi |
---|
[c2b03eb] | 375 | done) | sort | uniq |
---|
| 376 | ;; |
---|
[bc2279a] | 377 | MacOS) # Software de Mac OS. |
---|
[4ff56c5] | 378 | # Listar directorios de aplicaciones e intentar obtener la versión del fichero .plist (tanto original como descomprimido). |
---|
[89a5166] | 379 | find "${MNTDIR}/Applications" -type d -name "*.app" -prune -print | \ |
---|
| 380 | while read k; do |
---|
[4ff56c5] | 381 | FILE="$k/Contents/version.plist" |
---|
| 382 | [ -s "$FILE" ] || FILE="$k/Contents/version.plist.uncompress" |
---|
| 383 | [ -s "$FILE" ] && VERSION=$(awk -F"[<>]" '/ShortVersionString/ {getline;v=$3} |
---|
| 384 | END {print v}' "$FILE") |
---|
| 385 | echo "$(basename "$k" .app) $VERSION" |
---|
[89a5166] | 386 | done | sort |
---|
| 387 | ;; |
---|
[bc2279a] | 388 | BSD) # Software de FreeBSD. |
---|
| 389 | sqlite3 $MNTDIR/var/db/pkg/local.sqlite <<<"SELECT name FROM pkg_search;" 2>/dev/null | \ |
---|
| 390 | sed 's/\(.*\)-\(.*\)/\1 \2/g' | sort |
---|
| 391 | ;; |
---|
[c2b03eb] | 392 | *) ogRaiseError $OG_ERR_PARTITION "$1, $2" |
---|
[50a094c] | 393 | return $? ;; |
---|
| 394 | esac |
---|
| 395 | } |
---|
| 396 | |
---|
[bc2279a] | 397 | |
---|
[be74e2d] | 398 | #/** @function ogInfoCache: @brief muestra la informacion de la CACHE. |
---|
| 399 | #@param sin parametros |
---|
| 400 | #@return texto que se almacena en $IP.-InfoCache. punto_montaje, tama?oTotal, TamanioOcupado, TaminioLibre, imagenes dentro de la cahce |
---|
| 401 | #@warning Salidas de errores no determinada |
---|
| 402 | #@warning printf no soportado por busybox |
---|
| 403 | #@attention |
---|
| 404 | #@version 0.1 Date: 27/10/2008 Author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 405 | #*/ |
---|
[e4dafd6] | 406 | function ogInfoCache () |
---|
| 407 | { |
---|
| 408 | local info infoFilesystem infoSize infoUsed infoUsedPorcet infoMountedOn content |
---|
[be74e2d] | 409 | if ogMountCache |
---|
| 410 | then |
---|
| 411 | info=`df -h | grep $OGCAC` |
---|
| 412 | infoFilesystem=`echo $info | cut -f1 -d" "` |
---|
| 413 | infoSize=`echo $info | cut -f2 -d" "` |
---|
| 414 | infoUsed=`echo $info | cut -f3 -d" "` |
---|
| 415 | infoAvail=`echo $info | cut -f4 -d" "` |
---|
| 416 | infoUsedPorcet=`echo $info | cut -f5 -d" "` |
---|
| 417 | infoMountedOn=`echo $info | cut -f2 -d" "` |
---|
| 418 | if `ls ${OGCAC}$OGIMG > /dev/null 2>&1` |
---|
| 419 | then |
---|
| 420 | cd ${OGCAC}${OPENGNSYS} |
---|
| 421 | #content=`find images/ -type f -printf "%h/ %f %s \n"` busybox no soporta printf |
---|
| 422 | content=`find images/ -type f` |
---|
| 423 | cd / |
---|
| 424 | echo $info |
---|
| 425 | echo -ne $content |
---|
| 426 | echo " " |
---|
| 427 | #echo "$info" > ${OGLOG}/${IP}-InfoCache |
---|
| 428 | #echo "$content" >> {$OGLOG}/${IP}-InfoCache |
---|
| 429 | else |
---|
| 430 | echo $info |
---|
| 431 | #echo "$info" > {$OGLOG}/${IP}-InfoCache |
---|
| 432 | fi |
---|
| 433 | ogUnmountCache |
---|
| 434 | else |
---|
| 435 | echo " " |
---|
| 436 | #echo " " > {$OGLOG}/${IP}-InfoCache |
---|
| 437 | |
---|
| 438 | fi |
---|
| 439 | } |
---|
[e4dafd6] | 440 | |
---|