source: repoman/bin/deletepreimage @ a1c1fe0

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 a1c1fe0 was 1a2fa9d8, checked in by ramon <ramongomez@…>, 10 years ago

#673: Actualizar código incluido en OepnGnSys? 1.0.6 sobre la rama version1.1 para desarrollar la nueva versión.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@4609 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.2 KB
RevLine 
[8bf033d]1#!/bin/bash
[0d2f40e]2# Eliminar las imagenees del repositiro seg�raca de la consola web .img
[2cb912bd]3#Version 0.3   Ejecuci�n desde cron cada minuto.
[8bf033d]4#echo "* * * * *   root   /opt/opengnsys/bin/image-delete" > /etc/cron.d/imagedelete
5
6# Comprobar si el proceso ya est� en ejecuci�n.on.
7PROG=$(basename $0)
8[ "$(pgrep "$PROG")" != "$$" ] && exit
9
10# Variables.
11OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
12PATH=$PATH:$OPENGNSYS/bin
13OGIMG="$OPENGNSYS/images"
14REPOCFG="$OPENGNSYS/etc/ogAdmRepo.cfg"
15LOGFILE="$OPENGNSYS/log/$PROG.log"
16
17# Error si no est� bien configurado el repositorio de im�genes.nes.
18[ -d $OGIMG -a -f $REPOCFG ] || exit 1
19
20# Procesar ficheros de im�genes.s.
21trap 'echo "`date` : Proceso interrumpido" >> $LOGFILE; exit ' 1 2 3 6 9 15
22
23#TODO en LOCAL: si existe algun fichero *.delete lo movemos al repositorio
24ls /opt/opengnsys/www/tmp/*.delete &>/dev/null || exit
25#[ -f /opt/opengnsys/www/tmp/*.delete ] &&
26mv /opt/opengnsys/www/tmp/*.* /opt/opengnsys/images/
27
28#TODO: iniciar blucle siempre y cuando haya algun delete
29ls /opt/opengnsys/images/*.delete &>/dev/null || exit
30
31for IMG in `ls /opt/opengnsys/images/*.delete`; do
[4a51c8ba]32        ## Obtenemos el nombre de la imagen
[8bf033d]33        DELETEIMAGE=$(echo $IMG | awk -F"." '{print $1}' | awk -F"/opt/opengnsys/images/" '{print $2}')
[4a51c8ba]34
[8bf033d]35        # Borramos marca .delete para que el proximo cron no trabaje sobre este conjunto.
36        [ -f  $IMG ] &&  rm $IMG
[4a51c8ba]37
38        ## Comprobamos si es un Directorio .delete
39        DELETEdir=$(echo $IMG | awk -F"." '{print $2}') ## .delete
40        DELETEant=$(echo $IMG | awk -F"." '{print $3}') ## .ant
41        DELETEdiff=$(echo $IMG | awk -F"." '{print $3}')        ## .diff
42        ## Si NO es ninguno es un img
43
[8bf033d]44        ## se llama al escript de borrado de imagen.
[4a51c8ba]45        ## Si es un Directorio Borramos
46        if [[ $DELETEdir == "delete" ]]; then
[1a2fa9d8]47                /opt/opengnsys/bin/deleteimage $DELETEIMAGE
[4a51c8ba]48
49                # Si es un Imagen Backup Borramos
50                elif [[ $DELETEant == "ant" ]]; then
51                        DELETEIMAGE=$DELETEIMAGE".ant"
52                        /opt/opengnsys/bin/deleteimage $DELETEIMAGE
53
54                        # Si es un Imagen diff Borramos
55                        elif [[ $DELETEdiff == "diff" ]]; then
56                                /opt/opengnsys/bin/deleteimage $DELETEIMAGE
57
58                                # Si no es una de las anteriores lo que queda es img
59                                else
60                                        /opt/opengnsys/bin/deleteimage $DELETEIMAGE
61        fi
[8bf033d]62done
Note: See TracBrowser for help on using the repository browser.