source: server/bin/setclientmode @ fa43c91

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 fa43c91 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.3 KB
RevLine 
[61dbabb]1#!/bin/bash
[b5aae72]2# setclientmode: Configura el archivo de arranque de PXE para los clientes,
[61dbabb]3#       ya sea un equipo o un aula, generando enlaces a archivos usados como plantilla.
4# Nota: El archivo PXE por defecto "default" se deja en modo de ejecución "user"
5#       y se eliminan los enlaces para equipos con la plantilla por defecto.
[b5aae72]6# Uso:  clienmode NombrePlatilla { 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
14PXEDIR=$OPENGNSYS/tftpboot/pxelinux.cfg
15LOGFILE=$OPENGNSYS/log/opengnsys.log
16
17# Control básico de errores.
18if [ $# -ne 2 ]; then
19        echo "$PROG: Error de ejecución"
20        echo "Formato: $PROG Archivo_platilla [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
27if [ ! -e $PXEDIR/"$1" ]; then
28        echo "No existe archivo platilla: $PXEDIR/$1"
29        exit
30fi
31
32# Obtener datos de acceso a la Base de datos.
33source $SERVERCONF
34# Comprobar si se recibe nombre de aula o de equipo.
35IDAULA=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
36                "SELECT idaula FROM aulas WHERE nombreaula=\"$2\";")
37
38if [ -n "$IDAULA" ]; then
39        # Aula encontrada
40        ETHERNET=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
41                "SELECT mac FROM ordenadores WHERE idaula=\"$IDAULA\";")
42else
43        # Buscar ordenador
44        ETHERNET=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
45                "SELECT mac FROM ordenadores WHERE nombreordenador=\"$2\";")
46fi
47if [ -z "$ETHERNET" ]; then
48        date +"%b %d %T $PROG: No existe aula o equipo con el nombre \"$2\"" | tee -a $LOGFILE
49        exit 1
50fi
51
52# Creamos los enlaces
53# PXE no permite enlaces simbolicos y las letras han de ir en minuscula
54date +"%b %d %T $PROG: Configurando \"$1\" en \"$2\"" | tee -a $LOGFILE
55NPC=0
56for AUX in $ETHERNET; do
57        date +"%b %d %T $PROG: Detectada ethernet \"$AUX\" en \"$2\"" | tee -a $LOGFILE
58        AUX=$(echo $AUX | awk '{print tolower($0)}')
59        AUX="01-${AUX:0:2}-${AUX:2:2}-${AUX:4:2}-${AUX:6:2}-${AUX:8:2}-${AUX:10:2}"
60        # Si existe anteriormente lo borra
61        [ -e $PXEDIR/$AUX ] && rm $PXEDIR/$AUX
62        if [ "$1" != "default" ]; then
63                ln $PXEDIR/"$1" $PXEDIR/$AUX
64        fi
65        let NPC=NPC+1
66done
67date +"%b %d %T $PROG: $NPC equipo(s) configurado(s)" | tee -a $LOGFILE
68
Note: See TracBrowser for help on using the repository browser.