source: repoman/bin/deletepreimage @ c916af9

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 c916af9 was fb1207d, checked in by albertogp <albertogp@…>, 11 years ago

branches-version1.0
Integrando cambios en version 1.0
#462

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

  • Property mode set to 100755
File size: 2.2 KB
Line 
1#!/bin/bash
2# Eliminar las imagenees del repositiro seg�raca de la consola web .img
3#Version 0.3   Ejecuci�n desde cron cada minuto.
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
32        ## Obtenemos el nombre de la imagen
33        DELETEIMAGE=$(echo $IMG | awk -F"." '{print $1}' | awk -F"/opt/opengnsys/images/" '{print $2}')
34
35        # Borramos marca .delete para que el proximo cron no trabaje sobre este conjunto.
36        [ -f  $IMG ] &&  rm $IMG
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
44        ## se llama al escript de borrado de imagen.
45        ## Si es un Directorio Borramos
46        if [[ $DELETEdir == "delete" ]]; then
47                /opt/opengnsys/bin/deleteimage -d $DELETEIMAGE
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
62done
Note: See TracBrowser for help on using the repository browser.