source: server/bin/listclientmode @ f5aad83

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 f5aad83 was 7710a99, checked in by ramon <ramongomez@…>, 11 years ago

#664: comando listclientmode muestra tanto el nombre de plantilla PXE como el de su fichero asociado; mejorar el rendimiento del script setclientmode

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

  • Property mode set to 100755
File size: 1.6 KB
RevLine 
[61dbabb]1#!/bin/bash
[b5aae72]2# listclientmode: Lista la plantilla de arranque PXE para los clientes,
[61dbabb]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".
[b5aae72]6# Uso:  listclienmode NombrePC | NombreAula
[61dbabb]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
[7710a99]14TMPLDIR=$OPENGNSYS/tftpboot/menu.lst/templates
[d1d41ad]15MYCNF=/tmp/.my.cnf.$$
[61dbabb]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
[75f9c01]30# Sustituir caracteres ' por \' para evitar inyección SQL.
31RESOURCE="${1//\'/\'}"
[d1d41ad]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.
[9d380ec]43mysql --defaults-extra-file=$MYCNF -D "$CATALOG" -s -N -e \
[d1d41ad]44                "SELECT nombreordenador, arranque FROM ordenadores
45                   JOIN aulas USING (idaula)
46                  WHERE aulas.nombreaula='$RESOURCE'
47                     OR nombreordenador='$RESOURCE';" | \
[7710a99]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
[61dbabb]51
Note: See TracBrowser for help on using the repository browser.