source: server/bin/listclientlive @ bd4a17f

918-git-images-111dID-1020_logrotateBugID-1037_Mostrar.TipoDisco.WebID-1038_Muestra.el.numero.de.ordenadoresID-1039_Asignar_Disco.Particion.Imagen.AccesoRemotoID-824_Iniciar.Sistema.Restauradodevel-ogadmserver-for-masterdisk-imagemainmaster-1037opengnsys-1.1.1dpreqndtest
Last change on this file since bd4a17f was 7c841bd, checked in by ramon <ramongomez@…>, 7 years ago

#768: Adaptar nuevos cambios a scripts listclientlive y setclientlive.

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

  • Property mode set to 100755
File size: 1.5 KB
Line 
1#!/bin/bash
2# listclientlive: Lista la distribución ogLive asociada a los clientes,
3#       ya sea un equipo o un aula.
4# Uso:  listclienlive NombrePC | NombreAula
5# Autor: Ramón M. Gómez - Univ. Sevilla, junio 2017
6
7
8# Variables.
9PROG=$(basename "$0")
10OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
11SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg
12TFTPDIR=$OPENGNSYS/tftpboot
13MYCNF=/tmp/.my.cnf.$$
14
15# Control básico de errores.
16if [ $# -ne 1 ]; then
17        echo "$PROG: Error de ejecución" >&2
18        echo "Formato: $PROG [NOMBRE_PC|NOMBRE_AULA]" >&2
19        exit 1
20fi
21if [ ! -r $SERVERCONF ]; then
22        echo "$PROG: Sin acceso a fichero de configuración" >&2
23        exit 2
24fi
25
26# Obtener datos de acceso a la Base de datos.
27source $SERVERCONF
28# Sustituir caracteres ' por \' para evitar inyección SQL.
29RESOURCE="${1//\'/\'}"
30# Componer fichero con credenciales de conexión.
31touch $MYCNF
32chmod 600 $MYCNF
33cat << EOT > $MYCNF
34[client]
35user=$USUARIO
36password=$PASSWORD
37EOT
38# Borrar el fichero temporal si termina el proceso.
39trap "rm -f $MYCNF" 0 1 2 3 6 9 15
40# Obtener nombre de ordenador individual o todos los de una aula e indicar su plantilla asociada.
41mysql --defaults-extra-file="$MYCNF" -D "$CATALOG" -s -N -e \
42                "SELECT ord.nombreordenador, ord.oglivedir
43                   FROM ordenadores AS ord
44                   JOIN aulas USING (idaula)
45                  WHERE aulas.nombreaula='$RESOURCE'
46                     OR ord.nombreordenador='$RESOURCE';" | \
47        while read -r PC OGLIVE; do
48                echo "Equipo \"$PC\" asociado a cliente \"$OGLIVE\"  $([ -e $TFTPDIR/$OGLIVE ] || echo "(inexistente)")"
49        done
50
Note: See TracBrowser for help on using the repository browser.