source: repoman/bin/deletepreimage @ f009c3d

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 f009c3d was 25a56b8, checked in by irina <irinagomez@…>, 9 years ago

#678 Permite borrar imágenes en directorios de unidades organizativas desde la consola o línea de comando

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

  • Property mode set to 100755
File size: 1.9 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        DELETEIMAGE=$(echo ${IMG%%.*} | awk -F"/opt/opengnsys/images/" '{print $2}')
35
36        # Borramos marca .delete para que el proximo cron no trabaje sobre este conjunto.
37        [ -f  $IMG ] &&  rm $IMG
38
39        ## Comprobamos si es una imagen de backup
40        DELETEant=$(echo $IMG | awk -F"." '{print $3}') ## .ant
41
42        ## Si la imagen es un backup se añade la extensión ant
43        if [[ $DELETEant == "ant" ]]; then
44                DELETEIMAGE=$DELETEIMAGE".ant"
45        fi
46        ## si directorio:imagen cambiamos : por /
47        DELETEIMAGE=$(echo $DELETEIMAGE|tr : /)
48
49        ## se llama al escript de borrado de imagen.
50        /opt/opengnsys/bin/deleteimage $DELETEIMAGE
51
52done
Note: See TracBrowser for help on using the repository browser.