close
Warning:
Failed to sync with repository "ogBrowser-Git": (1366, "Incorrect string value: '\\xF0\\x9F\\x93\\xA6 I...' for column 'message' at row 1"); repository information may be out of date. Look in the Trac log for more information including mitigation strategies.
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
| 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. |
|---|
| 11 | PROG=$(basename $0) |
|---|
| 12 | OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"} |
|---|
| 13 | SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg |
|---|
| 14 | TMPLDIR=$OPENGNSYS/tftpboot/menu.lst/templates |
|---|
| 15 | MYCNF=/tmp/.my.cnf.$$ |
|---|
| 16 | |
|---|
| 17 | # Control básico de errores. |
|---|
| 18 | if [ $# -ne 1 ]; then |
|---|
| 19 | echo "$PROG: Error de ejecución" |
|---|
| 20 | echo "Formato: $PROG [NOMBRE_PC|NOMBRE_AULA]" |
|---|
| 21 | exit 1 |
|---|
| 22 | fi |
|---|
| 23 | if [ ! -r $SERVERCONF ]; then |
|---|
| 24 | echo "$PROG: Sin acceso a fichero de configuración" |
|---|
| 25 | exit 2 |
|---|
| 26 | fi |
|---|
| 27 | |
|---|
| 28 | # Obtener datos de acceso a la Base de datos. |
|---|
| 29 | source $SERVERCONF |
|---|
| 30 | # Sustituir caracteres ' por \' para evitar inyección SQL. |
|---|
| 31 | RESOURCE="${1//\'/\'}" |
|---|
| 32 | # Componer fichero con credenciales de conexión. |
|---|
| 33 | touch $MYCNF |
|---|
| 34 | chmod 600 $MYCNF |
|---|
| 35 | cat << EOT > $MYCNF |
|---|
| 36 | [client] |
|---|
| 37 | user=$USUARIO |
|---|
| 38 | password=$PASSWORD |
|---|
| 39 | EOT |
|---|
| 40 | # Borrar el fichero temporal si termina el proceso. |
|---|
| 41 | trap "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. |
|---|
| 43 | mysql --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.