Index: tareas_puppet/servidores_aula/utilaula/files/reinicio
===================================================================
--- tareas_puppet/servidores_aula/utilaula/files/reinicio	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/files/reinicio	(revision 103)
@@ -0,0 +1,26 @@
+#!/bin/bash
+##############################################################################
+# utilaula is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# utilaula is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with utilala. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+#Reinicia el servidor de aula si no hay nadie logeado. Tambien apaga
+#los ordenadores de los host conectados(Evita que se queden fritos
+#algunos tipos de clientes ligeros como los Dominion)
+#No tiene en cuenta si hay logeados alumnos 
+
+
+if  ! who | grep -q "(:0)"; then
+   ejecutaenhosts poweroff
+   /sbin/shutdown -r now
+fi
+

Property changes on: tareas_puppet/servidores_aula/utilaula/files/reinicio
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: tareas_puppet/servidores_aula/utilaula/files/ejecutaenhosts
===================================================================
--- tareas_puppet/servidores_aula/utilaula/files/ejecutaenhosts	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/files/ejecutaenhosts	(revision 103)
@@ -0,0 +1,104 @@
+#!/bin/bash
+##############################################################################
+# utilaula is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# utilaula is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with utilala. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+#
+#Permite ejecutar el comando que se le pase como parámetro en todos los hosts, ya 
+#sean portatiles o clientes ligeros que esten conectados en esa clase en ese instante.  
+#Con el parametro -p se ejecuta  en paralelo en todos los equipos(la salida resultante 
+#se almacena en un fichero), sin el parametro -p el comando se va ejecutando maquina a
+#maquina
+#
+#Ricardo Salgado Cid
+#IESO Galisteo
+#
+#26/01/11 Release incial ()
+#09/02/11 Opciones mas restrictivas en los ssh para evitar esperas infinitas
+
+if [ $# -lt 1 ]; then
+   echo "Permite ejecutar el comando que se le pase como parametro en todos los hosts"
+   echo "sean portatiles o clientes ligeros que esten conectados en esa clase en ese instante."
+   echo "Con el parametro -p se ejecuta  en paralelo en todos los equipos"
+   echo "Uso: $0 [-p] comando"
+   exit
+fi
+
+
+
+if [ "$1" \= "-p" ] ; then 
+   enparalelo="yes"
+   shift
+fi
+listahosts=$(avahi-browse -trpk -d local  _workstation._tcp 2>/dev/null | grep 192.168.0. | grep -v '_pro\|\-pro' | cut -d";" -f7,8 | sed 's/.local//' | sort)
+if [ -z "$listahosts" ]; then
+  echo "No se ha encontrado ninguna maquina conectada"
+  exit 2
+else
+  echo "El comando se ejecutará sobre $(echo $listahosts |  tr " " "\n" | wc -l ) maquina/s"
+fi
+
+for hostip in $listahosts 
+do
+  if [ -z $enparalelo ]; then
+    salida=/dev/stdout
+  else
+    salida=/dev/null
+  fi
+  host=$(echo $hostip | cut -d";" -f1)
+  ip=$(echo $hostip | cut -d";" -f2)
+  echo "Salida del comando en el host $host($ip):" > $salida
+  echo __________________________________________________________________________ > $salida
+  if [ -z $enparalelo ]; then
+     ssh -o StrictHostKeyChecking=no -o ConnectTimeout=9 -o ServerAliveCountMax=2 -o ServerAliveInterval=15 -i /var/lib/portatil/.ssh/id_rsa  root@$ip $* 
+  else
+     ssh -o StrictHostKeyChecking=no -o ConnectTimeout=9 -o ServerAliveCountMax=2 -o ServerAliveInterval=15 -i /var/lib/portatil/.ssh/id_rsa  root@$ip $* > /tmp/salida_host_$host.log 2>&1 &
+  fi
+  echo __________________________________________________________________________ > $salida
+  echo -e "\n\n" > $salida
+done
+
+if [ -z "$enparalelo" ]; then
+  exit 0
+else
+   salida="salidas_comando_$(date +%Y%m%d_%H%M).log"
+   echo -n "Esperando a que terminen los procesos "
+   for job in $(jobs -p)
+   do
+     echo -n "."
+     wait $job
+   done
+   echo -e "\n"
+   echo "Hecho!"
+   echo "Salidas del comando: \"$*\"" > $salida
+   echo $(date) >> $salida
+   for hostip in $listahosts
+   do
+     host=$(echo $hostip | cut -d";" -f1)
+     ip=$(echo $hostip | cut -d";" -f2)
+     echo "Salida del comando en el host $host($ip):" >> $salida
+     echo __________________________________________________________________________ >> $salida
+     cat /tmp/salida_host_${host}.log >> $salida
+     rm /tmp/salida_host_${host}.log
+     echo __________________________________________________________________________ >> $salida
+   done
+   echo "Salidas almacenadas en el fichero: $salida"
+
+#   read -n1 -p "¿Mostrar fichero? (s/N) "
+#   echo
+#   [[ $REPLY == [sSyY] ]] &&  less /root/$salida 
+#
+#   read -n1 -p "¿Borrar fichero? (s/N) "
+#   echo
+#   [[ $REPLY == [sSyY\n] ]] && rm $salida 
+
+fi

Property changes on: tareas_puppet/servidores_aula/utilaula/files/ejecutaenhosts
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: tareas_puppet/servidores_aula/utilaula/files/conectahost
===================================================================
--- tareas_puppet/servidores_aula/utilaula/files/conectahost	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/files/conectahost	(revision 103)
@@ -0,0 +1,40 @@
+#!/bin/bash
+##############################################################################
+# utilaula is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# utilaula is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with utilala. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+#
+#Ricardo Salgado(IESO Galisteo)
+#
+#Conecta a un host (portatil o workstation) que esté conectado a la red del aula en ese momento
+#toma como parametro el nombre del host(o una parte de el)
+#
+#Ricardo Salgado Cid
+#IESO Galisteo
+#
+#26/01/11 Release incial ()
+#09/02/11 Opciones mas restrictivas en los ssh para evitar esperas infinitas
+
+if [ $# -ne 1 ]; then
+   echo "Conecta a un host (portatil o workstation) que este conectado a la red del aula en ese momento"
+   echo "Uso: $0 nombre_equipo"
+   exit
+fi
+
+
+hostip=$(avahi-browse -trpk -d local  _workstation._tcp 2>/dev/null | grep 192.168.0. | grep -v '\-pro\|_pro' | grep $1.* | cut -d";" -f7,8 | sed 's/.local//' | sort | tail -1 )
+host=$(echo $hostip | cut -d";" -f1)
+ip=$(echo $hostip | cut -d";" -f2)
+
+echo "Conectando a $host($ip)"
+ssh -o StrictHostKeyChecking=no -o ConnectTimeout=9 -o ServerAliveCountMax=2 -o ServerAliveInterval=15  -i /var/lib/portatil/.ssh/id_rsa root@$ip

Property changes on: tareas_puppet/servidores_aula/utilaula/files/conectahost
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: tareas_puppet/servidores_aula/utilaula/files/apagado
===================================================================
--- tareas_puppet/servidores_aula/utilaula/files/apagado	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/files/apagado	(revision 103)
@@ -0,0 +1,25 @@
+#!/bin/bash
+##############################################################################
+# utilaula is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# utilaula is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with utilala. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+#Apaga el servidor de aula si no hay nadie logeado. Tambien apaga
+#los ordenadores de los host conectados(Evita que se queden fritos
+#algunos tipos de clientes ligeros como los Dominion)
+#No tiene en cuenta si hay logeados alumnos 
+
+if  ! who | grep -q "(:0)"; then
+   ejecutaenhosts poweroff
+   /sbin/shutdown -h now
+fi
+

Property changes on: tareas_puppet/servidores_aula/utilaula/files/apagado
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: tareas_puppet/servidores_aula/utilaula/files/arreglosportatil
===================================================================
--- tareas_puppet/servidores_aula/utilaula/files/arreglosportatil	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/files/arreglosportatil	(revision 103)
@@ -0,0 +1,38 @@
+#!/bin/bash
+##############################################################################
+# utilaula is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# utilaula is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with utilala. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+#
+#
+# Ricardo Salgado(IESO Galisteo)
+#
+# Ejecuta los comandos contenidos en la variable "comandos" en todos los portatiles conectados al aula.
+# Los comandos deben terminar con el caracter ";" a excepcion del ultimo
+# Pensado solo para los portatiles, cuidado con ejecutarlo sobre los clientes ligeros
+# Pasando como parametro -p al script los comandos se ejecutaran en paralelo en todos los host.
+# Sin parametros se ejecutaran host a host
+
+comandos="
+/etc/init.d/puppet stop;
+dpkg --configure -a --force-all;
+puppetd -tv;
+pkgsync;
+nss_updatedb ldap;
+apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold--reinstall install autofs5;
+/etc/init.d/puppet start
+"
+if [ "$1" \= "-p" ] ; then
+   /sbin/ejecutaenhosts -p $comandos
+else 
+   /sbin/ejecutaenhosts $comandos
+fi

Property changes on: tareas_puppet/servidores_aula/utilaula/files/arreglosportatil
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: tareas_puppet/servidores_aula/utilaula/files/listahosts
===================================================================
--- tareas_puppet/servidores_aula/utilaula/files/listahosts	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/files/listahosts	(revision 103)
@@ -0,0 +1,38 @@
+#!/bin/bash
+##############################################################################
+# utilaula is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# utilaula is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with utilala. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+#
+#Lista los hosts, sean portatiles o clientes ligeros que esten conectados en esa clase 
+#en ese instante.  
+#
+#Ricardo Salgado Cid
+#IESO Galisteo
+#
+#09/02/11 Release incial ()
+
+listahosts=$(avahi-browse -trpk -d local  _workstation._tcp 2>/dev/null | grep 192.168.0. | grep -v '_pro\|\-pro' | cut -d";" -f7,8 | sed 's/.local//' | sort)
+if [ -z "$listahosts" ]; then
+  echo "No se ha encontrado ninguna maquina conectada"
+  exit 2
+else
+  echo "Hay $(echo $listahosts |  tr " " "\n" | wc -l ) maquina/s conectadas:"
+fi
+
+for hostip in $listahosts 
+do
+  host=$(echo $hostip | cut -d";" -f1)
+  ip=$(echo $hostip | cut -d";" -f2)
+  echo "--$host($ip)"
+done
+

Property changes on: tareas_puppet/servidores_aula/utilaula/files/listahosts
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: tareas_puppet/servidores_aula/utilaula/leeme.txt
===================================================================
--- tareas_puppet/servidores_aula/utilaula/leeme.txt	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/leeme.txt	(revision 103)
@@ -0,0 +1,24 @@
+utilaula
+
+
+Tarea de puppet que añade comandos que hace posible conectarse facilmente
+a los ordenadores(portatiles o clientes ligeros) que estan encendidos en un 
+determinado momento en un aula desde el ordenador del profesor. Para instalar 
+la tarea solo hay que descomprimir en /etc/puppet/modules del servidor nfs y 
+añadirla a clase-especifica. Los comandos son los siguientes:
+
+*listahosts: devuelve una lista de las máquinas conectadas(hostname e ip).
+*conectahost: abre una sesión de ssh como root en la maquina que se le indique.
+   (No es necesario teclear el nombre entero,basta con los primeros caracteres)
+*ejecutaenhosts: ejecuta el comando que se le pase como parámetro en todos los hosts
+   (Con el parametro -p se ejecuta  en paralelo en todos los equipos)
+*arreglosportatil: ejecuta los comandos de configuracion basica de los portatiles.
+   (mirar dentro del script para mas detalles)
+*reincio: reincia el servidor de aula si no hay nadie logeado.
+*apagado: apaga el servidor de aula si no hay nadie logeado
+
+Ricardo Salgado Cid
+IESO Galisteo
+Febrero 2011
+
+
Index: tareas_puppet/servidores_aula/utilaula/changelog
===================================================================
--- tareas_puppet/servidores_aula/utilaula/changelog	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/changelog	(revision 103)
@@ -0,0 +1,3 @@
+16/02/11 v0.7 Corregidos permisos en la carpeta files
+10/02/11 v0·6 Corregido bug(No se creaba la carpeta .ssh dentro del root de la imagen ltsp)
+10/02/11 v0.5 Release incial con soporte de portatiles
Index: tareas_puppet/servidores_aula/utilaula/manifests/init.pp
===================================================================
--- tareas_puppet/servidores_aula/utilaula/manifests/init.pp	(nonexistent)
+++ tareas_puppet/servidores_aula/utilaula/manifests/init.pp	(revision 103)
@@ -0,0 +1,48 @@
+class utilaula {
+
+  file { 
+	
+	"/sbin/conectahost":
+        owner => root, group => root, mode => 750,
+        source => "puppet:///utilaula/conectahost";
+
+        "/sbin/listahosts":
+        owner => root, group => root, mode => 750,
+        source => "puppet:///utilaula/listahosts";
+
+	
+	"/sbin/ejecutaenhosts":
+	owner => root, group => root, mode => 750,
+        source => "puppet:///utilaula/ejecutaenhosts";
+
+        "/sbin/arreglosportatil":
+        owner => root, group => root, mode => 750,
+        source => "puppet:///utilaula/arreglosportatil";
+        
+        "/sbin/apagado":
+        owner => root, group => root, mode => 750,
+        source => "puppet:///utilaula/apagado";
+
+        "/sbin/reinicio":
+        owner => root, group => root, mode => 750,
+        source => "puppet:///utilaula/reinicio";
+
+	"/opt/ltsp/i386/root/.ssh":
+        owner => root, group => root, mode => 755,
+	ensure => directory,
+	before => File["/opt/ltsp/i386/root/.ssh/authorized_keys2"];
+
+  	"/opt/ltsp/i386/root/.ssh/authorized_keys2":
+        owner => root, group => root, mode => 600,
+        source => "/var/lib/portatil/.ssh/id_rsa.pub",
+        notify => Exec[crear-imagen-utilaula];
+        }
+
+
+  exec { "crear-imagen-utilaula":
+        command => "/usr/sbin/ltsp-update-image --arch i386",
+        refreshonly => true;
+       }
+
+}
+
