lgromero-new-oglive
Last change
on this file was
c28eefa,
checked in by Natalia Serrano <natalia.serrano@…>, 19 months ago
|
Log to syslog in a number of shell scripts
|
-
Property mode set to
100755
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | # Eliminar las imágenees del repositiro seg�raca de la consola web. |
---|
3 | #Version 0.3 Ejecución desde cron cada minuto. |
---|
4 | #echo "* * * * * root /opt/opengnsys/bin/image-delete" > /etc/cron.d/imagedelete |
---|
5 | # Version 1.1.0 - Llamar a script "checkrepo". |
---|
6 | |
---|
7 | # Comprobar si el proceso ya está en ejecución. |
---|
8 | PROG=$(basename $0) |
---|
9 | [ "$(pgrep "$PROG")" != "$$" ] && exit |
---|
10 | |
---|
11 | # Variables. |
---|
12 | OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"} |
---|
13 | PATH=$PATH:$OPENGNSYS/bin |
---|
14 | OGIMG="$OPENGNSYS/images" |
---|
15 | REPOCFG="$OPENGNSYS/etc/ogAdmRepo.cfg" |
---|
16 | |
---|
17 | source $OPENGNSYS/lib/ogfunctions.sh |
---|
18 | |
---|
19 | # Error si no está bien configurado el repositorio de imágenes. |
---|
20 | [ -d $OGIMG -a -f $REPOCFG ] || exit 1 |
---|
21 | |
---|
22 | # Procesar ficheros de imágenes. |
---|
23 | trap "echolog Proceso interrumpido; exit" 1 2 3 6 9 15 |
---|
24 | |
---|
25 | shopt -s nullglob |
---|
26 | TODELETE=( $OPENGNSYS/www/tmp/*.delete ) |
---|
27 | |
---|
28 | for IMG in ${TODELETE[@]##*/}; do |
---|
29 | # Obtenemos el nombre de la imagen |
---|
30 | DELETEIMAGE="${IMG%%.*}" |
---|
31 | ## Si la imagen es un backup se añade la extensión ant |
---|
32 | [ "${IMG##*.}" == "ant" ] && DELETEIMAGE+=".ant" |
---|
33 | |
---|
34 | ## si directorio:imagen cambiamos : por / |
---|
35 | DELETEIMAGE=$(echo $DELETEIMAGE|tr : /) |
---|
36 | |
---|
37 | ## se llama al escript de borrado de imagen. |
---|
38 | deleteimage $DELETEIMAGE |
---|
39 | done |
---|
40 | |
---|
41 | # Eliminar marcas de borrado. |
---|
42 | rm -f ${TODELETE[@]} |
---|
43 | # Actualizar información del repositorio. |
---|
44 | checkrepo |
---|
45 | |
---|
Note: See
TracBrowser
for help on using the repository browser.