source: repoman/bin/deletepreimage @ 240a4dc

918-git-images-111dconfigure-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-instalacion
Last change on this file since 240a4dc was 2b1ed11, checked in by ramon <ramongomez@…>, 8 years ago

#810: Crear script checkrepo para mantener información de imágenes del repositorio (se ejecutará en el cron tras el script deletepreimage.

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

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