[914d834] | 1 | #!/bin/bash |
---|
| 2 | |
---|
[eb9424f] | 3 | #/** |
---|
| 4 | # cloneremoteFromMaster |
---|
| 5 | #@brief Restaura una particion o imagen sobre las particiones de equipos cliente remotos |
---|
| 6 | #@param 1 str_origen admite dirección IP del equipo Master. |
---|
| 7 | #@param 2 str_origen admite int_disk str_REPO|str_CACHE |
---|
| 8 | #@param 3 str_origen admite int partorigen stre_imagen |
---|
| 9 | #@param 4 str_sesion multicast|unicast |
---|
[914d834] | 10 | #@param $5 int_disco_destino |
---|
| 11 | #@param $6 init_particion_destino |
---|
[eb9424f] | 12 | #@param $7 str_tool_clone |
---|
| 13 | #@param $8 str_tool_compresor |
---|
[914d834] | 14 | #@param ejemplo: cloneRemoteFromMaster 172.17.36.11 1 1 9000:full-duplex:239.194.17.36:70M:50:100 1 1 partclone lzop |
---|
| 15 | #@param ejemplo: cloneRemoteFromMaster 172.17.36.11 REPO /imagen1 9000:full-duplex:239.194.17.36:70M:50:100 1 1 partclone lzop |
---|
| 16 | #@param ejemplo: cloneRemoteFromMaster 172.17.36.11 CACHE /imagen1 9000:full-duplex:239.194.17.36:70M:50:100 1 1 partclone lzop |
---|
[eb9424f] | 17 | #@return |
---|
| 18 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 19 | #@exception $OG_ERR_IMGSIZEPARTITION=30 #Imagen demasiado pequeña para ser clonada |
---|
| 20 | #@exception OG_ERR_REDUCEFS=17 #error al reducir sistema de archivos. |
---|
| 21 | #@exception OG_ERR_EXTENDFS=18 #errror al expandir el sistema de archivos. |
---|
| 22 | #@exception OG_ERR_UCASTSYNTAXT=50 # Error en la generación de sintaxis de transferenica unicast |
---|
| 23 | #@exception OG_ERR_UCASTSENDPARTITION=51 # Error en envio UNICAST de una particion |
---|
| 24 | #@exception OG_ERR_UCASTSENDFILE=52 # Error en envio UNICAST de un fichero |
---|
| 25 | #@exception OG_ERR_UCASTRECEIVERPARTITION=53 #Error en la recepcion UNICAST de una particion |
---|
| 26 | #@exception OG_ERR_UCASTRECEIVERFILE=54 #Error en la recepcion UNICAST de un fichero |
---|
| 27 | #@exception OG_ERR_MCASTSYNTAXT=55 # Error en la generacion de sintaxis de transferenica Multicast. |
---|
| 28 | #@exception OG_ERR_MCASTSENDFILE=56 # Error en envio MULTICAST de un fichero |
---|
| 29 | #@exception OG_ERR_MCASTRECEIVERFILE=57 #Error en la recepcion MULTICAST de un fichero |
---|
| 30 | #@exception OG_ERR_MCASTSENDPARTITION=58 # Error en envio MULTICAST de una particion |
---|
| 31 | #@exception OG_ERR_MCASTRECEIVERPARTITION=59 # Error en la recepcion MULTICAST de una particion |
---|
| 32 | #@exception OG_ERR_PROTOCOLJOINMASTER=60 # Error en la conexion de una sesion UNICAST|MULTICAST con el MASTER |
---|
| 33 | #@note |
---|
| 34 | #@todo: |
---|
| 35 | #@version 0.9.1 - integración con OpenGnsys |
---|
| 36 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 37 | #@date 2009/03/17 |
---|
| 38 | #@version 0.9.2 - adaptacion a OpenGnsys |
---|
| 39 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 40 | #@date 2010/07/27 |
---|
| 41 | #@version 0.1.0 - gestion unicast |
---|
| 42 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 43 | #@date 2011/01/26 |
---|
| 44 | #@version 1.0 - control de errores para el ogAdmServer |
---|
| 45 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 46 | #@date 2011/04/24 |
---|
[14ca521d] | 47 | #@version 1.0 - Uso de parted para controlar tamaño particion destino. Requiere Formateo FS previo -parted usa FS para el tamanyo". |
---|
| 48 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 49 | #@date 2011/04/24 |
---|
[5d52d47] | 50 | #@version 1.0.1 - Se elimina la operación de reducir la particion. |
---|
| 51 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 52 | #@date 2011/05/16 |
---|
[44eeffb] | 53 | #@version 1.0.3 - se integra con httpd-log. |
---|
| 54 | #@version 1.0.3 - Habilita el uso de la variable OGWINREDUCE=TRUE|TRUE para reducir el sistema de archivos a enviar |
---|
| 55 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 56 | #@date 2011/12/22 |
---|
[1a2fa9d8] | 57 | #@version 1.0.6 - Uso de la funcion ogExecuteAndLog |
---|
| 58 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 59 | #@date 2012/02/12 |
---|
[8c10b3d] | 60 | #@version 1.1.0.a - sesion multicast cliente puerto:master:0:0 (ticket #872) |
---|
| 61 | #@author Antonio J. Doblas Viso |
---|
| 62 | #@date 2018/09/11 |
---|
| 63 | #*/ ## |
---|
[eb9424f] | 64 | #*/ ## |
---|
[914d834] | 65 | |
---|
[445ed28] | 66 | #test 1. cliente sin particiones. Detectado TODO: crear estrucutras de particiones |
---|
| 67 | #test 2. cliente con particion mas pequeña. Detectado. |
---|
| 68 | #test 3. cleinte con particion destinio no formateado. Detectado. |
---|
| 69 | #test 4. cliente con particion destino ocupado por el usuario pwd . FALLO. |
---|
| 70 | #test 5. master sin origen particion. |
---|
| 71 | #test 6. master sin origen fichero. |
---|
| 72 | |
---|
[1a2fa9d8] | 73 | TIME1=$SECONDS |
---|
| 74 | PROG="$(basename $0)" |
---|
[445ed28] | 75 | |
---|
| 76 | trap "pkill faucet; exit 1" 0 1 2 3 6 9 14 15 |
---|
[914d834] | 77 | |
---|
[1a2fa9d8] | 78 | #AYUDA |
---|
[445ed28] | 79 | if [ $# -lt 1 -o "$1" == "help" ]; then |
---|
[1a2fa9d8] | 80 | echo "cloneRemoteFromMaster ipmaster disk init [MULTICAST|UNICAST] session disk part tool comp" |
---|
| 81 | exit 1 |
---|
[914d834] | 82 | fi |
---|
| 83 | |
---|
[1a2fa9d8] | 84 | #ERROR |
---|
| 85 | if [ $# -lt 6 ]; then |
---|
| 86 | ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ipMaster SOURCE_disco SOURCE_particion [MULTICAST|UNICAST] SESSION TARGET_disk TARGET_partition" |
---|
[914d834] | 87 | exit $? |
---|
| 88 | fi |
---|
| 89 | |
---|
[1a2fa9d8] | 90 | #Load engine configurator from engine.cfg file. |
---|
| 91 | #Carga el configurador del engine desde el fichero engine.cfg |
---|
| 92 | # Valores por defecto: #IMGPROG="partclone" ; #IMGCOMP="lzop" ; #IMGEXT="img" #IMGREDUCE="TRUE" |
---|
| 93 | [ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg |
---|
| 94 | |
---|
| 95 | # Clear temporary file used as log track by httpdlog |
---|
| 96 | # Limpia los ficheros temporales usados como log de seguimiento para httpdlog |
---|
| 97 | echo " " > $OGLOGCOMMAND |
---|
| 98 | |
---|
| 99 | ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*" |
---|
| 100 | |
---|
| 101 | # Procesar parámetros de entrada |
---|
[eb9424f] | 102 | HOSTIP=`ogGetIpAddress` |
---|
[914d834] | 103 | if [ -z "$HOSTIP" ] |
---|
| 104 | then |
---|
[eb9424f] | 105 | source /tmp/net-eth* |
---|
[914d834] | 106 | HOSTIP=`ogGetIpAddress` |
---|
| 107 | fi |
---|
[fe10bff] | 108 | MASTERIP="$1" |
---|
| 109 | PROTOCOL="$4" |
---|
| 110 | case "${PROTOCOL^^}" in |
---|
| 111 | MULTICAST) |
---|
[62ccd9b] | 112 | SESSIONMCASTSERVER=$5 |
---|
[8c10b3d] | 113 | SESSIONMCASTCLIENT=`echo $5 | awk -F: '{print $1}'`:$MASTERIP:0:0 |
---|
[62ccd9b] | 114 | ;; |
---|
[fe10bff] | 115 | UNICAST) |
---|
[62ccd9b] | 116 | SESSIONUCASTSERVER=$5 |
---|
[fe10bff] | 117 | SESSIONUCASTCLIENT=`echo $5 | awk -F: '{print $1}'`:$MASTERIP |
---|
| 118 | ;; |
---|
| 119 | *) |
---|
| 120 | exit $(ogRaiseError $OG_ERR_FORMAT "Protocolo $PROTOCOL no soportado en esta operacion"; echo $?) |
---|
| 121 | ;; |
---|
[62ccd9b] | 122 | esac |
---|
[914d834] | 123 | # contenedor destino (disco particion) |
---|
[fe10bff] | 124 | DISKTARGET="$6" |
---|
| 125 | PARTTARGET="$7" |
---|
[914d834] | 126 | #herramienta de compresión. |
---|
[fe10bff] | 127 | TOOLCLONE="$8" |
---|
| 128 | COMPRESOR="$9" |
---|
[914d834] | 129 | |
---|
[eb9424f] | 130 | pkill faucet |
---|
[914d834] | 131 | |
---|
[eb9424f] | 132 | # Preparando Instrucción según sea Master o Client |
---|
[914d834] | 133 | case $MASTERIP in |
---|
| 134 | $HOSTIP) |
---|
[1a2fa9d8] | 135 | ogEcho log session "[1] Equipo Master preparando el origen de los datos a enviar" |
---|
[eb9424f] | 136 | ogGetPath $2 $3.img &>/dev/null; RC=$?; |
---|
| 137 | ogDiskToDev $2 $3 &>/dev/null; RETVAL=$?; |
---|
| 138 | |
---|
| 139 | if [ "$RC" == "0" ]; then |
---|
| 140 | IMG=$(ogGetPath $2 $3.img); MODEMASTER=SENDFILE |
---|
| 141 | elif [ "$RETVAL" == "0" ]; then |
---|
| 142 | DISKSOURCE=$2; PARTSOURCE=$3; MODEMASTER=SENDPARTITION |
---|
[914d834] | 143 | else |
---|
[eb9424f] | 144 | ogRaiseError $OG_ERR_NOTFOUND "$2 $3"; exit $? |
---|
| 145 | fi |
---|
| 146 | echo $MODEMASTER |
---|
[445ed28] | 147 | # Preparando instrucción del Master segun $MODEMASTER{SENDPARTITION SENDFILE} |
---|
[914d834] | 148 | case "$MODEMASTER" in |
---|
| 149 | SENDPARTITION) |
---|
[fe10bff] | 150 | ogEcho log session "[5] Master en modo $MODEMASTER: informacion inicial a los clientes-slaves" |
---|
[445ed28] | 151 | if ps aux | grep -v grep | grep "faucet 4000" |
---|
| 152 | then |
---|
| 153 | ogRaiseError $OG_ERR_NOTFOUND "MASTER: puerto en uso: 118"; exit $? |
---|
| 154 | else |
---|
| 155 | faucet 4000 --out echo "WORKING" & |
---|
| 156 | fi |
---|
[fe10bff] | 157 | ogEcho log session "[10]: Desmontando DISK:$DISKSOURCE PARTITION:$PARTSOURCE" |
---|
[445ed28] | 158 | ogUnmount $2 $3 || exit $(ogRaiseError $OG_ERR_LOCKED "no se puede desmontar $2 $3 l124"; echo $?) |
---|
[914d834] | 159 | #Obtener tamaño de la partición. |
---|
[445ed28] | 160 | SIZE=$(ogGetPartitionSize $2 $3) || exit $(ogRaiseError $OG_ERR_REDUCEFS "Error al detectar tamaño partcion $2 $3 l127"; echo $?) |
---|
[44eeffb] | 161 | |
---|
[588d1eb] | 162 | # Si es UEFI copio el cargador de arranque a la partición |
---|
| 163 | OSTYPE="$(ogGetOsType $2 $3)" |
---|
| 164 | if ogIsEfiActive && [ "$OSTYPE" == "Windows" ]; then |
---|
| 165 | ogEcho log session "[12] $MSG_HELP_ogCopyEfiBootLoader" |
---|
| 166 | ogCopyEfiBootLoader $2 $3 |
---|
| 167 | fi |
---|
| 168 | |
---|
[fe10bff] | 169 | if [ "$OGWINREDUCE" == "TRUE" ] |
---|
[44eeffb] | 170 | then |
---|
[fe10bff] | 171 | ogEcho log session "[15]: Calculando la reduccion del sistema de archivos DISK:$DISKSOURCE PARTITION:$PARTSOURCE SIZE:$SIZE" |
---|
| 172 | ogReduceFs $2 $3 || exit $(ogRaiseError $OG_ERR_REDUCEFS "Error al reducir el FS $2 $3 l129"; echo $?) |
---|
[44eeffb] | 173 | fi |
---|
| 174 | |
---|
[445ed28] | 175 | REDSIZE=$(ogGetFsSize $2 $3) || exit $(ogRaiseError $OG_ERR_REDUCEFS "Error al detectar el nuevo FS $2 $3 l130"; echo $?) |
---|
[44eeffb] | 176 | TIMEAUX=$[SECONDS-TIME1] |
---|
[fe10bff] | 177 | ogEcho log session "[20]: Preparada para enviar el sistema de archivos: Tamaño datos: $REDSIZE origne: $DISKSOURCE $PARTSOURCE" |
---|
| 178 | ogEcho log session " tiempo de reducción del sistema de archivos: $[TIMEAUX/60]m $[TIMEAUX%60]s" |
---|
[44eeffb] | 179 | |
---|
[5d52d47] | 180 | #if [ $REDSIZE -lt $SIZE ]; then |
---|
| 181 | # echo "[24] Redimensionar partición a $REDSIZE KB." |
---|
| 182 | # ogSetPartitionSize $2 $3 $REDSIZE |
---|
| 183 | #fi |
---|
[44eeffb] | 184 | |
---|
[fe10bff] | 185 | ogEcho log session "[25] Master en Modo $MODEMASTER: informacion de transferencia a los clientes-slaves $PROTOCOL $TOOLCLONE $COMPRESOR $REDSIZE" |
---|
[eb9424f] | 186 | pkill faucet |
---|
[445ed28] | 187 | if ps aux | grep -v grep | grep "faucet 4000" |
---|
| 188 | then |
---|
| 189 | ogRaiseError $OG_ERR_NOTFOUND "MASTER: puerto en uso: 140"; exit $? |
---|
| 190 | else |
---|
| 191 | faucet 4000 --out echo "READY $TOOLCLONE $COMPRESOR $REDSIZE" & |
---|
| 192 | fi |
---|
[fe10bff] | 193 | case "${PROTOCOL^^}" in |
---|
| 194 | MULTICAST) |
---|
[1a2fa9d8] | 195 | ogEcho log session "[29] Transferencia Multicast: ogMcastSendPartition $DISKSOURCE $PARTSOURCE $SESSIONMCASTSERVER $TOOLCLONE $COMPRESOR " |
---|
| 196 | ogExecAndLog session "ogMcastSendPartition" "$DISKSOURCE" "$PARTSOURCE" "$SESSIONMCASTSERVER" "$TOOLCLONE" "$COMPRESOR" || RETVAL=$? |
---|
[62ccd9b] | 197 | ;; |
---|
[fe10bff] | 198 | UNICAST) |
---|
[62ccd9b] | 199 | sleep 60 |
---|
[1a2fa9d8] | 200 | ogEcho log session "[29] Transferencia Unicast: ogUcastSendPartition $DISKSOURCE $PARTSOURCE $SESSIONUCASTSERVER $TOOLCLONE $COMPRESOR" |
---|
| 201 | ogExecAndLog session "ogUcastSendPartition" "$DISKSOURCE" "$PARTSOURCE" "$SESSIONUCASTSERVER" "$TOOLCLONE" "$COMPRESOR" || RETVAL=$? |
---|
[62ccd9b] | 202 | ;; |
---|
[fe10bff] | 203 | esac |
---|
[62ccd9b] | 204 | |
---|
[5d52d47] | 205 | #if [ $REDSIZE -lt $SIZE ]; then |
---|
| 206 | # echo "[85] Redimensionar partición a $SIZE KB." |
---|
| 207 | # ogSetPartitionSize $2 $3 $SIZE |
---|
[fe10bff] | 208 | ogEcho log session "[90] Extender sistema de archivos." |
---|
[914d834] | 209 | ogExtendFs $2 $3 |
---|
[5d52d47] | 210 | #fi |
---|
[914d834] | 211 | pkill faucet |
---|
[445ed28] | 212 | if [ $RETVAL == 0 ] |
---|
| 213 | then |
---|
| 214 | exit 0 |
---|
| 215 | else |
---|
| 216 | exit $(ogRaiseError $OG_ERR_MCASTSENDPARTITION "Error al enviar la particion $2 $3 con protocolo $PROTOCOL l167"; echo $?) |
---|
| 217 | fi |
---|
[fe10bff] | 218 | |
---|
[914d834] | 219 | ;; |
---|
[eb9424f] | 220 | SENDFILE) |
---|
[fe10bff] | 221 | ogEcho log session "[5] Master en modo $MODEMASTER: informacion inicial a los clientes-slaves" |
---|
| 222 | ogEcho log session "[10]: Preparando Imagen: $IMG" |
---|
[445ed28] | 223 | TOOLCLONE=$(ogGetImageProgram $2 $3) || exit $(ogRaiseError $OG_ERR_LOCKED "TOOLCLONE no detectado l174"; echo $?) |
---|
[5d52d47] | 224 | COMPRESOR=$(ogGetImageCompressor $2 $3) || exit $(ogRaiseError $OG_ERR_LOCKED "COMPRESOR NO DETECTADO l175"; echo $?) |
---|
| 225 | REDSIZE=$(ogGetImageSize $2 $3) || exit $(ogRaiseError $OG_ERR_LOCKED "REDSIZE NO DETECTADO l176"; echo $?) |
---|
[fe10bff] | 226 | ogEcho log session "[25] Master en Modo $MODEMASTER" |
---|
| 227 | ogEcho log "Informacion de transferencia a los clientes-slaves $PROTOCOL $TOOLCLONE $COMPRESOR $REDSIZE" |
---|
[445ed28] | 228 | if ps aux | grep -v grep | grep "faucet 4000" |
---|
| 229 | then |
---|
| 230 | ogRaiseError $OG_ERR_NOTFOUND "MASTER: puerto en uso: 140"; exit $? |
---|
| 231 | else |
---|
| 232 | faucet 4000 --out echo "READY $TOOLCLONE $COMPRESOR $REDSIZE" & |
---|
[fe10bff] | 233 | fi |
---|
| 234 | case "${PROTOCOL^^}" in |
---|
| 235 | MULTICAST) |
---|
[eb9424f] | 236 | echo "[29] ogMcastSendFile $2 $3.img $SESSIONMCASTSERVER " |
---|
| 237 | ogMcastSendFile $2 $3.img $SESSIONMCASTSERVER || RETVAL=$? |
---|
| 238 | ;; |
---|
[fe10bff] | 239 | UNICAST) |
---|
[eb9424f] | 240 | sleep 60 |
---|
| 241 | echo "[29] ogUcastSendFile $2 $3.img $SESSIONUCASTSERVER" |
---|
| 242 | ogUcastSendFile $2 $3.img $SESSIONUCASTSERVER || RETVAL=$? |
---|
| 243 | ;; |
---|
| 244 | esac |
---|
[914d834] | 245 | pkill faucet |
---|
[445ed28] | 246 | if [ $RETVAL == 0 ] |
---|
| 247 | then |
---|
| 248 | exit 0 |
---|
| 249 | else |
---|
[fe10bff] | 250 | exit $(ogRaiseError $OG_ERR_MCASTSENDFILE "Error al enviar la image $2 $3.img con protocolo $PROTOCOL l200"; echo $?) |
---|
[445ed28] | 251 | fi |
---|
[eb9424f] | 252 | ;; |
---|
[914d834] | 253 | esac |
---|
[eb9424f] | 254 | # FIN Preparando instrucción del Master segun $MODEMASTER{SENDPARTITION SENDFILE} |
---|
[914d834] | 255 | ;; |
---|
[44eeffb] | 256 | *) |
---|
[fe10bff] | 257 | ogEcho log session "[1] Equipo -Client- preparando para recibir datos $PROTOCOL" |
---|
[445ed28] | 258 | ogDiskToDev $DISKTARGET $PARTTARGET &>/dev/null || exit $(ogRaiseError $OG_ERR_LOCKED "El cliente no tiene esas particiones $DISKTARGET $PARTTARGET l211"; echo $?) |
---|
[7e4db2f] | 259 | # TODO: si el cliente no está en la lista de clientes UNICAST salir. |
---|
[fe10bff] | 260 | case "${PROTOCOL^^}" in |
---|
| 261 | UNICAST) |
---|
[445ed28] | 262 | echo "$SESSIONUCASTSERVER" | grep $HOSTIP || exit $(ogRaiseError $OG_ERR_PROTOCOLJOINMASTER "Este cliente no pertence a la sesion UNICAST l214"; echo $?) |
---|
| 263 | ;; |
---|
[7e4db2f] | 264 | esac |
---|
[fe10bff] | 265 | ogEcho log session "[2] Desmontando particion destino" |
---|
[445ed28] | 266 | ogUnmount $DISKTARGET $PARTTARGET || exit $(ogRaiseError $OG_ERR_LOCKED "no se puede desmontar la particion destino $2 $3 l218"; echo $?) |
---|
[fe10bff] | 267 | ogEcho log session "[25] Buscando informacion extra sobre la clonacion con el master $MASTERIP: " |
---|
[eb9424f] | 268 | sleep 10 |
---|
| 269 | TIMEWAITMASTER=120 |
---|
| 270 | TIMEWAITING=0 |
---|
| 271 | GETINFO="NONE" |
---|
| 272 | while [ "${GETINFO}" != "OK" ] |
---|
[914d834] | 273 | do |
---|
| 274 | INFOEXTRA=`hose $MASTERIP 4000 --in cat 2>/dev/null` |
---|
[eb9424f] | 275 | sleep 10; echo -n "." |
---|
[44eeffb] | 276 | #echo comienza el timeout $TIMEWAITMASTER para abortar |
---|
[eb9424f] | 277 | [ -z "$INFOEXTRA" ] && let TIMEWAITMASTER=$TIMEWAITMASTER-10 |
---|
[445ed28] | 278 | [ "$TIMEWAITMASTER" -gt "0" ] || exit $(ogRaiseError $OG_ERR_PROTOCOLJOINMASTER " l230 "; echo $?) |
---|
[eb9424f] | 279 | #Si primer parametro desde el server es READY, salimos del bucle |
---|
| 280 | GETINFO=$(echo $INFOEXTRA | awk '{print $1}') |
---|
[fe10bff] | 281 | [ "$GETINFO" == "READY" ] && GETINFO="OK" |
---|
[914d834] | 282 | done |
---|
[eb9424f] | 283 | echo $INFOEXTRA |
---|
| 284 | TOOLCLONE=$(echo $INFOEXTRA | awk '{print $2}') |
---|
| 285 | COMPRESOR=$(echo $INFOEXTRA | awk '{print $3}') |
---|
| 286 | SIZEIMAGE=$(echo $INFOEXTRA | awk '{print $4}') |
---|
[fe10bff] | 287 | ogEcho log "$INFOEXTRA = herramienta= $TOOLCLONE compresor= $COMPRESOR size= $SIZEIMAGE" |
---|
[445ed28] | 288 | ogMount $DISKTARGET $PARTTARGET || ogFormat $DISKTARGET $PARTTARGET |
---|
[1a2fa9d8] | 289 | #SIZEPARTTARGET=$(parted `ogDiskToDev $DISKTARGET $PARTTARGET` unit kB print | grep Disk | awk -F" " '{print $3}' | tr -d kB); |
---|
| 290 | SIZEPARTTARGET=$(ogGetPartitionSize $DISKTARGET $PARTTARGET ) |
---|
[fe10bff] | 291 | ogEcho log session "[28] comprobando que el tamaño de la imagen $SIZEIMAGE es menor que el de la particion destino $SIZEPARTTARGET" |
---|
[14ca521d] | 292 | # comprobamos que el tamaño de a imagen es menor que la del cliente. |
---|
[914d834] | 293 | if [ "$SIZEIMAGE" -lt "$SIZEPARTTARGET" ] |
---|
[44eeffb] | 294 | then |
---|
[fe10bff] | 295 | ogEcho log session "[30] Iniciando Cliente $PROTOCOL " |
---|
| 296 | case "${PROTOCOL^^}" in |
---|
| 297 | MULTICAST) |
---|
| 298 | ogEcho log session "ogMcastReceiverPartition $DISKTARGET $PARTTARGET $SESSIONMCASTCLIENT $TOOLCLONE $COMPRESOR" |
---|
[1a2fa9d8] | 299 | ogExecAndLog command "ogMcastReceiverPartition" "$DISKTARGET" "$PARTTARGET" "$SESSIONMCASTCLIENT" "$TOOLCLONE" "$COMPRESOR" || exit $(ogRaiseError $OG_ERR_MCASTRECEIVERPARTITION " l251 "; echo $?) |
---|
[445ed28] | 300 | ;; |
---|
[fe10bff] | 301 | UNICAST) |
---|
| 302 | ogEcho log session "ogUcastReceiverPartition $DISKTARGET $PARTTARGET $SESSIONUCASTCLIENT $TOOLCLONE $COMPRESOR" |
---|
[1a2fa9d8] | 303 | ogExecAndLog command "ogUcastReceiverPartition" "$DISKTARGET" "$PARTTARGET" "$SESSIONUCASTCLIENT" "$TOOLCLONE" "$COMPRESOR" || exit $(ogRaiseError $OG_ERR_UCASTRECEIVERPARTITION " l230 "; echo $?) |
---|
[62ccd9b] | 304 | ;; |
---|
[445ed28] | 305 | esac |
---|
[4976431] | 306 | if which configureOsCustom &>/dev/null; then |
---|
| 307 | ogEcho log session "[90] configureOsCustom $DISKTARGET $PARTTARGET" |
---|
[501e543] | 308 | # Si $2 = num_disk las varibles REPO IMGNAME estan vacias |
---|
| 309 | ! [[ $2 =~ ^[0-9]+$ ]] && REPO="$2" && IMGNAME="$3" |
---|
| 310 | configureOsCustom $DISKTARGET $PARTTARGET $REPO $IMGNAME |
---|
[4976431] | 311 | else |
---|
| 312 | ogEcho log session "[90] $MSG_SCRIPTS_OS_CONFIGURE $DISKTARGET $PARTTARGET" |
---|
| 313 | configureOs $DISKTARGET $PARTTARGET |
---|
| 314 | fi |
---|
| 315 | |
---|
[914d834] | 316 | else |
---|
[eb9424f] | 317 | # Si el tamaño de los datos recibidos es más grande que la particion destino |
---|
[14ca521d] | 318 | ogRaiseError $OG_ERR_IMGSIZEPARTITION "ERROR tamanio particion= $SIZEPARTTARGET menor que la imagen= $SIZEIMAGE"; exit $? |
---|
[914d834] | 319 | fi |
---|
| 320 | ;; |
---|
| 321 | esac |
---|
| 322 | TIME=$[SECONDS-TIME1] |
---|
[fe10bff] | 323 | ogEcho log session "[100] Duración de la operación $[TIME/60]m $[TIME%60]s" |
---|
[914d834] | 324 | |
---|