source: repoman/bin/deleteimage @ 431b5dc

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 431b5dc was 8a64a902, checked in by ramon <ramongomez@…>, 12 years ago

Corregida errata de formato en script deleteimage.

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

  • Property mode set to 100755
File size: 1.8 KB
Line 
1#!/bin/bash
2#         deleteimage [ -b | -r ] str_image
3#@file    deleteimage
4#@brief   Borra del repositorio los ficheros de una imagen.
5#@param   -b           Elimina también la copia de seguridad de la imagen (opcional).
6#@param   -r           Recupera la copia de seguridad de la imagen (opcional).
7#@param   str_image    Nombre canónico de la imagen, sin extensión.
8#@version 1.0
9#@date    2012-10-14
10#@author  Ramón Gómez, ETSII Univ. Sevilla
11
12
13PROG=$(basename $0)
14OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
15OGIMG=$OPENGNSYS/images
16IMGEXT="img"
17BAKEXT="ant"
18 
19# Si se solicita, mostrar ayuda.
20if [ "$*" == "help" ]; then
21    cat << EOT
22$PROG: Borra los ficheros de una imagen del repositorio.
23Formato: $PROG [ -b | -r ] str_image
24         -b  Elimina también la copia de seguridad de la imagen.
25         -r  Recupera la copia de seguridad de la imagen.
26Ejemplo: $PROG imagen1
27EOT
28    exit 0
29fi
30# Procesar parámetros
31while getopts br OPTION; do
32    case $OPTION in
33        b) DELETEBACKUP=1 ;;
34        r) RECOVERBACKUP=1 ;;
35        *) ERR=1 ;;
36    esac
37    shift $((OPTIND-1))
38done
39[ -n "$DELETEBACKUP" ] && [ -n "$RECOVERBACKUP" ] && ERR=1
40if [ $# != 1 -o -n "$ERR" ]; then
41    echo "$PROG Error: Formato: $PROG [ -b | -r ] str_image"
42    exit 1
43fi
44
45# Fichero principal de la imagen.
46IMGFILE="$OGIMG/$1.$IMGEXT"
47
48# Eliminar ficheros de la imagen.
49rm -f $IMGFILE && rm -f $IMGFILE.{sum,torrent}
50
51# Recuperar copia de seguridad de la imagen.
52if [ -n "$RECOVERBACKUP" ]; then
53    mv -f $IMGFILE.$BAKEXT $IMGFILE && \
54            (mv -f $IMGFILE.sum.$BAKEXT $IMGFILE.sum 2>/dev/null
55             mv -f $IMGFILE.torrent.$BAKEXT $IMGFILE.torrent 2>/dev/null)
56fi
57
58# Borrar copia de seguridad de la imagen.
59if [ -n "$DELETEBACKUP" ]; then
60    rm -f $IMGFILE.$BAKEXT && rm -f $IMGFILE.{sum,torrent}.$BAKEXT
61fi
62
Note: See TracBrowser for help on using the repository browser.