source: admin/Interface/RestaurarSoftIncremental @ 2142791

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 2142791 was 9204a04, checked in by ramon <ramongomez@…>, 12 years ago

Versión 1.0.5, #565: Integrar cambios en comandos para crear y restaurar imágenes incrementales.

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

  • Property mode set to 100755
File size: 6.1 KB
RevLine 
[4329e85]1#!/bin/bash
2#___________________________________________________________________
3#
4#  RESTAURAR 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)
[9204a04]12# $4 Dirección del repositorio
[4329e85]13# $5 Nombre canónico del software incremental (sin extensión)
14# $5 Es una cadena "nnnn" tipo flags que codifica varios parametros.
15#               Tiene el formato "nnnn" donde "n" vale 0 ó 1.   
16#               1XXX: Borrar la particion de destino antes de restaurar la imagen incremental
17#               X1XX: Copiar Imagen incremental también a la cache
18#               XX1X: Borrar previamente la imagen incremental de la cache antes de copiarla
19#               XXX1: No borrar archivos en destino
20#               El valor X indica que no importa el valor que tenga el dato
21# $7 Método de clonación 0=Desde caché 1=Desde repositorio
22# $8 Ruta de origen de la Imagen (Carpeta)
23#___________________________________________________________________
24#
25# Control parámetros
26#___________________________________________________________________
27
28        PROG="$(basename $0)"
29        if [ $# -lt 6 ]; then
30                usage=" ndisco nparticion nombre_imagen_basica ip_repositorio copiar_a_caché "
31                usage="$usage Borrar_cache_previamente metodo_clonación Ruta_origen"
32                ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG $usage"
33                exit $?
34        fi
35       
36        DISCO=$1
[9204a04]37        NPART=$2
[4329e85]38        NOMBREIMG=$3
39        IPREPOSITORIO=$4
40        NOMBREIMGINC=$5
41       
42        flag=$6
43        echo "flah:$flag">/tmp/log
44        BORRARIMG=${flag:0:1}
45        COPIACACHE=${flag:1:1}
46        BORRACACHE=${flag:2:1}
47        NOBORRACHIVOS=${flag:3:1}
48       
49        METCLONA=$7
50        RUTAORIGEN=$8
51#___________________________________________________________________
52#
53# Variables y configuración logs
54#___________________________________________________________________
55       
56        source /opt/opengnsys/interfaceAdm/ImagenesSincronizadas.lib
[9204a04]57
58        if [ -z $SISTEMAFICHERO ]; then
59                case "$TIPOPARTICION" in
60                        7)
61                                SISTEMAFICHERO="Windows"
62                        ;;
63                        83)
64                                SISTEMAFICHERO="Linux"
65                ;;
66                esac
67        fi
[4329e85]68#___________________________________________________________________
69#
70# Proceso
71#___________________________________________________________________
72
73        echo "Restauracion de imagen incremental..." | tee -a $OGLOGSESSION $OGLOGFILE
74       
75        # Borrado previo de la partición
76        if [ $BORRARIMG -eq 1 ]; then
77                if [ -n $RUTAORIGEN ]; then
78                        echo "Borrando carpeta $PARTICION$RUTAORIGEN" | tee -a $OGLOGSESSION $OGLOGFILE
79                    rm -R $PARTICION$RUTAORIGEN         
80                else
81                        echo "Formateando la particion" | tee -a $OGLOGSESSION $OGLOGFILE
82                        ogFormat $DISCO $PARTICION $TIPOPARTICION
83                        RETVAL=$?       
84                        if [ $RETVAL -ne 0 ]; then
85                           exit $OG_ERR_PARTITION
86                        fi
87                fi         
88        fi
89
90        # Sincronización desde repositorio
91        if [ $METCLONA = 1 ]; then
92                if [ $COPIACACHE = 0 ]; then   
93                        echo "Restaurando imagen basica desde repositorio $IPREPOSITORIO" | tee -a $OGLOGSESSION $OGLOGFILE
94                        ORIGEN="$REPOSITORIO/$NOMBREIMG/"       
95                        DESTINO=$PARTICION$RUTAORIGEN/ 
96                        # Restauración de la imagen básica
97                        echo "Sincronizando imagen basica entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
98                        restaurarImagen $ORIGEN $DESTINO $SISTEMAFICHERO 1
99                        RETVAL=$?
100                        if [ $RETVAL -ne 0 ]; then
101                           exit $OG_ERR_IMAGE
102                        fi
103
104                        # Restauración de la imagen incremental
105                        echo "Restaurando imagen incremental desde repositorio $IPREPOSITORIO" | tee -a $OGLOGSESSION $OGLOGFILE
106                        ORIGEN="$REPOSITORIO/$NOMBREIMGINC/"   
107                        DESTINO=$PARTICION$RUTAORIGEN/ 
108                        OP_DELETE=""
109                        # Restauración de la imagen incremental
110                        echo "Sincronizando imagen entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
111                        restaurarImagen $ORIGEN $DESTINO $SISTEMAFICHERO 1
[9204a04]112                        restauraListaAcl $ORIGEN $DESTINO $SISTEMAFICHERO $DISCO $NPART
[4329e85]113                        RETVAL=$?
114                        exit $RETVAL
115                fi             
116        fi     
117       
118        # Restauración desde la caché
119        echo "Restaurando desde la cache" | tee -a $OGLOGSESSION $OGLOGFILE
120       
121        # Comprobar si existe caché
122        CACHE=$(montaCache)
123        if [ -z $CACHE ]; then
124                echo "No se ha podido restaurar la imagen desde la cache" | tee -a $OGLOGSESSION $OGLOGFILE
125        ogRaiseError $OG_ERR_NOTCACHE "CACHE"
126        exit $?
127        fi                     
128
129        # Borrar imagen de la caché
130        if [ $BORRACACHE -eq 1 ]; then
131                echo "Borrando imagen basica $NOMBREIMG de la cache" | tee -a $OGLOGSESSION $OGLOGFILE
132            rm -R $CACHE$OGIMG/$NOMBREIMG
133                echo "Borrando imagen incremental $NOMBREIMGINC de la cache" | tee -a $OGLOGSESSION $OGLOGFILE
134            rm -R $CACHE$OGIMG/$NOMBREIMGINC
135        fi
136       
137        # Actualización de la caché
138        echo "Actualizando cache local desde repositorio $IPREPOSITORIO" | tee -a $OGLOGSESSION $OGLOGFILE
139       
140        ORIGEN="$REPOSITORIO/$NOMBREIMG/"
141        DESTINO="$CACHE$OGIMG/$NOMBREIMG/"
142        echo "Sincronizando imagen basica entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
143        restaurarImagen $ORIGEN $DESTINO $SISTEMAFICHERO 1     
144        RETVAL=$?       
145        if [ $RETVAL -ne 0 ]; then
146           exit $OG_ERR_IMAGE
147        fi                     
148        ORIGEN="$REPOSITORIO/$NOMBREIMGINC/"
149        DESTINO="$CACHE$OGIMG/$NOMBREIMGINC/"
150        echo "Sincronizando imagen incremental entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
151        restaurarImagen $ORIGEN $DESTINO $SISTEMAFICHERO 1     
152        RETVAL=$?       
153        if [ $RETVAL -ne 0 ]; then
154           exit $OG_ERR_IMAGE
155        fi     
156
157        # Restauración desde caché a la partición
158       
159        echo "Copiando imagen basica a la partición desde cache local" | tee -a $OGLOGSESSION $OGLOGFILE
160        ORIGEN="$CACHE$OGIMG/$NOMBREIMG/"
161        DESTINO=$PARTICION$RUTAORIGEN/ 
162        echo "Sincronizando imagen entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
163        restaurarImagen $ORIGEN $DESTINO $SISTEMAFICHERO 2     
164        RETVAL=$?       
165        if [ $RETVAL -ne 0 ]; then
166           exit $OG_ERR_IMAGE
167        fi
168       
169        echo "Copiando imagen incremental a la partición desde cache local" | tee -a $OGLOGSESSION $OGLOGFILE
170        ORIGEN="$CACHE$OGIMG/$NOMBREIMGINC/"
171        DESTINO=$PARTICION$RUTAORIGEN/ 
172        OP_DELETE=""
173        echo "Sincronizando imagen entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
174        restaurarImagen $ORIGEN $DESTINO $SISTEMAFICHERO 2     
[9204a04]175        restauraListaAcl $ORIGEN $DESTINO $SISTEMAFICHERO $DISCO $NPART
[4329e85]176        RETVAL=$?       
177        if [ $RETVAL -ne 0 ]; then
178           exit $OG_ERR_IMAGE
179        fi
180#___________________________________________________________________
181#
182# Retorno
183#___________________________________________________________________
184
[9204a04]185        exit 0
Note: See TracBrowser for help on using the repository browser.