[715bedc] | 1 | #!/bin/bash |
---|
| 2 | #/** |
---|
| 3 | #@file Image.lib |
---|
| 4 | #@brief Librería o clase Image |
---|
| 5 | #@class Image |
---|
| 6 | #@brief Funciones para creación, restauración y clonación de imágenes de sistemas. |
---|
| 7 | #@version 0.9 |
---|
| 8 | #@warning License: GNU GPLv3+ |
---|
| 9 | #*/ |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | #/** |
---|
[ebf06c7] | 13 | # ogCreateImage int_ndisk int_npartition str_repo path_image |
---|
[715bedc] | 14 | #@brief Crea una imagen a partir de una partición. |
---|
[42669ebf] | 15 | #@param int_ndisk nº de orden del disco |
---|
| 16 | #@param int_npartition nº de orden de la partición |
---|
| 17 | #@param str_repo repositorio de imágenes (remoto o caché local) |
---|
| 18 | #@param path_image camino de la imagen (sin extensión) |
---|
[715bedc] | 19 | #@return (nada, por determinar) |
---|
[ebf06c7] | 20 | #@note repo = { REPO, CACHE } |
---|
[cfeabbf] | 21 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 22 | #@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado. |
---|
| 23 | #@exception OG_ERR_PARTITION partición no accesible o no soportada. |
---|
| 24 | #@exception OG_ERR_LOCKED particion bloqueada por otra operación. |
---|
| 25 | #@exception OG_ERR_IMAGE error al crear la imagen del sistema. |
---|
[715bedc] | 26 | #@warning En pruebas iniciales |
---|
[3458879] | 27 | #@todo Comprobaciones, control de errores, definir parámetros, etc. |
---|
[985bef0] | 28 | #@version 0.1 - Integracion para Opengnsys - HIDRA:CrearImagen{EXT3, NTFS}.sh; EAC: CreateImageFromPartition () en Deploy.lib |
---|
| 29 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 30 | #@Date 2008/05/13 |
---|
| 31 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 32 | #@date 2008/10/27 |
---|
[0fbc05e] | 33 | #@version 0.9 - Versión en pruebas para OpenGnSys |
---|
[715bedc] | 34 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[cfeabbf] | 35 | #@date 2009/10/07 |
---|
[1e7eaab] | 36 | #*/ ## |
---|
[42669ebf] | 37 | function ogCreateImage () |
---|
| 38 | { |
---|
[59f9ad2] | 39 | # Variables locales |
---|
[5919303] | 40 | local PART PROGRAM IMGDIR IMGFILE ERRCODE |
---|
[59f9ad2] | 41 | |
---|
[42669ebf] | 42 | # Si se solicita, mostrar ayuda. |
---|
[59f9ad2] | 43 | if [ "$*" == "help" ]; then |
---|
| 44 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npart path_dir str_image" \ |
---|
[3543b3e] | 45 | "$FUNCNAME 1 1 REPO /aula1/winxp" |
---|
[59f9ad2] | 46 | return |
---|
| 47 | fi |
---|
[c136ae7] | 48 | # Error si no se reciben 4 parámetros. |
---|
[0fbc05e] | 49 | [ $# -ne 4 ] && ogRaiseError $OG_ERR_FORMAT && return $? |
---|
[59f9ad2] | 50 | |
---|
[715bedc] | 51 | PART="$(ogDiskToDev $1 $2)" || return $? |
---|
[a79dd508] | 52 | if ogIsLocked $1 $2; then |
---|
| 53 | ogRaiseError $OG_ERR_LOCKED "$1,$2" |
---|
| 54 | return $? |
---|
| 55 | fi |
---|
[cfeabbf] | 56 | IMGDIR=$(ogGetParentPath "$3" "$4") |
---|
| 57 | [ -n "$IMGDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$3 $(dirname $4)" || return $? |
---|
[0fbc05e] | 58 | IMGFILE="$IMGDIR/$(basename "$4").pgz" |
---|
[cfeabbf] | 59 | ogUnmount $1 $2 2>/dev/null |
---|
[715bedc] | 60 | |
---|
[a79dd508] | 61 | ogLock $1 $2 || return $? |
---|
[c2b03eb] | 62 | trap "ogUnlock $1 $2; rm -f $IMGFILE" 1 2 3 6 9 |
---|
[715bedc] | 63 | |
---|
| 64 | TYPE="$(ogGetFsType $1 $2)" |
---|
| 65 | case "$TYPE" in |
---|
[5919303] | 66 | EXT[234]) |
---|
| 67 | PROGRAM=partclone.extfs ;; |
---|
[0fbc05e] | 68 | REISERFS|XFS|JFS) |
---|
[5919303] | 69 | PROGRAM=partclone.dd ;; |
---|
[715bedc] | 70 | NTFS|HNTFS) |
---|
[5919303] | 71 | PROGRAM=partclone.ntfs ;; |
---|
[59f9ad2] | 72 | FAT16|FAT32|HFAT16|HFAT32) |
---|
[5919303] | 73 | PROGRAM=partclone.fat ;; |
---|
[0fbc05e] | 74 | HFS|HFS+) |
---|
[5919303] | 75 | PROGRAM=partclone.hfsp ;; |
---|
[cfeabbf] | 76 | *) ogRaiseError $OG_ERR_PARTITION "$1 $2 $TYPE" |
---|
[715bedc] | 77 | return $? ;; |
---|
| 78 | esac |
---|
| 79 | |
---|
[5919303] | 80 | $PROGRAM -c -C -F -s $PART | mbuffer -q -m 70% | gzip -c > "$IMGFILE" |
---|
[42669ebf] | 81 | # Controlar salida de error y desbloquear partición. |
---|
[cfeabbf] | 82 | ERRCODE=$? |
---|
[f5432db7] | 83 | if [ $ERRCODE != 0 ]; then |
---|
[cfeabbf] | 84 | ogRaiseError $OG_ERR_IMAGE "$1 $2 $IMGFILE" |
---|
[f5432db7] | 85 | rm -f "$IMGFILE" |
---|
[cfeabbf] | 86 | fi |
---|
[715bedc] | 87 | ogUnlock $1 $2 |
---|
[cfeabbf] | 88 | return $ERRCODE |
---|
[715bedc] | 89 | } |
---|
| 90 | |
---|
[b094c59] | 91 | |
---|
| 92 | #/** |
---|
[0fbc05e] | 93 | # ogGetImageFs str_repo path_image |
---|
| 94 | #@brief Devuelve el tipo de sistema de archivos almacenado en un fichero de imagen. |
---|
| 95 | #@param str_repo repositorio de imágenes o caché local |
---|
| 96 | #@param path_image camino de la imagen |
---|
| 97 | #@return str_imgtype - mnemónico del tipo de sistema de archivos |
---|
| 98 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 99 | #@exception OG_ERR_NOTFOUND fichero de imagen no encontrado. |
---|
| 100 | #@todo Comprobar salidas para todos los tipos de sistemas de archivos. |
---|
| 101 | #/** |
---|
| 102 | function ogGetImageFs () |
---|
| 103 | { |
---|
| 104 | local IMGFILE IMGTYPE |
---|
| 105 | IMGTYPE=$(ogGetImageType "$1" "$2") |
---|
| 106 | IMGFILE=$(ogGetPath "$1" "$2.$IMGTYPE") || return $? |
---|
| 107 | [ -r "$IMGFILE" ] || ogRaiseError OG_ERR_NOTFOUND "$IMGFILE" || return $? |
---|
| 108 | case "$IMGTYPE" in |
---|
| 109 | img) # Partimage. |
---|
| 110 | partimage -B gui=no imginfo "$IMGFILE" 2>&1 | \ |
---|
| 111 | awk '/^Filesystem/ {sub(/\.\.+/," "); if ($2=="ntfs") print NTFS; |
---|
| 112 | else { sub(/fs$/,""); print toupper($2);} }' |
---|
| 113 | ;; |
---|
| 114 | pgz) # Partclone / GZip |
---|
| 115 | gzip -dc "$IMGFILE" | partclone.chkimg -C -s - 2>&1 | \ |
---|
| 116 | awk '/^File system/ {if ($2=="EXTFS") print "EXT3"; else print $3;}' |
---|
| 117 | ;; |
---|
| 118 | *) # Error si el fichero de imagen no es accesible. |
---|
| 119 | ogRaiseError OG_ERR_NOTFOUND "$IMGFILE" |
---|
| 120 | return $? ;; |
---|
| 121 | esac |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | |
---|
[39277f4] | 125 | # ogGetImageSize str_repo path_image |
---|
[b094c59] | 126 | #@brief Devuelve el tamaño del sistema de archivos almacenado en un fichero de imagen. |
---|
[42669ebf] | 127 | #@param str_repo repositorio de imágenes o caché local |
---|
| 128 | #@param path_image camino de la imagen |
---|
[0fbc05e] | 129 | #@return int_size - tamaño (en KB) |
---|
[b094c59] | 130 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 131 | #@exception OG_ERR_NOTFOUND fichero de imagen no encontrado. |
---|
| 132 | #*/ |
---|
| 133 | #@warning En pruebas iniciales |
---|
| 134 | #@todo Definición de parámetros y salidas. |
---|
| 135 | #@version 0.1 - Primera versión muy en pruebas para OpenGNSys |
---|
| 136 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 137 | #@date 2009/09/11 |
---|
[1e7eaab] | 138 | #*/ ## |
---|
[42669ebf] | 139 | function ogGetImageSize () |
---|
| 140 | { |
---|
[b094c59] | 141 | # Variables locales |
---|
[0fbc05e] | 142 | local IMGFILE IMGTYPE |
---|
[b094c59] | 143 | |
---|
[42669ebf] | 144 | # Si se solicita, mostrar ayuda. |
---|
[b094c59] | 145 | if [ "$*" == "help" ]; then |
---|
| 146 | ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk int_npart" \ |
---|
[3543b3e] | 147 | "$FUNCNAME 1 1 REPO /aula1/winxp ==> 5642158" |
---|
[b094c59] | 148 | return |
---|
| 149 | fi |
---|
[42669ebf] | 150 | # Error si no se reciben menos de 2 parámetros. |
---|
[0fbc05e] | 151 | [ $# -ne 2 ] && ogRaiseError $OG_ERR_FORMAT && return $? |
---|
[42669ebf] | 152 | # Devuelve el tamaño de la imagen en KB. |
---|
[0fbc05e] | 153 | IMGTYPE=$(ogGetImageType "$1" "$2") |
---|
| 154 | IMGFILE=$(ogGetPath "$1" "$2.$IMGTYPE") |
---|
| 155 | case "$IMGTYPE" in |
---|
| 156 | img) # Partimage. |
---|
| 157 | partimage -B gui=no imginfo "$IMGFILE" 2>&1 | \ |
---|
| 158 | awk '/Partition size/ {sub(/\.\.+/," "); ps=$3} END {print ps*1024*1024;}' |
---|
| 159 | ;; |
---|
| 160 | pgz) # Partclone / GZip |
---|
| 161 | gzip -dc "$IMGFILE" | partclone.chkimg -C -s - 2>&1 | \ |
---|
| 162 | awk -F: '/Block size/ {bs=$2} /Used block/ {ub=$2} END {print bs*ub/1024}' |
---|
| 163 | ;; |
---|
| 164 | *) # Error si el fichero de imagen no es accesible. |
---|
| 165 | ogRaiseError OG_ERR_NOTFOUND "$IMGFILE" |
---|
| 166 | return $? ;; |
---|
| 167 | esac |
---|
[b094c59] | 168 | } |
---|
| 169 | |
---|
| 170 | |
---|
[39277f4] | 171 | #### PRUEBAS |
---|
| 172 | # Obtener tipo de imagen |
---|
[42669ebf] | 173 | function ogGetImageType () |
---|
| 174 | { |
---|
[0fbc05e] | 175 | local IMGFILE IMGTYPE EXT |
---|
| 176 | for EXT in img pgz; do |
---|
| 177 | IMGFILE=$(ogGetPath "$1" "$2.$EXT") |
---|
| 178 | [ -r "$IMGFILE" ] && IMGTYPE="$EXT" |
---|
| 179 | done |
---|
| 180 | echo $IMGTYPE |
---|
[39277f4] | 181 | } |
---|
| 182 | |
---|
[b094c59] | 183 | #/** |
---|
[39277f4] | 184 | # ogRestoreImage str_repo path_image int_ndisk int_npartition |
---|
[b094c59] | 185 | #@brief Restaura una imagen de sistema de archivos en una partición. |
---|
[42669ebf] | 186 | #@param str_repo repositorio de imágenes o caché local |
---|
| 187 | #@param path_image camino de la imagen |
---|
| 188 | #@param int_ndisk nº de orden del disco |
---|
| 189 | #@param int_npartition nº de orden de la partición |
---|
[b094c59] | 190 | #@return (por determinar) |
---|
| 191 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 192 | #@exception OG_ERR_NOTFOUND fichero de imagen o partición no detectados. |
---|
| 193 | #@exception OG_ERR_LOCKED partición bloqueada por otra operación. |
---|
| 194 | #@exception OG_ERR_IMAGE error al restaurar la imagen del sistema. |
---|
[39277f4] | 195 | #@todo Comprobar incongruencias partición-imagen, control de errores, definir parámetros, caché/repositorio, etc. |
---|
[0fbc05e] | 196 | #@version 0.1 - Integracion para Opengnsys - HIDRA:RestaurarImagen{EXT3, NTFS}.sh; EAC: RestorePartitionFromImage() en Deploy.lib |
---|
[985bef0] | 197 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 198 | #@Date 2008/05/13 |
---|
| 199 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 200 | #@date 2008/10/27 |
---|
[0fbc05e] | 201 | #@version 0.9 - Primera version muy en pruebas para OpenGnSys |
---|
[b094c59] | 202 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 203 | #@date 2009/09/10 |
---|
[1e7eaab] | 204 | #*/ ## |
---|
[42669ebf] | 205 | function ogRestoreImage () |
---|
| 206 | { |
---|
[b094c59] | 207 | # Variables locales |
---|
[0fbc05e] | 208 | local PART PARTSIZE IMGFILE IMGTYPE IMGSIZE FSTYPE |
---|
[b094c59] | 209 | |
---|
[42669ebf] | 210 | # Si se solicita, mostrar ayuda. |
---|
[b094c59] | 211 | if [ "$*" == "help" ]; then |
---|
| 212 | ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk int_npart" \ |
---|
[3543b3e] | 213 | "$FUNCNAME REPO /aula1/winxp 1 1" |
---|
[b094c59] | 214 | return |
---|
| 215 | fi |
---|
[42669ebf] | 216 | # Error si no se reciben 4 parámetros. |
---|
[b094c59] | 217 | [ $# -lt 4 ] && ogRaiseError $OG_ERR_FORMAT && return $? |
---|
[3458879] | 218 | # Procesar parámetros. |
---|
| 219 | PART="$(ogDiskToDev "$3" "$4")" || return $? |
---|
[0fbc05e] | 220 | IMGTYPE=$(ogGetImageType "$1" "$2") |
---|
| 221 | IMGFILE=$(ogGetPath "$1" "$2.$IMGTYPE") |
---|
[b094c59] | 222 | [ -r "$IMGFILE" ] || ogRaiseError OG_ERR_NOTFOUND "$IMGFILE" || return $? |
---|
[42669ebf] | 223 | # Error si la imagen no cabe en la particion. |
---|
[3458879] | 224 | IMGSIZE=$(ogGetImageSize "$1" "$2") |
---|
| 225 | PARTSIZE=$(ogGetPartitionSize $3 $4) |
---|
| 226 | if [ $IMGSIZE -gt $PARTSIZE ]; then |
---|
| 227 | ogRaiseError $OG_ERR_PARTITION "$IMGSIZE > $PARTSIZE" |
---|
| 228 | return $? |
---|
| 229 | fi |
---|
[b094c59] | 230 | |
---|
[42669ebf] | 231 | # Comprobar el bloqueo de la partición, desmontarla y bloquearla. |
---|
[39277f4] | 232 | if ogIsLocked $3 $4; then |
---|
| 233 | ogRaiseError $OG_ERR_LOCKED "$3,$4" |
---|
| 234 | return $? |
---|
| 235 | fi |
---|
[f5432db7] | 236 | ogUnmount $3 $4 2>/dev/null || return $? |
---|
[39277f4] | 237 | ogLock $3 $4 || return $? |
---|
[b094c59] | 238 | trap "ogUnlock $3 $4" 1 2 3 6 9 |
---|
| 239 | |
---|
[0fbc05e] | 240 | # Restaurar según el tipo de imagen. |
---|
| 241 | # Atención: no se comprueba el tipo de sistema de archivos. |
---|
[42669ebf] | 242 | # Atención: no se comprueba incongruencia entre partición e imagen. |
---|
[0fbc05e] | 243 | #FSTYPE="$(ogGetFsType $3 $4)" |
---|
| 244 | case "$IMGTYPE" in |
---|
| 245 | img) # Partimage |
---|
| 246 | partimage -M -f3 -o -d -V0 -B gui=no -c -z1 --volume=0 restore $PART "$IMGFILE" |
---|
| 247 | ;; |
---|
| 248 | pgz) # Partclone / GZip |
---|
[5919303] | 249 | gzip -dc "$IMGFILE" | mbuffer -q -m 70% | partclone.restore -C -F -o "$PART" |
---|
[0fbc05e] | 250 | ;; |
---|
| 251 | *) # Error si imagen no accesible o de tipo desconocido. |
---|
| 252 | ogRaiseError $OG_ERR_FORMAT |
---|
| 253 | return $? ;; |
---|
[b094c59] | 254 | esac |
---|
[f5432db7] | 255 | ERRCODE=$? |
---|
| 256 | if [ $ERRCODE != 0 ]; then |
---|
| 257 | ogRaiseError $OG_ERR_IMAGE "$IMGFILE, $3, $4" |
---|
| 258 | fi |
---|
[b094c59] | 259 | ogUnlock $3 $4 |
---|
[f5432db7] | 260 | return $ERRCODE |
---|
[b094c59] | 261 | } |
---|
| 262 | |
---|
[8f4c506] | 263 | |
---|
| 264 | function ogCreateImageFromPartition () { |
---|
| 265 | #/** @function CreateImageFromPartition: @brief Crea una imagen de la particion indicada, utilizando el programa definido en las variable $CloneImageNTFS y $CloneImageEXT23 |
---|
| 266 | #@param $1 int DiskEAC |
---|
| 267 | #@param $2 int_PartitionEAC |
---|
| 268 | #@param $3 str_Repositorio ......... parametro pasado a ConectToRepo, admite $REPO $CACHE str_IP_servidorAlterno |
---|
| 269 | #@param $4 str_pathbase .............. Pathbase, directorio relativo, de la imagen, en EAC, se ha definido que todo repositorio comience por hdimages, pero puede variar, para adaparse a usb, o cualquier otro almacenamiento. |
---|
| 270 | #@param $5 str_NameImage.str_compresion .......... (como compresion admite gzip y lzop) |
---|
| 271 | #@param ejemplo: CreateImageFromPartition 1 1 $IP hdimages/pruebas/ base.gzip |
---|
| 272 | #@return la propia de la herramienta de clonacion partimage o ntfsclone |
---|
| 273 | #@return genera la imagen con el nombre (imagen.compresion), y se le a?ade un guion y el numero de particion(parametro $2). |
---|
| 274 | #@return Tambien se solicita al servidor EAC, la creaci?n del fichero meta torrent, que tendra el nombre tal base.gzip-1.torrent, |
---|
| 275 | #@return Tambien se crea el fichero base.gzip-1.mcast con informacion para su uso con multicast, tal base.gzip-1.mcast |
---|
| 276 | #@warning Salidas de errores no determinada |
---|
| 277 | #@attention |
---|
| 278 | #@note Pendiente: que admita como segundo parametro el valor 0 (para que identifique el MBR del disco) |
---|
| 279 | #@version 0.1 Date: 27/10/2008 Author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 280 | #*/ |
---|
| 281 | if [ $# != 5 ] |
---|
| 282 | then |
---|
[8f20481] | 283 | echo "sintaxis: CreateImageFromPartition <ndisco> <nparticion> <iprespositorio> <pathbase> <nombreimagen.compresion>" |
---|
| 284 | echo "ejemplo: CreateImageFromPartition 1 1 \$IP images/pruebas/ base.gzip" |
---|
| 285 | echo " en iprepositorio admite cualquier ip de un servdior EAC, se llama a la funcion MountRepo ip" |
---|
[8f4c506] | 286 | fi |
---|
| 287 | if [ $# = 5 ] |
---|
| 288 | then |
---|
[8f20481] | 289 | CloneImageNTFS="${CLONETOOLSNTFS:-partimage}" |
---|
| 290 | CloneImageEXT23="${CLONETOOLSEXT:-partimage}" |
---|
| 291 | CompresionImage="${CLONETOOLSCOMPRESSOR:-gzip}" |
---|
| 292 | |
---|
[8f4c506] | 293 | disco=`ogDiskToDev $1 $2` |
---|
| 294 | ogUnmountPartition $1 $2 |
---|
| 295 | fs=`ogGetFsType $1 $2` |
---|
[8f20481] | 296 | |
---|
[8f4c506] | 297 | echo determinando tipo de Sistema Operativo y consulando la variable global CloneImageNTFS: $fs |
---|
| 298 | case $fs in |
---|
| 299 | "NTFS") |
---|
| 300 | case $CloneImageNTFS in |
---|
| 301 | "ntfsclone") |
---|
| 302 | #imaged="ntfsclone --force --save-image -O - $disco | " |
---|
| 303 | imaged="ntfsclone --force --save-image -O - $disco" |
---|
| 304 | program=ntfsclone |
---|
| 305 | ;; |
---|
| 306 | "partimage") |
---|
| 307 | #imaged="partimage -M -f3 -o -d -B gui=no -c -z0 --volume=0 save $disco stdout |" |
---|
| 308 | imaged="partimage -M -f3 -o -d -B gui=no -c -z0 --volume=0 save $disco stdout" |
---|
| 309 | program=partimage |
---|
| 310 | ;; |
---|
| 311 | "partimage-ng") |
---|
| 312 | #echo "partimage-ng" |
---|
| 313 | #imaged="partimage-ng save $disco stdout" |
---|
| 314 | program=partimage-ng |
---|
| 315 | ;; |
---|
| 316 | "partclone") |
---|
| 317 | #echo "partclone" |
---|
| 318 | #imaged="partclone.ntfs -c -F -s $disco | " |
---|
| 319 | imaged="partclone.ntfs -c -F -s $disco" |
---|
| 320 | program=partclone.ntfs |
---|
| 321 | #zcat ~/image_sda1.pcl.gz | partclone.ext4 -r -o /dev/sda1 |
---|
| 322 | ;; |
---|
| 323 | esac |
---|
| 324 | ;; |
---|
| 325 | EXT[234]|REISERFS) |
---|
| 326 | case $CloneImageEXT23 in |
---|
| 327 | "partimage") |
---|
| 328 | imaged="partimage -M -f3 -o -d -B gui=no -c -z0 --volume=0 save $disco stdout" |
---|
| 329 | program=partimage |
---|
| 330 | ;; |
---|
| 331 | "partimage-ng") |
---|
| 332 | #echo "partimage-ng" |
---|
| 333 | imaged="partimage-ng save $disco stdout" |
---|
| 334 | program=partimage-ng |
---|
| 335 | ;; |
---|
| 336 | "partclone") |
---|
| 337 | echo "partclone" |
---|
| 338 | imaged="partclone.ext3 -c -F -C -s $disco" |
---|
| 339 | program=partclone.ext3 |
---|
| 340 | #zcat ~/image_sda1.pcl.gz | partclone.ext4 -r -o /dev/sda1 |
---|
| 341 | ;; |
---|
| 342 | esac |
---|
| 343 | ;; |
---|
| 344 | esac |
---|
| 345 | |
---|
| 346 | # utilizando mbuffer para reducir posibles errores de acceso a discos |
---|
| 347 | imaged="$imaged | mbuffer -m 70%" |
---|
| 348 | #metodo de compresion. |
---|
[8f20481] | 349 | case $CompresionImage in |
---|
| 350 | "gzip") |
---|
| 351 | comando="$imaged | gzip -c >" |
---|
| 352 | ;; |
---|
| 353 | "lzop") |
---|
| 354 | comando="$imaged | lzop >" |
---|
| 355 | ;; |
---|
| 356 | esac |
---|
| 357 | |
---|
[8f4c506] | 358 | #. determnamos el fichero donde se almacenar? la image |
---|
| 359 | #camino=`ConnectToRepo $3 $4 $5` |
---|
| 360 | #MkdirPath $camino |
---|
| 361 | firstcamino=`ogNewPath $3 $4` |
---|
| 362 | camino=$firstcamino$5 |
---|
| 363 | echo $camino |
---|
| 364 | sleep 1 |
---|
[8f20481] | 365 | |
---|
[8f4c506] | 366 | #preparamos y ejecutamos el comanod a realizar |
---|
| 367 | echo "Creando imagen particion $disco programa $program compresion $CompresionImage en el repositorio $3 como $4 $5 - $2" |
---|
| 368 | comando="$comando ${camino}-$2" |
---|
| 369 | echo "comando: $comando" |
---|
| 370 | echo $comando > /tmp/run.sh |
---|
| 371 | sh /tmp/run.sh |
---|
| 372 | unset comando |
---|
[8f20481] | 373 | |
---|
[8f4c506] | 374 | #iniciamos la creacion del torrent |
---|
| 375 | echo "Iniciando la creacion del punto torrent con CreateTorrentFromImage ip=$3 path=$4 image=$5-$2" echo |
---|
[8f20481] | 376 | #CreateTorrentFromImage $3 $4 $5-$2 |
---|
[8f4c506] | 377 | # iniciacmos el putno mcast |
---|
| 378 | echo "creando un punto mcast ${camino}-$2.mcast" |
---|
| 379 | echo "program;$program" > ${camino}.mcast |
---|
| 380 | echo "compresion;$CompresionImage" >> ${camino}.mcast |
---|
| 381 | echo "fsimage;$fs" >> ${camino}.mcast |
---|
| 382 | |
---|
| 383 | #UmountRepo $3 |
---|
| 384 | fi |
---|
| 385 | } |
---|