source: admin/Interface/CrearSoftIncremental @ ac8b8f58

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 ac8b8f58 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: 4.2 KB
RevLine 
[4329e85]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)
[9204a04]12# $4 Dirección del repositorio
[4329e85]13# $5 Nombre canónico de la imagen incremental (sin extensión)
14# $6 Es una cadena "nnnn" tipo flags que codifica varios parametros.
15#               Tiene el formato "nnnn" donde "n" vale 0 ó 1.   
16#               1XXX: Borrar la imagen incremental del repositorio antes de crearla
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 Ruta de origen de la Imagen (Carpeta)
22
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 nombre_imagen_incremental"
31                usage="$usage copiar_a_caché Borrar_cache_previamente 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        RUTAORIGEN=$7
50#___________________________________________________________________
51#
52# Variables y configuración logs
53#___________________________________________________________________
54       
55        source /opt/opengnsys/interfaceAdm/ImagenesSincronizadas.lib
56       
57#___________________________________________________________________
58#
59# Lista de archivos a sincronizar
60#___________________________________________________________________
61       
62        TMPFILELIST="/tmp/_listatmp_"
63        FILELIST="/tmp/_lista_"
64#___________________________________________________________________
65#
66# Proceso
67#___________________________________________________________________
68
69        echo "Creacion de imagen incremental..." | tee -a $OGLOGSESSION $OGLOGFILE
70       
71        ORIGEN=$PARTICION$RUTAORIGEN/   
72        DESTINO="$REPOSITORIO/$NOMBREIMG/"
73       
74        # Borrado previo de imagen en repositorio
75        if [ $BORRARIMG -eq 1 ]; then
[9204a04]76           echo "Borrando previamente imagen del $NOMBREIMGINC repositorio" | tee -a $OGLOGSESSION $OGLOGFILE
[4329e85]77        fi
78               
79        # Creación de la lista de archivos entre partición e imagen básica del repositorio
[9204a04]80        echo "Creacion de la lista de archivos a transferir entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
81        crearListaAcl $ORIGEN $DESTINO $SISTEMAFICHERO $DISCO $NPART   
82        crearImagen $ORIGEN $DESTINO $SISTEMAFICHERO 1 1 $TMPFILELIST   
[4329e85]83        RETVAL=$?       
84        if [ $RETVAL -ne 0 ]; then
85           exit $OG_ERR_IMAGE
86        fi     
87       
88        # Editar la lista y depurarla
89        editarLista $TMPFILELIST $FILELIST
90       
91        # Creación de la imagen incremental en el repositorio
[9204a04]92        DESTINO="$REPOSITORIO/$NOMBREIMGINC/"
[4329e85]93        echo "Sincronizacion para crear imagen incremental entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
[9204a04]94        crearImagen $ORIGEN $DESTINO $SISTEMAFICHERO 1 2 $FILELIST     
[4329e85]95        RETVAL=$?       
96        if [ $RETVAL -ne 0 ]; then
97           exit $OG_ERR_IMAGE
98        fi     
99       
100        # Copia opcional a la caché
101        if [ $COPIACACHE -eq 1 ]; then
102                echo "Copiando imagen a cache" | tee -a $OGLOGSESSION $OGLOGFILE
103                CACHE=$(montaCache)
104                if [ -z $CACHE ]; then
105                        echo "No se ha podido copiar la imagen a la cache" | tee -a $OGLOGSESSION $OGLOGFILE
106                    exit 0
107                fi             
108
109                # Borrar imagen de la caché
110                if [ $BORRACACHE -eq 1 ]; then
111                        echo "Borrando imagen $NOMBREIMGINC de la cache" | tee -a $OGLOGSESSION $OGLOGFILE
112                    rm -R $CACHE$OGIMG/$NOMBREIMGINC
113                fi     
114
115                DESTINO="$CACHE$OGIMG/$NOMBREIMGINC/"
116                echo "Sincronizando imagen entre $ORIGEN y $DESTINO" | tee -a $OGLOGSESSION $OGLOGFILE
[9204a04]117                crearImagen $ORIGEN $DESTINO $SISTEMAFICHERO 2 2 $FILELIST     
[4329e85]118                RETVAL=$?       
119                if [ $RETVAL -ne 0 ]; then
120                   exit $OG_ERR_IMAGE
121                fi             
122   fi   
[9204a04]123
124        eliminaListaAcl $ORIGEN $SISTEMAFICHERO
[4329e85]125#___________________________________________________________________
126#
127# Retorno
128#___________________________________________________________________
129
130        exit 0
[9204a04]131       
Note: See TracBrowser for help on using the repository browser.