source: client/shared/scripts/ogCrearSoftIncremental

qndtest
Last change on this file was b239936, checked in by albertogp <albertogp@…>, 10 years ago

branches-version1.0-tickets
Mejoras en los comandos
Eliminar imagen Repositorio, crea una marca en los ficheros
ogCreateImagenBasica
ogCrearSoftIncremental
#462

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

  • Property mode set to 100755
File size: 6.2 KB
Line 
1#!/bin/bash
2#___________________________________________________________________
3#
4#  CREAR IMAGEN INCREMENTAL
5#___________________________________________________________________
6#
7# Parámetros recibidos desde el cliente:
8#
9# $1 Número de disco
10# $2 Número de particion
11# $3 Nombre canónico de la imagen básica (sin extensión)
12# $4 Dirección del repositorio
13# $5 Nombre canónico de la imagen incremental (sin extensión)
14# $6 Es una cadena "nnn" tipo flags que codifica varios parametros.
15#               Tiene el formato "nnn" donde "n" vale 0 ó 1.   
16#               1XX: Gestionar fichero completo en lugar de diferencas
17#               X1X: Eliminar archivos de la imagen que no estén en la partición
18#               XX1: Comprimir archivos para enviarlos por la red
19#               El valor X indica que no importa el valor que tenga el dato
20# $7 Es una cadena "nnnn" tipo flags que codifica varios parametros.
21#               Tiene el formato "nnnn" donde "n" vale 0 ó 1.   
22#               1XXX: Borrar la imagen incremental del repositorio antes de crearla
23#               X1XX: Copiar imagen incremental también a la cache
24#               XX1X: Borrar previamente la imagen incremental de la cache antes de copiarla
25#               XXX1: No borrar archivos en destino
26#               El valor X indica que no importa el valor que tenga el dato
27# $8 Método de syncronización 1=Sincronización1  2=Sincronizacion2
28# $9 Ruta de origen de la Imagen (Carpeta)
29
30#___________________________________________________________________
31#
32# Control parámetros
33#___________________________________________________________________
34
35        PROG="$(basename $0)"
36        if [ $# -lt 7 ]; then
37                usage=" ndisco nparticion nombre_imagen_basica ip_repositorio nombre_imagen_incremental"
38                usage="$usage copiar_a_caché Borrar_cache_previamente Ruta_origen"
39                ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG $usage"
40                exit $?
41        fi
42       
43        DISCO=$1
44        NPART=$2
45        NOMBREIMG=$3
46        IPREPOSITORIO=$4
47        NOMBREIMGINC=$5
48       
49        flag=$6
50        echo "flah:$flag">/tmp/log
51        WHLFILE=${flag:0:1}
52        RMVFILE=${flag:1:1}
53        CMPFILE=${flag:2:1}
54
55        flag=$7
56        echo "flah:$flag">/tmp/log
57        BORRARIMG=${flag:0:1}
58        COPIACACHE=${flag:1:1}
59        BORRACACHE=${flag:2:1}
60        NOBORRACHIVOS=${flag:3:1}
61       
62        RUTAORIGEN=$9
63#___________________________________________________________________
64#
65# Variables y configuración logs
66#___________________________________________________________________
67       
68        source /opt/opengnsys/scripts/ImagenesSincronizadas.lib
69#___________________________________________________________________
70#
71# Activa navegador para ver progreso
72#___________________________________________________________________
73
74        coproc /opt/opengnsys/bin/browser -qws http://localhost/cgi-bin/httpd-log.sh   
75#___________________________________________________________________
76#
77# Lista de archivos a sincronizar
78#___________________________________________________________________
79       
80        TMPFILELIST="/tmp/_listatmp_"
81        FILELIST="/tmp/_lista_"
82#___________________________________________________________________
83#
84# Proceso
85#___________________________________________________________________
86
87        echo "Creacion de imagen incremental..." | tee -a $OGLOGSESSION $OGLOGFILE
88       
89        ORIGEN=$PARTICION$RUTAORIGEN/   
90        DESTINO="$REPOSITORIO/$NOMBREIMG/"
91       
92        # Borrado previo de imagen en repositorio
93        if [ $BORRARIMG -eq 1 ]; then
94           echo "Borrando previamente imagen del $NOMBREIMGINC repositorio" | tee -a $OGLOGSESSION $OGLOGFILE
95        fi
96       
97        ## Marca de localizacion Repositorio
98        FILE_IMG=".marcimg"
99        MARCAORIGEN=$ORIGEN$FILE_IMG
100        ## Marca de localizacion Repositorio en Imagen
101        if [ ! -f $MARCAORIGEN  ]; then
102                ##echo "Creando Marca Repositorio en Particion $MARCAORIGEN"  | tee -a $OGLOGSESSION $OGLOGFILE
103                touch $MARCAORIGEN
104        fi
105               
106        # Creación de la lista de archivos entre partición e imagen básica del repositorio
107        echo "Creacion de la lista de archivos a transferir entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
108        crearListaAcl $ORIGEN $DESTINO $SISTEMAFICHERO $DISCO $NPART   
109        crearImagen $ORIGEN $DESTINO $SISTEMAFICHERO 1 1 $TMPFILELIST   
110        RETVAL=$?       
111        if [ $RETVAL -ne 0 ]; then
112                 kill $COPROC_PID
113           exit $OG_ERR_IMAGE
114        fi     
115       
116        # Editar la lista y depurarla
117        editarLista $TMPFILELIST $FILELIST
118       
119        # Creación de la imagen incremental en el repositorio
120        DESTINO="$REPOSITORIO/$NOMBREIMGINC/"
121        echo "Sincronizacion para crear imagen incremental entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
122        crearImagen $ORIGEN $DESTINO $SISTEMAFICHERO 1 2 $FILELIST     
123        RETVAL=$?       
124        if [ $RETVAL -ne 0 && [$RETVAL -ne 23]; then
125                 kill $COPROC_PID
126           exit $OG_ERR_IMAGE
127        fi     
128        ## Marca de localizacion Repositorio
129        FILE_IMG=".marcimg"
130        MARCA=$DESTINO$FILE_IMG
131        ## Marca de localizacion Repositorio en Imagen
132        if [ ! -f $MARCA  ]; then
133                ##echo "Creando Marca Repositorio en Imagen $MARCA"  | tee -a $OGLOGSESSION $OGLOGFILE
134                touch $MARCA
135        fi
136       
137        echo "!!! Finaliza correctamente !!! la creacion de imagen incremental $NOMBREIMGINC entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
138
139        # Copia opcional a la caché
140        if [ $COPIACACHE -eq 1 ]; then
141                echo "Copiando imagen a cache" | tee -a $OGLOGSESSION $OGLOGFILE
142                CACHE=$(montaCache)
143                if [ -z $CACHE ]; then
144                        echo "No se ha podido copiar la imagen a la cache" | tee -a $OGLOGSESSION $OGLOGFILE
145                        kill $COPROC_PID
146      exit $OG_ERR_NOTCACHE
147                fi             
148
149                # Borrar imagen de la caché
150                if [ $BORRACACHE -eq 1 ]; then
151                        echo "Borrando imagen $NOMBREIMGINC de la cache" | tee -a $OGLOGSESSION $OGLOGFILE
152                  rm -R $CACHE$OGIMG/$NOMBREIMGINC
153                fi     
154
155                DESTINO="$CACHE$OGIMG/$NOMBREIMGINC/"
156                echo "Sincronizando imagen entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
157                crearImagen $ORIGEN $DESTINO $SISTEMAFICHERO 2 2 $FILELIST     
158                RETVAL=$?       
159                if [ $RETVAL -ne 0 ]; then
160                         kill $COPROC_PID
161                   exit $OG_ERR_IMAGE
162                fi     
163                echo "!!! Finaliza correctamente !!! la copia de imagen incremental $NOMBREIMGINC a la cache" | tee -a $OGLOGSESSION $OGLOGFILE 
164  fi   
165
166        ## Marca de localizacion Repositorio
167        FILE_IMG=".marcimg"
168        MARCA=$DESTINO$FILE_IMG
169        ## Marca de localizacion Repositorio en CACHE
170        if [ ! -f $MARCA  ]; then
171                ##echo "Creando Marca Repositorio en CACHE $MARCA"  | tee -a $OGLOGSESSION $OGLOGFILE
172                touch $MARCA
173        fi
174
175        ## Eliminando Marca Origen Repositorio
176        rm $MARCAORIGEN
177        eliminaListaAcl $ORIGEN $SISTEMAFICHERO 
178#___________________________________________________________________
179#
180# Retorno
181#___________________________________________________________________
182
183        kill $COPROC_PID
184        exit 0
185       
Note: See TracBrowser for help on using the repository browser.