source: server/bin/listclientmode @ 9e27287

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 9e27287 was b5aae72, checked in by ramon <ramongomez@…>, 14 years ago

Creadas 2 plantillas PXE: modo "user" (por defecto) y modo "admin".
Modificados los nombres de scripts para gestión de plantillas a listclientmode y setclientmode.
Modificado instalador para copiar las plantillas y los scripts.
Close #260.

git-svn-id: https://opengnsys.es/svn/trunk@1352 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.0 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
14PXEDIR=$OPENGNSYS/tftpboot/pxelinux.cfg
15
16# Control básico de errores.
17if [ $# -ne 1 ]; then
18        echo "$PROG: Error de ejecución"
19        echo "Formato: $PROG [NOMBRE_PC|NOMBRE_AULA]"
20        exit 1
21fi
22if [ ! -r $SERVERCONF ]; then
23        echo "$PROG: Sin acceso a fichero de configuración"
24        exit 2
25fi
26
27# Obtener datos de acceso a la Base de datos.
28source $SERVERCONF
29# Comprobar si se recibe nombre de aula o de equipo.
30IDAULA=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
31                "SELECT idaula FROM aulas WHERE nombreaula='$1';")
32
33if [ -n "$IDAULA" ]; then
34        # Aula encontrada
35        ETHERNET=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
36                "SELECT mac FROM ordenadores WHERE idaula='$IDAULA';")
37else
38        # Buscar ordenador
39        ETHERNET=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
40                "SELECT mac FROM ordenadores WHERE nombreordenador='$1';")
41fi
42if [ -z "$ETHERNET" ]; then
43        echo "$PROG: No existe ningun aula o equipo con el nombre \"$1\""
44        exit 1
45fi
46
47for ETH in $ETHERNET; do
48        AUX=$(echo $ETH | awk '{print tolower($0)}')
49        AUX="01-${AUX:0:2}-${AUX:2:2}-${AUX:4:2}-${AUX:6:2}-${AUX:8:2}-${AUX:10:2}"
50        PCNAME=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
51                "SELECT nombreordenador FROM ordenadores WHERE mac='$ETH';")
52        if [ -f $PXEDIR/$AUX ]; then
53                INODE=$(ls -i $PXEDIR/$AUX | cut -f1 -d" ")
54                TMPL=$(ls -i $PXEDIR | grep $INODE | grep -v "01-" | cut -f2 -d" ")
55                [ -z "$TMPL" ] && TMPL="default"
56        else
57                TMPL="default"
58        fi
59        echo "Equipo $PCNAME ($ETH) asociado a plantilla \"$TMPL\""
60done
61
Note: See TracBrowser for help on using the repository browser.