Proyecto

General

Perfil

« Anterior | Siguiente » 

Revisión 496

Tarea para portátiles que modifica el anacron para que sí se ejecuten por encima del 80% de batería

Ver diferencias:

tareas_puppet/portatiles/comunes/port_actualiza-anacron/leeme.txt
BREVE DESCRIPCION DE LA EJECUCION DEL MODULO
--------------------------------------------
Este modulo modifica el script /etc/init.d/anacron en los portátiles tanto de profes como de alumnos.
La modificación consiste en que se comprueba el nivel de batería del portátil.
Si es menor que el 80% no se ejecuta el anacron y por consiguiente todas las tareas
asociadas en los directorios /etc/cron.daily /etc/cron.weekly y /etc/cron.monthly no se ejecutan.
Sin embargo si la carga de batería es superior al 80% sí se ejecutarán las tareas, como por ejemplo pkgsync.
Se ejecutará una vez y hasta el siguiente reinicio no se hará efectivo.
La tarea comprueba la batería al iniciarse el servicio, lo que no significa que las tareas se ejecuten inmediatamente, si no a la hora que le corresponda.
INSTRUCCIONES DE INSTALACION DEL MODULO
---------------------------------------
Desempaquetar en /etc/puppet/modules
Incluir la linea include "nombre_modulo" en /etc/puppet/manifests/classes/especifica-miniportatil-2011.pp
------------------------------------------------
22-Marzo-2013.
Francisco Rodrigo Lopez
Administrador informatico del IES JAVIER GARCIA TELLEZ
tareas_puppet/portatiles/comunes/port_actualiza-anacron/manifests/init.pp
class port_actualiza-anacron {
file { "/etc/init.d/anacron":
owner=>root, group=>root, mode=>755,
source=>"puppet:///modules/port_actualiza-anacron/anacron",
}
}
tareas_puppet/portatiles/comunes/port_actualiza-anacron/files/anacron
#! /bin/sh
### BEGIN INIT INFO
# Provides: anacron
# Required-Start: $remote_fs $syslog $time
# Required-Stop: $remote_fs $syslog $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Handle anac(h)ronistic cron
### END INIT INFO
# /etc/init.d/anacron: start anacron
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin
test -x /usr/sbin/anacron || exit 0
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting anac(h)ronistic cron" "anacron"
if test -x /usr/bin/on_ac_power
then
/usr/bin/on_ac_power >/dev/null
if test $? -eq 1
then
bateria_restante=`acpi | tr -d " " | cut -f2 -d"," | cut -f1 -d"%"`
if [ $bateria_restante -lt 80 ];
then
log_progress_msg "deferred while on battery power."
log_end_msg 0
exit 0
fi
fi
fi
# on_ac_power doesn't exist, on_ac_power returns 0 (ac power being used)
# or on_ac_power returns 255 (undefined, desktop machine without APM)
start-stop-daemon --start --exec /usr/sbin/anacron -- -s
log_end_msg 0
;;
restart|force-reload|reload)
# nothing to do
:
;;
stop)
log_daemon_msg "Stopping anac(h)ronistic cron" "anacron"
start-stop-daemon --stop --exec /usr/sbin/anacron --oknodo --quiet
log_end_msg 0
;;
status)
exit 4
;;
*)
echo "Usage: /etc/init.d/anacron {start|stop|restart|force-reload|reload}"
exit 2
;;
esac
exit 0

Exportar a: Unified diff