close Warning: Failed to sync with repository "ogBrowser-Git": (1366, "Incorrect string value: '\\xF0\\x9F\\x93\\xA6 I...' for column 'message' at row 1"); repository information may be out of date. Look in the Trac log for more information including mitigation strategies.

source: server/bin/registeredsoftware @ 279dcb69

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 279dcb69 was 5cfec97, checked in by ramon <ramongomez@…>, 13 years ago

#638: Script registeredsoftware que accede a la BD para listar los programas detectados en el perfil de software asocado a una imagen.

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

  • Property mode set to 100755
File size: 1.9 KB
Line 
1#!/bin/bash
2#         registeredsoftware str_image
3#@file    registeredsoftware
4#@brief   Lista el software instalado en una imagen de sistema.
5#@param   str_image     Nombre canónico de la imagen.
6#@return  Líneas con el formato:   programa versión
7#@version 1.0 - Creación del script.
8#@author  Ramón Gómez - Univ. Sevilla
9#@date    2014-02-27
10
11
12# Variables.
13PROG=$(basename $0)
14OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
15SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg
16MYCNF=/tmp/.my.cnf.$$
17
18# Si se solicita, mostrar ayuda.
19if [ "$*" == "help" ]; then
20        echo "$PROG: Lista el software instalado en una imagen de sistema."
21        echo "Formato: $PROG str_image"
22        exit 0
23fi
24
25# Control básico de errores.
26if [ $# -ne 1 ]; then
27        echo "$PROG Error: Formato: $PROG str_image" >&2
28        exit 1
29fi
30if [ ! -r $SERVERCONF ]; then
31        echo "$PROG: Sin acceso a fichero de configuración"
32        exit 2
33fi
34
35# Sustituir caracteres ' por \' para evitar inyección SQL.
36RESOURCE="${1//\'/\'}"
37
38# Obtener datos de acceso a la base de datos.
39source $SERVERCONF
40
41# Componer fichero con credenciales de conexión a la base de datos.
42touch $MYCNF
43chmod 600 $MYCNF
44cat << EOT > $MYCNF
45[client]
46user=$USUARIO
47password=$PASSWORD
48EOT
49
50# Borrar el fichero temporal si termina el proceso.
51trap "rm -f $MYCNF" 0 1 2 3 6 9 15
52
53# Obtener lista de componentes del perfil de software asociado a la imagen.
54mysql --defaults-extra-file=$MYCNF -D "$CATALOG" -s -N -e \
55                "SELECT softwares.descripcion
56                   FROM perfilessoft
57        LEFT OUTER JOIN perfilessoft_softwares ON perfilessoft.idperfilsoft=perfilessoft_softwares.idperfilsoft
58        LEFT OUTER JOIN softwares ON softwares.idsoftware=perfilessoft_softwares.idsoftware
59        LEFT OUTER JOIN tiposoftwares ON softwares.idtiposoftware=tiposoftwares.idtiposoftware
60        LEFT OUTER JOIN imagenes ON perfilessoft.idperfilsoft=imagenes.idperfilsoft
61                  WHERE imagenes.nombreca='$RESOURCE'
62               ORDER BY tiposoftwares.idtiposoftware,softwares.descripcion;"
63
Note: See TracBrowser for help on using the repository browser.