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