#678 unidades organizativas separadas: los script deleteimagen y torrent-creator permiten imágenes dentro de subdirectorios de /opt/opengnsys/images
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4786 a21b9725-9963-47de-94b9-378ad31fedc9remotes/github/debian-pkg
parent
2a051725a0
commit
d6bffcc865
|
@ -1,10 +1,14 @@
|
|||
#!/bin/bash
|
||||
# deleteimage [ -b | -r ] str_image
|
||||
# deleteimage [ -b | -r ] [ dir_ogunit ] str_image
|
||||
#@file deleteimage
|
||||
#@brief Borra del repositorio los ficheros de una imagen.
|
||||
#@param -b Elimina también la copia de seguridad de la imagen (opcional).
|
||||
#@param -r Recupera la copia de seguridad de la imagen (opcional).
|
||||
#@param str_dir_ogunit Nombre del subdirectorio de la unidad organizativa (opcional).
|
||||
#@param str_image Nombre canónico de la imagen, sin extensión.
|
||||
#@exception 1 Error de formato
|
||||
#@exception 2 Solo ejecutable por root
|
||||
#@exception 3 No existe subdirectorio de la unidad organizativa
|
||||
#@version 1.0 - Versión inicial.
|
||||
#@date 2012-10-14
|
||||
#@author Ramón Gómez, ETSII Univ. Sevilla
|
||||
|
@ -14,6 +18,9 @@
|
|||
#@version 1.0.6 - Detección automática del tipo de imagen.
|
||||
#@date 2014-10-29
|
||||
#@author Ramón Gómez, ETSII Univ. Sevilla
|
||||
#@version 1.1 - Separación subdirectorios unidades organizativas.
|
||||
#@date 2016-01-03
|
||||
#@author Irina Gómez, ETSII Univ. Sevilla
|
||||
|
||||
|
||||
PROG=$(basename $0)
|
||||
|
@ -27,10 +34,13 @@ DIFFEXT="diff"
|
|||
if [ "$*" == "help" ]; then
|
||||
cat << EOT
|
||||
$PROG: Borra los ficheros de una imagen del repositorio.
|
||||
Formato: $PROG [ -b | -r ] str_image
|
||||
Formato: $PROG [ -b | -r ] [ str_dir_ogunit ] str_image
|
||||
-b Elimina también la copia de seguridad de la imagen.
|
||||
-r Recupera la copia de seguridad de la imagen.
|
||||
dir_ogunit subdirectorio unidad organizativa
|
||||
|
||||
Ejemplo: $PROG imagen1
|
||||
$PROG -r dir_ogunit2 imagen2
|
||||
EOT
|
||||
exit 0
|
||||
fi
|
||||
|
@ -44,27 +54,42 @@ while getopts br OPTION; do
|
|||
shift $((OPTIND-1))
|
||||
done
|
||||
[ -n "$DELETEBACKUP" ] && [ -n "$RECOVERBACKUP" ] && ERR=1
|
||||
if [ $# != 1 -o -n "$ERR" ]; then
|
||||
echo "$PROG Error: Formato: $PROG [ -b | -r ] str_image"
|
||||
if [ $# -lt 1 -o -n "$ERR" ]; then
|
||||
echo "$PROG Error: Formato: $PROG [ -b | -r ] [ str_dir_ogunit ] str_image"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$USER" != "root" ]; then
|
||||
echo "$PROG: Error: solo ejecutable por root" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ "$2" ]; then
|
||||
if [ -d "$OGIMG/$1" ]; then
|
||||
OGIMG="$OGIMG/$1"
|
||||
else
|
||||
echo "$PROG Error: No existe el subdirectorio de la unidad organizativa $OGIMG/$1"
|
||||
exit 3
|
||||
fi
|
||||
shift
|
||||
fi
|
||||
|
||||
# Eliminar ficheros de imagen monolítica o sincronizada básica.
|
||||
IMGPATH="$OGIMG/$1.$IMGEXT"
|
||||
if [ -f $IMGPATH ]; then
|
||||
echo "Borrando fichero $PATHDIR"
|
||||
echo "Borrando fichero $IMGPATH"
|
||||
rm -f $IMGPATH && rm -f $IMGPATH.{sum,full.sum,torrent}
|
||||
else
|
||||
# Eliminar ficheros de imagen sincronizada diferencial.
|
||||
IMGPATH="$OGIMG/$1.$IMGEXT.$DIFFEXT"
|
||||
if [ -f $IMGPATH ]; then
|
||||
echo "Borrando fichero $PATHDIR"
|
||||
echo "Borrando fichero $IMGPATH"
|
||||
rm -f $IMGPATH && rm -f $IMGPATH.{sum,full.sum,torrent}
|
||||
else
|
||||
# Eliminar directorio de imagen sincronizada.
|
||||
IMGPATH="$OGIMG/$1"
|
||||
if [ -d $IMGPATH ]; then
|
||||
echo "Borrando directorio $PATHDIR"
|
||||
echo "Borrando directorio $IMGPATH"
|
||||
rm -fr $IMGPATH
|
||||
fi
|
||||
fi
|
||||
|
@ -81,7 +106,7 @@ fi
|
|||
|
||||
# Borrar copia de seguridad de la imagen.
|
||||
if [ -n "$DELETEBACKUP" ]; then
|
||||
[ -e $IMGPATH ] && echo "Eliminando copia $IMGPATH.$BAKEXT"
|
||||
[ -e $IMGPATH.$BAKEXT ] && echo "Eliminando copia $IMGPATH.$BAKEXT"
|
||||
rm -f $IMGPATH.$BAKEXT && rm -f $IMGPATH.{sum,full.sum,torrent}.$BAKEXT
|
||||
fi
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ pushd $OGIMG >/dev/null
|
|||
|
||||
# Procesar ficheros de imágenes.
|
||||
trap 'echo "`date` : Proceso interrumpido" >> $LOGFILE; exit ' 1 2 3 6 9 15
|
||||
for IMG in *.{img,pgz,diff}; do
|
||||
for IMG in *.{img,pgz,diff} */*.{img,pgz,diff} ; do
|
||||
# Saltar al siguiente si la imagen está bloqueada o si no existe el fichero.
|
||||
LOCKFILE="$IMG.lock"
|
||||
if [ -f "$LOCKFILE" -o ! -f "$IMG" ]; then
|
||||
|
|
Loading…
Reference in New Issue