source: client/shared/scripts/cloneRemoteFromMaster @ 5269592

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 5269592 was 2338c95f, checked in by ramon <ramongomez@…>, 14 years ago

Rama version1.0:

  • Redistribución de directorios para el cliente.
  • Modificación del instalador para adaptarse a la nueva estructura de directorios.
  • Desinstalador quita los recursos de OpenGnSys en Samba.
  • Documentación actualizada para la nueva versión.

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

  • Property mode set to 100755
File size: 6.8 KB
Line 
1#!/bin/bash
2# Script para la clonacion de particiones remotas.
3# (puede usarse como base para el programa de restauración de imágenes usado por OpenGnSys Admin).
4# Versión: 0.9.1, 2009/03/17, - Antonio J. Doblas Viso. Universidad de Malaga.
5# Versión: 0.9.2, 2010/07/27, - Antonio J. Doblas Viso. Universidad de Malaga.
6# Version: 0.1.0  2011/01/26, - Antonio J. Doblas Viso. Universidad de Malaga.
7
8TIME1=$SECONDS
9PROG="$(basename $0)"
10#if [ $# -ne 5 ]; then
11 #   ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG tamaño"
12#    exit $?
13#fi
14
15
16#/**  @function cloneremoteFromMaster: @brief Restaura una particion o imagen sobre las particiones de equipos cliente remotos
17#@param  $1 str_origen admite dirección IP del equipo Master.
18#@param $2 str_origen  admite int_disk    str_REPO|str_CACHE
19#@param $3 str_origen  admite int partorigen   stre_imagen
20#@param $4 str_sesion multicast
21#@param $5 int_disco_destino
22#@param $6 init_particion_destino
23#@param ejemplo: cloneRemoteFromMaster 172.17.36.11 1 1 9000:full-duplex:239.194.17.36:70M:50:100 1 1 partclone lzop
24#@param ejemplo: cloneRemoteFromMaster 172.17.36.11 REPO /imagen1 9000:full-duplex:239.194.17.36:70M:50:100 1 1 partclone lzop
25#@param ejemplo: cloneRemoteFromMaster 172.17.36.11 CACHE /imagen1 9000:full-duplex:239.194.17.36:70M:50:100 1 1 partclone lzop
26#@return la propia de la herramienta de clonacion partimage o ntfsclone
27#
28
29
30
31FOUNDSOURCE=false
32HOSTIP=`ogGetIpAddress`
33
34SESSIONMCASTSERVER=$4
35SESSIONMCASTCLIENT=`echo $4 | awk -F: '{print $1}'`
36DISKTARGET=$5
37PARTTARGET=$6
38TOOLCLONE=$7
39COMPRESOR=$8
40
41TIME1=$SECONDS
42PROG="$(basename $0)"
43if [ $# -lt 1 ]; then
44        echo "cloneRemoteFromMaster ipmaster disk init session disk part tool comp"
45        exit 1
46fi
47
48if [  $# -lt 5  ]; then
49    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ TORRENT|UNICAST | MULTICAST:npuerto ]"
50    exit $?
51fi
52
53#Chequeamos variables-constantes
54
55# check HOSTIP
56if [ -z "$HOSTIP" ]
57then
58        source /tmp/net-eth0.conf
59        HOSTIP=`ogGetIpAddress`
60fi
61MODEMASTER=false
62
63
64#Chequeamos parametros.
65
66# is $1 a valid IP
67MASTERIP=$1
68
69# contendor origen (disco particion o file)
70
71
72# IP destino: session multicast.
73SESSIONMCASTSERVER=$4
74SESSIONMCASTCLIENT=`echo $4 | awk -F: '{print $1}'`
75
76# contenedor destino (disco particion)
77DISKTARGET=$5
78PARTTARGET=$6
79
80#herramienta de compresión.
81TOOLCLONE=$7
82COMPRESOR=$8
83
84
85###IMG=$(ogGetPath $2 $3.img)
86###echo $IMG
87
88# Check command in Master (sendFile or sendPartition)
89####if [ -n $IMG ]
90
91
92case $MASTERIP in
93        $HOSTIP)
94                ogGetPath $2 $3.img
95                RC=`echo $?`
96                echo "$RC comenzando control del valor del origen $2 $3"
97                if [ $RC == "0" ]
98                then
99                        echo "mode senfile"
100                        IMG=$(ogGetPath $2 $3.img)
101                        MODEMASTER=SENDFILE
102                else
103                        if [ $(ogDiskToDev $2 $3) ]
104                        then
105                                echo "mode sendpartitons"
106                                DISKSOURCE=$2
107                                PARTSOURCE=$3
108                                MODEMASTER=SENDPARTITION
109                        fi
110                fi
111
112                echo "modo "  $MODEMASTER
113
114                if [ "$MODEMASTER" == "false" ]
115                then
116                        echo "cloneRemote: origen no encontrado"
117                        exit 1
118                else
119                        echo "cloneRemote: sistema preparando para un $MODEMASTER"
120                fi
121
122                case "$MODEMASTER" in
123                        SENDPARTITION)
124                                echo "[5]: cloneRemoteFromMaster: sistema preparando como MASTER modo $MODEMASTER"
125                                echo "[10]: Desmontando DISK:$DISKSOURCE PARTITION:$PARTSOURCE"
126                                ogUnmount $2 $3 || exit
127                                #Obtener tamaño de la partición.
128                                SIZE=$(ogGetPartitionSize $2 $3) 
129                                # Reducir el sistema de archvios.
130                                echo "[15]: Calculando la reduccion del sistema de archivos DISK:$DISKSOURCE PARTITION:$PARTSOURCE SIZE:$SIZE"
131                                ogReduceFs $2 $3 || exit 1
132
133                                #echo "salida de ogReduceFS" $?
134                                #if [ $? == 1 ]
135                                #then
136                                #       echo "no se ha podido reducir FS"
137#                               exit 1
138#
139                                REDSIZE=$(ogGetFsSize $2 $3)   
140                                echo "[20]: Reducido el  sistema de archivos a $REDSIZE  $DISKSOURCE $PARTSOURCE"
141                                if [ $REDSIZE -lt $SIZE ]; then
142                                        echo "[24] Redimensionar partición a $REDSIZE KB."
143                                        ogSetPartitionSize $2 $3 $REDSIZE
144                                fi
145                                echo "[25] ofreciendo informacion a los clientes-slaves"
146                                faucet 4000 --out echo "$TOOLCLONE $COMPRESOR $REDSIZE" &
147                                echo "[30] Enviando multicast "
148                                echo ogMcastSendPartition $DISKSOURCE $PARTSOURCE $SESSIONMCASTSERVER $TOOLCLONE $COMPRESOR
149                                ogMcastSendPartition $DISKSOURCE $PARTSOURCE $SESSIONMCASTSERVER $TOOLCLONE $COMPRESOR
150                                if [ $REDSIZE -lt $SIZE ]; then
151                                        echo "[85] Redimensionar partición a $SIZE KB."
152                                        ogSetPartitionSize $2 $3 $SIZE
153                                        echo "[90] Extender sistema de archivos."
154                                        ogExtendFs $2 $3
155                                fi
156                                pkill faucet
157                        ;;
158                        SENDFILE)
159                                echo "[5]: cloneRemoteFromMaster: sistema preparando como MASTER modo $MODEMASTER"
160                                echo "[10]: Preparando Imagen: $IMG"
161                                TOOLCLONE=$(ogGetImageProgram $2 $3)
162                                COMPRESOR=$(ogGetImageCompressor $2 $3)
163                                REDSIZE=$(ogGetImageSize $2 $3)
164                                echo "[25] ofreciendo informacion a los clientes-slaves: $TOOLCLONE $COMPRESOR $REDSIZE"
165                                faucet 4000 --out echo "$TOOLCLONE $COMPRESOR $REDSIZE" &
166                                echo "[30] Enviando multicast: ogMcastSendFile $2 $3.img $SESSIONMCASTSERVER "
167                                ogMcastSendFile  $2 $3.img $SESSIONMCASTSERVER
168                                pkill faucet   
169                ;;
170                esac
171                pkill faucet
172        ;;
173        *)
174                echo "[5]: cloneRemoteFromMaster: sistema preparando como CLIENTE modo $MODEMASTER"
175                ogUnmount $DISKTARGET $PARTTARGET
176                echo "[24] Cliente intentando conectar con el master $MASTERIP"
177                echo -n "[25] Buscando informacion extra sobre la clonacion: "
178                # While para esperar al servidor
179                while [ -z "$INFOEXTRA" ]
180                do
181                        INFOEXTRA=`hose $MASTERIP 4000 --in cat 2>/dev/null`
182                        sleep 10
183                        echo -n "."
184                done           
185                TOOLCLONE=$(echo $INFOEXTRA | awk '{print $1}')
186                COMPRESOR=$(echo $INFOEXTRA | awk '{print $2}')
187                SIZEIMAGE=$(echo $INFOEXTRA | awk '{print $3}')
188                echo -n "[25] $INFOEXTRA = herramienta= $TOOLCLONE  compresor= $COMPRESOR size= $SIZEIMAGE "
189                # comprobamos que el tamaño de a imagen es menor que la del cliente.
190                SIZEPARTTARGET=$(ogGetPartitionSize $DISKTARGET $PARTTARGET)
191                if [ "$SIZEIMAGE" -lt "$SIZEPARTTARGET" ]
192                then
193                        echo -n "[30] Iniciando CLIENTE MULTICAST: "
194                        echo ogMcastReceiverPartition $DISKTARGET $PARTTARGET $SESSIONMCASTCLIENT $TOOLCLONE $COMPRESOR
195                        ogMcastReceiverPartition "$DISKTARGET" "$PARTTARGET" "$SESSIONMCASTCLIENT" "$TOOLCLONE" "$COMPRESOR"
196                        echo "[90] Extender sistema de archivos"
197                        ogExtendFs $DISKTARGET $PARTTARGET
198                        # Cambiar nombre en sistemas Windows.
199                        if [ "$(ogGetOsType $DISKTARGET $PARTTARGET)" = "Windows" ]; then
200                                HOST=$(ogGetHostname)
201                                HOST=${HOST:-"UNKNOWN"}
202                                echo "[90] Cambiar nombre Windows a \"$HOST\"."
203                                ogSetWindowsName $DISKTARGET $PARTTARGET "$HOST"
204                        fi             
205                else
206                        echo -n "[25] $INFOEXTRA = herramienta= $TOOLCLONE  compresor= $COMPRESOR size= $SIZEIMAGE "
207                        echo -n "[26] ERROR tamanio particion= $SIZEPARTTARGET  tamanio de la imagen= $SIZEIMAGE"
208                        exit 1
209                fi
210        ;;
211esac
212TIME=$[SECONDS-TIME1]
213echo "[100] Duración de la operación $[TIME/60]m $[TIME%60]s"
214
215
Note: See TracBrowser for help on using the repository browser.