source: server/bin/listclientmode @ 1f6fd06

918-git-images-111dconfigure-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 1f6fd06 was 5d28f39, checked in by ramon <ramongomez@…>, 8 years ago

#768: Nuevos scripts listclientlive y setclientlive para listar y asignar clientes ogLive.

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

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#!/bin/bash
2# listclientmode: Lista la plantilla de arranque PXE para los clientes,
3#       ya sea un equipo o un aula.
4# Nota: Si no existe un enlace entre el fichero PXE con la Ethernet del equipo y su
5#        archivo plantilla, se considera que la plantilla por omisión es "default".
6# Uso:  listclienmode NombrePC | NombreAula
7# Autores: Irina Gomez y Ramon Gomez - Univ. Sevilla, noviembre 2010
8
9
10# Variables.
11PROG=$(basename $0)
12OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
13SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg
14TMPLDIR=$OPENGNSYS/tftpboot/menu.lst/templates
15MYCNF=/tmp/.my.cnf.$$
16
17# Control básico de errores.
18if [ $# -ne 1 ]; then
19        echo "$PROG: Error de ejecución"
20        echo "Formato: $PROG [NOMBRE_PC|NOMBRE_AULA]"
21        exit 1
22fi
23if [ ! -r $SERVERCONF ]; then
24        echo "$PROG: Sin acceso a fichero de configuración"
25        exit 2
26fi
27
28# Obtener datos de acceso a la Base de datos.
29source $SERVERCONF
30# Sustituir caracteres ' por \' para evitar inyección SQL.
31RESOURCE="${1//\'/\'}"
32# Componer fichero con credenciales de conexión.
33touch $MYCNF
34chmod 600 $MYCNF
35cat << EOT > $MYCNF
36[client]
37user=$USUARIO
38password=$PASSWORD
39EOT
40# Borrar el fichero temporal si termina el proceso.
41trap "rm -f $MYCNF" 0 1 2 3 6 9 15
42# Obtener nombre de ordenador individual o todos los de una aula e indicar su plantilla asociada.
43mysql --defaults-extra-file=$MYCNF -D "$CATALOG" -s -N -e \
44                "SELECT nombreordenador, arranque FROM ordenadores
45                   JOIN aulas USING (idaula)
46                  WHERE aulas.nombreaula='$RESOURCE'
47                     OR nombreordenador='$RESOURCE';" | \
48        while read PC TMPL; do
49                echo "Equipo \"$PC\" asociado a arranque tipo \"$(head -1 $TMPLDIR/$TMPL |cut -f2 -d" ")\" (fichero $TMPL)"
50        done
51
Note: See TracBrowser for help on using the repository browser.