[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. |
---|
[e39921b] | 7 | #@version 1.1.0 |
---|
[715bedc] | 8 | #@warning License: GNU GPLv3+ |
---|
| 9 | #*/ |
---|
| 10 | |
---|
[914d834] | 11 | |
---|
[e39921b] | 12 | #/** |
---|
[2fc81c4] | 13 | # ogCreateImageSyntax path_device path_filename [str_tool] [str_compressionlevel] |
---|
[914d834] | 14 | #@brief Genera una cadena de texto con la instrucción para crear un fichero imagen |
---|
[bbe1bcf] | 15 | #@param path_device dispositivo Linux del sistema de archivos |
---|
[2fc81c4] | 16 | #@param path_fileneme path absoluto del fichero imagen |
---|
[bbe1bcf] | 17 | #@param [opcional] str_tool herrmaienta de clonacion [partimage, partclone, ntfsclone] |
---|
| 18 | #@param [opcional] str_compressionlevel nivel de compresion. [0 -none-, 1-lzop-, 2-gzip] |
---|
| 19 | #@return str_command - cadena con el comando que se debe ejecutar. |
---|
| 20 | #@warning Salida nula si se producen errores. |
---|
[914d834] | 21 | #@TODO introducir las herramientas fsarchiver, dd |
---|
| 22 | #@version 1.0 - Primeras pruebas |
---|
| 23 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 24 | #@date 2010/02/08 |
---|
[bbe1bcf] | 25 | #@version 1.0.5 - Incrustar códico de antigua función ogPartcloneSyntax |
---|
| 26 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 27 | #@date 2012/09/14 |
---|
[914d834] | 28 | #*/ ## |
---|
| 29 | function ogCreateImageSyntax() |
---|
| 30 | { |
---|
[1feb465] | 31 | local FS TOOL LEVEL DEV IMGFILE BUFFER PARAM1 PARAM2 PARAM3 |
---|
[914d834] | 32 | |
---|
| 33 | # Si se solicita, mostrar ayuda. |
---|
| 34 | if [ "$*" == "help" ]; then |
---|
[bbe1bcf] | 35 | ogHelp "$FUNCNAME" "$FUNCNAME path_device path_imagefile [str_tool] [str_compressionlevel]" \ |
---|
| 36 | "$FUNCNAME /dev/sda1 /opt/opengnsys/images/prueba.img partclone lzop" \ |
---|
| 37 | "$FUNCNAME /dev/sda1 /opt/opengnsys/images/prueba.img" |
---|
[914d834] | 38 | return |
---|
| 39 | fi |
---|
[2fc81c4] | 40 | # Error si no se reciben entre 2 y 4 parámetros. |
---|
| 41 | [ $# -ge 2 -a $# -le 4 ] || ogRaiseError $OG_ERR_FORMAT "$*" || return $? |
---|
[914d834] | 42 | |
---|
[2fc81c4] | 43 | # Asignación de parámetros. |
---|
[1feb465] | 44 | DEV="$1" |
---|
[bbe1bcf] | 45 | IMGFILE="$2" |
---|
[914d834] | 46 | case "$#" in |
---|
[1feb465] | 47 | 2) # Sintaxis por defecto OG DEV IMGFILE |
---|
[bbe1bcf] | 48 | TOOL="partclone" |
---|
| 49 | LEVEL="gzip" |
---|
| 50 | ;; |
---|
| 51 | 4) # Sintaxis condicionada. |
---|
| 52 | TOOL="${3,,}" |
---|
| 53 | LEVEL="${4,,}" |
---|
| 54 | ;; |
---|
| 55 | esac |
---|
[914d834] | 56 | |
---|
[bbe1bcf] | 57 | case "$TOOL" in |
---|
| 58 | ntfsclone) |
---|
[1feb465] | 59 | PARAM1="ntfsclone --force --save-image -O - $DEV" |
---|
[bbe1bcf] | 60 | ;; |
---|
| 61 | partimage|default) |
---|
[1feb465] | 62 | PARAM1="partimage -M -f3 -o -d -B gui=no -c -z0 --volume=0 save $DEV stdout" |
---|
[bbe1bcf] | 63 | ;; |
---|
| 64 | partclone) |
---|
[1feb465] | 65 | FS="$(ogGetFsType $(ogDevToDisk $DEV 2>/dev/null) 2>/dev/null)" |
---|
[bbe1bcf] | 66 | case "$FS" in |
---|
| 67 | EXT[234]) PARAM1="partclone.extfs" ;; |
---|
| 68 | BTRFS) PARAM1="partclone.btrfs" ;; |
---|
| 69 | REISERFS) PARAM1="partclone.reiserfs" ;; |
---|
| 70 | REISER4) PARAM1="partclone.reiser4" ;; |
---|
| 71 | JFS) PARAM1="partclone.jfs" ;; |
---|
| 72 | XFS) PARAM1="partclone.xfs" ;; |
---|
[48c9e6e] | 73 | F2FS) PARAM1="partclone.f2fs" ;; |
---|
| 74 | NILFS2) PARAM1="partclone.nilfs2" ;; |
---|
[bbe1bcf] | 75 | NTFS) PARAM1="partclone.ntfs" ;; |
---|
[9836a86] | 76 | EXFAT) PARAM1="partclone.exfat" ;; |
---|
[bbe1bcf] | 77 | FAT16|FAT32) PARAM1="partclone.fat" ;; |
---|
| 78 | HFS|HFSPLUS) PARAM1="partclone.hfsp" ;; |
---|
[9836a86] | 79 | UFS) PARAM1="partclone.ufs" ;; |
---|
[48c9e6e] | 80 | VMFS) PARAM1="partclone.vmfs" ;; |
---|
| 81 | *) PARAM1="partclone.imager" ;; |
---|
[bbe1bcf] | 82 | esac |
---|
[9836a86] | 83 | # Por compatibilidad, si no existe el ejecutable usar por defecto "parclone.dd". |
---|
| 84 | which $PARAM1 &>/dev/null || PARAM1="partclone.dd" |
---|
[1feb465] | 85 | PARAM1="$PARAM1 -d0 -F -c -s $DEV" |
---|
[46a1ff9] | 86 | # El programa partclone.dd no tiene opción "-c". |
---|
[a30ad15f] | 87 | [[ "$PARAM1" =~ ^partclone.dd ]] && PARAM1="${PARAM1/ -c / }" |
---|
[1feb465] | 88 | ;; |
---|
| 89 | esac |
---|
| 90 | # Comprobar que existe mbuffer. |
---|
[9836a86] | 91 | which mbuffer &>/dev/null && PARAM2="| mbuffer -q -m 40M " || PARAM2=" " |
---|
[bbe1bcf] | 92 | |
---|
| 93 | # Nivel de compresion. |
---|
| 94 | case "$LEVEL" in |
---|
| 95 | 0|none) PARAM3=" > " ;; |
---|
| 96 | 1|lzop) PARAM3=" | lzop > " ;; |
---|
| 97 | 2|gzip) PARAM3=" | gzip -c > " ;; |
---|
| 98 | 3|bzip) PARAM3=" | bzip -c > " ;; |
---|
[914d834] | 99 | esac |
---|
[bbe1bcf] | 100 | |
---|
| 101 | # Sintaxis final. |
---|
| 102 | [ -n "$PARAM1" ] && echo "$PARAM1 $PARAM2 $PARAM3 $IMGFILE" |
---|
[914d834] | 103 | } |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | #/** |
---|
[2fc81c4] | 107 | # ogRestoreImageSyntax path_filename path_device [str_tools] [str_compressionlevel] |
---|
[914d834] | 108 | #@brief Genera una cadena de texto con la instrucción para crear un fichero imagen |
---|
[2fc81c4] | 109 | #@param path_device dispositivo Linux del sistema de archivos |
---|
| 110 | #@param path_fileneme path absoluto del fichero imagen |
---|
| 111 | #@param [opcional] str_tools herrmaienta de clonacion [partimage, partclone, ntfsclone] |
---|
| 112 | #@param [opcional] str_compressionlevel nivel de compresion. [0 -none-, 1-lzop-, 2-gzip] |
---|
[914d834] | 113 | #@return cadena con el comando que se debe ejecutar. |
---|
| 114 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 115 | #@warning En pruebas iniciales |
---|
| 116 | #@TODO introducir las herramientas fsarchiver, dd |
---|
| 117 | #@TODO introducir el nivel de compresion gzip |
---|
| 118 | #@version 1.0 - Primeras pruebas |
---|
| 119 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 120 | #@date 2010/02/08 |
---|
| 121 | #*/ ## |
---|
[46a1ff9] | 122 | function ogRestoreImageSyntax () |
---|
[914d834] | 123 | { |
---|
| 124 | local TOOL COMPRESSOR LEVEL PART IMGFILE FILEHEAD INFOIMG |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | # Si se solicita, mostrar ayuda. |
---|
| 128 | if [ "$*" == "help" ]; then |
---|
| 129 | ogHelp "$FUNCNAME" "$FUNCNAME filename partition [tool] [levelcompresor]" \ |
---|
| 130 | "$FUNCNAME /opt/opengnsys/images/prueba.img /dev/sda1 [partclone] [lzop]" |
---|
| 131 | return |
---|
| 132 | fi |
---|
| 133 | |
---|
[2fc81c4] | 134 | # Error si no se reciben entre 2 y 4 parámetros. |
---|
| 135 | [ $# -ge 2 -a $# -le 4 ] || ogRaiseError $OG_ERR_FORMAT "$*" || return $? |
---|
[914d834] | 136 | |
---|
| 137 | # controlamos que el parametro 1 (imagen) es tipo file. |
---|
| 138 | [ -f $1 ] || ogRaiseError $OG_ERR_NOTFOUND "$1" || return $? |
---|
| 139 | |
---|
| 140 | # Si 2 parametros (file-origen-, device-destino-) = ogGetImageFull($1) |
---|
| 141 | if [ "$#" -eq 2 ]; then |
---|
| 142 | IMGFILE=$1 |
---|
| 143 | PART=$2 |
---|
| 144 | INFOIMG=$(ogGetImageInfo $IMGFILE) || ogRaiseError $OG_ERR_NOTFOUND "No Image $1" || return $? |
---|
| 145 | TOOL=`echo $INFOIMG | cut -f1 -d:` |
---|
| 146 | COMPRESSOR=`echo $INFOIMG | cut -f2 -d:` |
---|
| 147 | ogRestoreImageSyntax $IMGFILE $PART $TOOL $COMPRESSOR |
---|
| 148 | fi |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | # Si cuatro parametros genera sintaxis |
---|
| 152 | if [ "$#" -eq 4 ]; then |
---|
| 153 | IMGFILE=$1 |
---|
| 154 | PART=$2 |
---|
| 155 | # comprobamos parametro herramienta compresion. |
---|
| 156 | TOOL=$(echo $3 | tr [A-Z] [a-z]) |
---|
| 157 | #ogCheckProgram $TOOL |
---|
| 158 | #comprobar parámetro compresor. |
---|
| 159 | LEVEL=$(echo $4 | tr [A-Z] [a-z]) |
---|
| 160 | #ogCheckProgram $LEVEL |
---|
| 161 | |
---|
| 162 | case "$LEVEL" in |
---|
| 163 | "0"|"none") |
---|
| 164 | COMPRESSOR=" " |
---|
| 165 | ;; |
---|
| 166 | "1"|"lzop" | "LZOP") |
---|
| 167 | COMPRESSOR=" lzop -dc " |
---|
| 168 | ;; |
---|
| 169 | "2"|"gzip" | "GZIP") |
---|
| 170 | COMPRESSOR=" gzip -dc " |
---|
| 171 | ;; |
---|
| 172 | "3"|"bzip" | "BZIP" ) |
---|
| 173 | COMPRESSOR=" bzip -dc " |
---|
| 174 | ;; |
---|
| 175 | *) |
---|
| 176 | ogRaiseError $OG_ERR_NOTFOUND "Compressor no valid $TOOL" || return $? |
---|
| 177 | ;; |
---|
| 178 | esac |
---|
| 179 | #comprobar mbuffer |
---|
| 180 | which mbuffer > /dev/null && MBUFFER="| mbuffer -q -m 40M " || MBUFFER=" " |
---|
| 181 | |
---|
| 182 | case "$TOOL" in |
---|
| 183 | "ntfsclone" | "NTFSCLONE") |
---|
| 184 | TOOL="| ntfsclone --restore-image --overwrite $PART -" |
---|
| 185 | ;; |
---|
| 186 | "partimage"| "PARTIMAGE") |
---|
| 187 | TOOL="| partimage -f3 -B gui=no restore $PART stdin" |
---|
| 188 | ;; |
---|
| 189 | "partclone" | "PARTCLONE") |
---|
| 190 | # -C para que no compruebe tamaños |
---|
[0084b42] | 191 | TOOL="| partclone.restore -d0 -C -I -o $PART" |
---|
[914d834] | 192 | ;; |
---|
[46a1ff9] | 193 | partclone.dd) |
---|
[1feb465] | 194 | TOOL="| pv | dd conv=sync,noerror bs=1M of=$PART" |
---|
| 195 | ;; |
---|
[914d834] | 196 | *) |
---|
| 197 | ogRaiseError $OG_ERR_NOTFOUND "Tools imaging no valid $TOOL" || return $? |
---|
| 198 | ;; |
---|
| 199 | esac |
---|
| 200 | |
---|
| 201 | echo "$COMPRESSOR $IMGFILE $MBUFFER $TOOL" |
---|
| 202 | fi |
---|
| 203 | |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | |
---|
| 207 | |
---|
[715bedc] | 208 | |
---|
| 209 | #/** |
---|
[1c9ef24] | 210 | # ogCreateDiskImage int_ndisk str_repo path_image [str_tools] [str_compressionlevel] |
---|
| 211 | #@brief Crea una imagen (copia de seguridad) de un disco completo. |
---|
| 212 | #@param int_ndisk nº de orden del disco |
---|
| 213 | #@param str_repo repositorio de imágenes (remoto o caché local) |
---|
| 214 | #@param path_image camino de la imagen (sin extensión) |
---|
| 215 | #@return (nada, por determinar) |
---|
| 216 | #@note repo = { REPO, CACHE } |
---|
| 217 | #@note Esta primera versión crea imágenes con dd comprimidas con gzip. |
---|
| 218 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 219 | #@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado. |
---|
| 220 | #@exception OG_ERR_LOCKED particion bloqueada por otra operación. |
---|
| 221 | #@exception OG_ERR_IMAGE error al crear la imagen del sistema. |
---|
| 222 | #@warning En pruebas iniciales |
---|
| 223 | #@todo Gestión de bloqueos de disco |
---|
| 224 | #@todo Comprobar si debe desmontarse la caché local |
---|
| 225 | #@todo Comprobar que no se crea la imagen en el propio disco |
---|
| 226 | #@version 1.1.0 - Primera versión para OpenGnsys con herramientas prefijadas. |
---|
| 227 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 228 | #@Date 2016/04/08 |
---|
| 229 | #*/ ## |
---|
| 230 | function ogCreateDiskImage () |
---|
| 231 | { |
---|
| 232 | # Variables locales |
---|
| 233 | local DISK PROGRAM IMGDIR IMGFILE IMGTYPE ERRCODE |
---|
| 234 | |
---|
| 235 | # Si se solicita, mostrar ayuda. |
---|
| 236 | if [ "$*" == "help" ]; then |
---|
| 237 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk path_dir str_image" \ |
---|
| 238 | "$FUNCNAME 1 REPO /disk1" |
---|
| 239 | return |
---|
| 240 | fi |
---|
| 241 | # Error si no se reciben entre 3 y 5 parámetros. |
---|
| 242 | [ $# -ge 3 -a $# -le 5 ] || ogRaiseError $OG_ERR_FORMAT "$*" || return $? |
---|
| 243 | |
---|
| 244 | # Comprobar que no está bloqueada ni la partición, ni la imagen. |
---|
| 245 | DISK="$(ogDiskToDev $1)" || return $? |
---|
[a30ad15f] | 246 | if ogIsDiskLocked $1; then |
---|
[1c9ef24] | 247 | ogRaiseError $OG_ERR_LOCKED "$MSG_LOCKED $1" |
---|
| 248 | return $? |
---|
| 249 | fi |
---|
| 250 | IMGTYPE="dsk" # Extensión genérica de imágenes de disco. |
---|
| 251 | IMGDIR=$(ogGetParentPath "$2" "$3") |
---|
| 252 | [ -n "$IMGDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$2 $(dirname $3)" || return $? |
---|
| 253 | IMGFILE="$IMGDIR/$(basename "$3").$IMGTYPE" |
---|
| 254 | if ogIsImageLocked "$IMGFILE"; then |
---|
| 255 | ogRaiseError $OG_ERR_LOCKED "$MSG_IMAGE $3, $4" |
---|
| 256 | return $? |
---|
| 257 | fi |
---|
[bac2d63] | 258 | |
---|
| 259 | # No guardar imagen en el propio disco (disco no incluido en el camino del repositorio). |
---|
| 260 | if [[ $(ogGetPath "$2" /) =~ ^$DISK ]]; then |
---|
| 261 | ogRaiseError $OG_ERR_IMAGE "$2 = $DISK" |
---|
| 262 | return $? |
---|
| 263 | fi |
---|
| 264 | |
---|
[1c9ef24] | 265 | # Generar la instruccion a ejecutar antes de aplicar los bloqueos. |
---|
[46a1ff9] | 266 | PROGRAM=$(ogCreateImageSyntax $DISK $IMGFILE) |
---|
[bac2d63] | 267 | # Desmontar todos los sistemas de archivos del disco, bloquear disco e imagen. |
---|
[1c9ef24] | 268 | ogUnmountAll $1 2>/dev/null |
---|
| 269 | ogLockDisk $1 || return $? |
---|
| 270 | ogLockImage "$2" "$3.$IMGTYPE" || return $? |
---|
| 271 | |
---|
| 272 | # Crear Imagen. |
---|
| 273 | trap "ogUnlockDisk $1; ogUnlockImage "$3" "$4.$IMGTYPE"; rm -f $IMGFILE" 1 2 3 6 9 |
---|
| 274 | eval $PROGRAM |
---|
| 275 | |
---|
| 276 | # Controlar salida de error y desbloquear partición. |
---|
| 277 | ERRCODE=$? |
---|
| 278 | if [ $ERRCODE != 0 ]; then |
---|
| 279 | ogRaiseError $OG_ERR_IMAGE "$1 $2 $IMGFILE" |
---|
| 280 | rm -f "$IMGFILE" |
---|
| 281 | fi |
---|
[bac2d63] | 282 | # Desbloquear disco e imagen. |
---|
[1c9ef24] | 283 | ogUnlockDisk $1 |
---|
| 284 | ogUnlockImage "$2" "$3.$IMGTYPE" |
---|
| 285 | return $ERRCODE |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | |
---|
| 289 | |
---|
| 290 | #/** |
---|
[2fc81c4] | 291 | # ogCreateImage int_ndisk int_npartition str_repo path_image [str_tools] [str_compressionlevel] |
---|
[715bedc] | 292 | #@brief Crea una imagen a partir de una partición. |
---|
[42669ebf] | 293 | #@param int_ndisk nº de orden del disco |
---|
| 294 | #@param int_npartition nº de orden de la partición |
---|
| 295 | #@param str_repo repositorio de imágenes (remoto o caché local) |
---|
| 296 | #@param path_image camino de la imagen (sin extensión) |
---|
[2fc81c4] | 297 | #@param [opcional] str_tools herrmaienta de clonacion [partimage, partclone, ntfsclone] |
---|
| 298 | #@param [opcional] str_compressionlevel nivel de compresion. [0 -none-, 1-lzop-, 2-gzip] |
---|
[715bedc] | 299 | #@return (nada, por determinar) |
---|
[ebf06c7] | 300 | #@note repo = { REPO, CACHE } |
---|
[cfeabbf] | 301 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 302 | #@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado. |
---|
| 303 | #@exception OG_ERR_PARTITION partición no accesible o no soportada. |
---|
| 304 | #@exception OG_ERR_LOCKED particion bloqueada por otra operación. |
---|
| 305 | #@exception OG_ERR_IMAGE error al crear la imagen del sistema. |
---|
[3458879] | 306 | #@todo Comprobaciones, control de errores, definir parámetros, etc. |
---|
[985bef0] | 307 | #@version 0.1 - Integracion para Opengnsys - HIDRA:CrearImagen{EXT3, NTFS}.sh; EAC: CreateImageFromPartition () en Deploy.lib |
---|
[bbe1bcf] | 308 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[985bef0] | 309 | #@Date 2008/05/13 |
---|
| 310 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 311 | #@date 2008/10/27 |
---|
[0fbc05e] | 312 | #@version 0.9 - Versión en pruebas para OpenGnSys |
---|
[715bedc] | 313 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[cfeabbf] | 314 | #@date 2009/10/07 |
---|
[bbe1bcf] | 315 | #@version 1.0 - Llama a función ogCreateImageSyntax para generar la llamada al comando. |
---|
| 316 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 317 | #@date 2010/02/08 |
---|
[1e7eaab] | 318 | #*/ ## |
---|
[42669ebf] | 319 | function ogCreateImage () |
---|
| 320 | { |
---|
[59f9ad2] | 321 | # Variables locales |
---|
[08b941f] | 322 | local PART PROGRAM IMGDIR IMGFILE IMGTYPE ERRCODE |
---|
[59f9ad2] | 323 | |
---|
[42669ebf] | 324 | # Si se solicita, mostrar ayuda. |
---|
[59f9ad2] | 325 | if [ "$*" == "help" ]; then |
---|
| 326 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npart path_dir str_image" \ |
---|
[3543b3e] | 327 | "$FUNCNAME 1 1 REPO /aula1/winxp" |
---|
[59f9ad2] | 328 | return |
---|
| 329 | fi |
---|
[2fc81c4] | 330 | # Error si no se reciben entre 4 y 6 parámetros. |
---|
| 331 | [ $# -ge 4 -a $# -le 6 ] || ogRaiseError $OG_ERR_FORMAT "$*" || return $? |
---|
[59f9ad2] | 332 | |
---|
[08b941f] | 333 | # Comprobar que no está bloqueada ni la partición, ni la imagen. |
---|
[715bedc] | 334 | PART="$(ogDiskToDev $1 $2)" || return $? |
---|
[a79dd508] | 335 | if ogIsLocked $1 $2; then |
---|
[e39921b] | 336 | ogRaiseError $OG_ERR_LOCKED "$MSG_LOCKED $1, $2" |
---|
[a79dd508] | 337 | return $? |
---|
| 338 | fi |
---|
[a73649d] | 339 | |
---|
[914d834] | 340 | IMGTYPE="img" # Extensión genérica de imágenes. |
---|
[cfeabbf] | 341 | IMGDIR=$(ogGetParentPath "$3" "$4") |
---|
| 342 | [ -n "$IMGDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$3 $(dirname $4)" || return $? |
---|
[a73649d] | 343 | |
---|
[08b941f] | 344 | IMGFILE="$IMGDIR/$(basename "$4").$IMGTYPE" |
---|
| 345 | if ogIsImageLocked "$IMGFILE"; then |
---|
| 346 | ogRaiseError $OG_ERR_LOCKED "$MSG_IMAGE $3, $4" |
---|
| 347 | return $? |
---|
| 348 | fi |
---|
[bbe1bcf] | 349 | # Generar la instruccion a ejecutar antes de aplicar los bloqueos. |
---|
| 350 | PROGRAM=$(ogCreateImageSyntax $PART $IMGFILE $5 $6) |
---|
[08b941f] | 351 | # Desmontar partición, bloquear partición e imagen. |
---|
[cfeabbf] | 352 | ogUnmount $1 $2 2>/dev/null |
---|
[a79dd508] | 353 | ogLock $1 $2 || return $? |
---|
[08b941f] | 354 | ogLockImage "$3" "$4.$IMGTYPE" || return $? |
---|
[715bedc] | 355 | |
---|
[08b941f] | 356 | # Crear Imagen. |
---|
| 357 | trap "ogUnlock $1 $2; ogUnlockImage "$3" "$4.$IMGTYPE"; rm -f $IMGFILE" 1 2 3 6 9 |
---|
[914d834] | 358 | eval $PROGRAM |
---|
[08b941f] | 359 | |
---|
[42669ebf] | 360 | # Controlar salida de error y desbloquear partición. |
---|
[cfeabbf] | 361 | ERRCODE=$? |
---|
[f5432db7] | 362 | if [ $ERRCODE != 0 ]; then |
---|
[cfeabbf] | 363 | ogRaiseError $OG_ERR_IMAGE "$1 $2 $IMGFILE" |
---|
[f5432db7] | 364 | rm -f "$IMGFILE" |
---|
[cfeabbf] | 365 | fi |
---|
[08b941f] | 366 | # Desbloquear partición e imagen. |
---|
[715bedc] | 367 | ogUnlock $1 $2 |
---|
[08b941f] | 368 | ogUnlockImage "$3" "$4.$IMGTYPE" |
---|
[cfeabbf] | 369 | return $ERRCODE |
---|
[715bedc] | 370 | } |
---|
| 371 | |
---|
[b094c59] | 372 | |
---|
[a25cc03] | 373 | #/** |
---|
| 374 | # ogCreateMbrImage int_ndisk str_repo path_image |
---|
| 375 | #@brief Crea una imagen a partir del sector de arranque de un disco. |
---|
| 376 | #@param int_ndisk nº de orden del disco |
---|
| 377 | #@param str_repo repositorio de imágenes (remoto o caché local) |
---|
| 378 | #@param path_image camino de la imagen (sin extensión) |
---|
| 379 | #@return (nada, por determinar) |
---|
| 380 | #@note repo = { REPO, CACHE } |
---|
| 381 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 382 | #@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado. |
---|
| 383 | #@exception OG_ERR_IMAGE error al crear la imagen del sistema. |
---|
| 384 | #@version 0.9 - Versión en pruebas para OpenGNSys |
---|
| 385 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 386 | #@date 2010/01/12 |
---|
| 387 | #@version 1.0 - Adaptación a OpenGnSys 1.0 |
---|
| 388 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 389 | #@date 2011/03/10 |
---|
| 390 | #*/ ## |
---|
| 391 | function ogCreateMbrImage () |
---|
| 392 | { |
---|
| 393 | # Variables locales |
---|
| 394 | local DISK IMGDIR IMGFILE |
---|
| 395 | # Si se solicita, mostrar ayuda. |
---|
| 396 | if [ "$*" == "help" ]; then |
---|
| 397 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk path_dir str_image" \ |
---|
| 398 | "$FUNCNAME 1 REPO /aula1/mbr" |
---|
| 399 | return |
---|
| 400 | fi |
---|
| 401 | # Error si no se reciben 3 parámetros. |
---|
[a73649d] | 402 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[a25cc03] | 403 | |
---|
| 404 | DISK=$(ogDiskToDev "$1") || return $? |
---|
| 405 | IMGDIR=$(ogGetParentPath "$2" "$3") |
---|
| 406 | [ -n "$IMGDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$2 $(dirname $3)" || return $? |
---|
| 407 | IMGFILE="$IMGDIR/$(basename "$3").mbr" |
---|
| 408 | |
---|
| 409 | # Crear imagen del MBR. |
---|
| 410 | dd if="$DISK" of="$IMGFILE" bs=512 count=1 || ogRaiseError $OG_ERR_IMAGE "$1 $IMGFILE" || return $? |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | |
---|
| 414 | #/** |
---|
[b52e658] | 415 | # ogCreateBootLoaderImage int_ndisk str_repo path_image |
---|
| 416 | #@brief Crea una imagen del boot loader a partir del sector de arranque de un disco. |
---|
| 417 | #@param int_ndisk nº de orden del disco |
---|
| 418 | #@param str_repo repositorio de imágenes (remoto o caché local) |
---|
| 419 | #@param path_image camino de la imagen (sin extensión) |
---|
| 420 | #@return (nada, por determinar) |
---|
| 421 | #@note repo = { REPO, CACHE } |
---|
| 422 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 423 | #@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado. |
---|
| 424 | #@exception OG_ERR_IMAGE error al crear la imagen del sistema. |
---|
| 425 | #@version 1.0 - Adaptacion de ogCreateMbrImage para guardar solo el Boot Loader |
---|
| 426 | #@author Juan Carlos Xifre, SICUZ Universidad de Zaragoza |
---|
| 427 | #@date 2011/03/21 |
---|
| 428 | #*/ ## |
---|
| 429 | function ogCreateBootLoaderImage () |
---|
| 430 | { |
---|
| 431 | # Variables locales |
---|
| 432 | local DISK IMGDIR IMGFILE |
---|
| 433 | # Si se solicita, mostrar ayuda. |
---|
| 434 | if [ "$*" == "help" ]; then |
---|
| 435 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk path_dir str_image" \ |
---|
| 436 | "$FUNCNAME 1 REPO /aula1/mbr" |
---|
| 437 | return |
---|
| 438 | fi |
---|
| 439 | # Error si no se reciben 3 parámetros. |
---|
[a73649d] | 440 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[b52e658] | 441 | |
---|
| 442 | DISK=$(ogDiskToDev "$1") || return $? |
---|
| 443 | IMGDIR=$(ogGetParentPath "$2" "$3") |
---|
| 444 | [ -n "$IMGDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$2 $(dirname $3)" || return $? |
---|
| 445 | IMGFILE="$IMGDIR/$(basename "$3").mbr" |
---|
| 446 | |
---|
| 447 | # Crear imagen del Boot Loader dentro del MBR. |
---|
| 448 | dd if="$DISK" of="$IMGFILE" bs=446 count=1 || ogRaiseError $OG_ERR_IMAGE "$1 $IMGFILE" || return $? |
---|
| 449 | } |
---|
| 450 | |
---|
[d3dc88d] | 451 | #/** |
---|
| 452 | # ogGetSizeParameters int_num_disk int_num_part str_repo [monolit|sync|diff] |
---|
| 453 | #@brief Devuelve el tamaño de los datos de un sistema de ficheros, el espacio necesario para la imagen y si cabe en el repositorio elegido. |
---|
| 454 | #@param int_disk numero de disco |
---|
| 455 | #@param int_part numero de particion |
---|
| 456 | #@param str_repo repositorio de imágenes { REPO, CACHE } |
---|
| 457 | #@param str_imageType Tipo de imagen: monolit (por defecto), sync o diff. (parametro opcional) |
---|
| 458 | #@return SIZEDATA SIZEREQUIRED ISENOUGHSPACE |
---|
| 459 | #@note si str_imageType= diff necesario /tmp/ogimg.info, que es creado por ogCreateInfoImage. |
---|
| 460 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 461 | #@author Irina Gomez, ETSII Universidad de Sevilla |
---|
| 462 | #@date 2014/10/24 |
---|
| 463 | #*/ ## |
---|
| 464 | function ogGetSizeParameters () |
---|
| 465 | { |
---|
| 466 | local MNTDIR SIZEDATA KERNELVERSION SIZEREQUIRED FACTORGZIP FACTORLZOP SIZEFREE |
---|
| 467 | # Si se solicita, mostrar ayuda. |
---|
| 468 | if [ "$*" == "help" ]; then |
---|
| 469 | ogHelp "$FUNCNAME" "$FUNCNAME num_disk num_part str_repo [monolic|sync|diff]" \ |
---|
| 470 | "if $FUNCNAME 1 2 REPO sync ; then ...; fi" \ |
---|
| 471 | "if $FUNCNAME 1 6 CACHE ; then ...; fi" |
---|
| 472 | return |
---|
| 473 | fi |
---|
| 474 | # Error si no se reciben 1 o 2 parámetros. |
---|
| 475 | [ $# -lt 3 ] && return $(ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE [monolitic|sync]" ; echo $?) |
---|
| 476 | |
---|
| 477 | MNTDIR=$(ogMount $1 $2) |
---|
| 478 | if [ "$MNTDIR" == "" ]; then |
---|
| 479 | ogRaiseError $OG_ERR_PARTITION "$1 $2" |
---|
| 480 | return $? |
---|
| 481 | fi |
---|
| 482 | |
---|
| 483 | # Datos contenidos en la particion o en la lista de archivos de contiene la diferencial. |
---|
| 484 | if [ "_${4^^}_" == "_DIFF_" ]; then |
---|
| 485 | [ -r /tmp/ogimg.info ] || return $(ogRaiseError session $OG_ERR_NOTFOUND "/tmp/ogimg.info"; echo $?) |
---|
| 486 | cd $MNTDIR |
---|
| 487 | SIZEDATA=$(grep -v "\/$" /tmp/ogimg.info | tr '\n' '\0'| du -x -c --files0-from=- 2>/dev/null|tail -n1 |cut -f1) |
---|
| 488 | else |
---|
| 489 | SIZEDATA=$(df -k | grep $MNTDIR | awk '{print $3}') |
---|
| 490 | fi |
---|
| 491 | |
---|
| 492 | #Aplicar factor de compresion |
---|
| 493 | if [ "_${4^^}_" == "_SYNC_" -o "_${4^^}_" == "_DIFF_" ]; then |
---|
| 494 | |
---|
| 495 | # Sistema de fichero de la imagen según kernel, menor que 3.7 EXT4. comparamos revision |
---|
| 496 | KERNELVERSION=$(uname -r| awk '{printf("%d",$1);sub(/[0-9]*\./,"",$1);printf(".%02d",$1)}') |
---|
| 497 | [ $KERNELVERSION \< 3.07 ] && IMGFS="EXT4" || IMGFS=${IMGFS:-"BTRFS"} |
---|
| 498 | FACTORSYNC=${FACTORSYNC:-"120"} |
---|
| 499 | # Si IMGFS="BTRFS" la compresion es mayor. |
---|
[81ae95c] | 500 | [ $IMGFS == "BTRFS" ] && let FACTORSYNC=$FACTORSYNC-20 |
---|
[d3dc88d] | 501 | |
---|
| 502 | let SIZEREQUIRED=$SIZEDATA*$FACTORSYNC/100 |
---|
| 503 | # El tamaño mínimo del sistema de ficheros btrfs es 250M, ponemos 300 |
---|
| 504 | [ $SIZEREQUIRED -lt 300000 ] && SIZEREQUIRED=300000 |
---|
| 505 | |
---|
| 506 | else |
---|
| 507 | FACTORGZIP=55/100 |
---|
| 508 | FACTORLZOP=65/100 |
---|
| 509 | let SIZEREQUIRED=$SIZEDATA*$FACTORLZOP |
---|
| 510 | fi |
---|
| 511 | |
---|
| 512 | #Comprobar espacio libre en el contenedor. |
---|
| 513 | [ "${3^^}" == "CACHE" ] && SIZEFREE=$(ogGetFreeSize `ogFindCache`) |
---|
| 514 | [ "${3^^}" == "REPO" ] && SIZEFREE=$(df -k | grep $OGIMG | awk '{print $4}') |
---|
| 515 | |
---|
| 516 | [ "$SIZEREQUIRED" -lt "$SIZEFREE" ] && ISENOUGHSPACE=TRUE || ISENOUGHSPACE=FALSE |
---|
| 517 | |
---|
| 518 | echo $SIZEDATA $SIZEREQUIRED $ISENOUGHSPACE |
---|
| 519 | |
---|
| 520 | |
---|
| 521 | } |
---|
[cbbb046] | 522 | |
---|
[b52e658] | 523 | #/** |
---|
[a25cc03] | 524 | # ogIsImageLocked [str_repo] path_image |
---|
| 525 | #@brief Comprueba si una imagen está bloqueada para uso exclusivo. |
---|
| 526 | #@param str_repo repositorio de imágenes (opcional) |
---|
| 527 | #@param path_image camino de la imagen (sin extensión) |
---|
[7685100] | 528 | #@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error. |
---|
[a25cc03] | 529 | #@note repo = { REPO, CACHE } |
---|
| 530 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 531 | #@version 1.0 - Adaptación a OpenGnSys 1.0 |
---|
| 532 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 533 | #@date 2011/03/10 |
---|
[7685100] | 534 | #@version 1.0.1 - Devolver falso en caso de error. |
---|
| 535 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 536 | #@date 2011-05-18 |
---|
[a25cc03] | 537 | #*/ ## |
---|
| 538 | function ogIsImageLocked () |
---|
| 539 | { |
---|
| 540 | # Si se solicita, mostrar ayuda. |
---|
| 541 | if [ "$*" == "help" ]; then |
---|
| 542 | ogHelp "$FUNCNAME" "$FUNCNAME [str_repo] path_image" \ |
---|
| 543 | "if $FUNCNAME /opt/opengnsys/images/aula1/winxp.img; then ...; fi" \ |
---|
| 544 | "if $FUNCNAME REPO /aula1/winxp.img; then ...; fi" |
---|
| 545 | return |
---|
| 546 | fi |
---|
| 547 | # Error si no se reciben 1 o 2 parámetros. |
---|
[7685100] | 548 | [ $# -lt 1 -o $# -gt 2 ] && return 1 |
---|
[914d834] | 549 | |
---|
[a25cc03] | 550 | # Comprobar si existe el fichero de bloqueo. |
---|
| 551 | test -n "$(ogGetPath $@.lock)" |
---|
| 552 | } |
---|
[914d834] | 553 | |
---|
| 554 | |
---|
[a25cc03] | 555 | #/** |
---|
| 556 | # ogLockImage [str_repo] path_image |
---|
| 557 | #@brief Bloquea una imagen para uso exclusivo. |
---|
| 558 | #@param str_repo repositorio de imágenes (opcional) |
---|
| 559 | #@param path_image camino de la imagen (sin extensión) |
---|
| 560 | #@return Nada. |
---|
| 561 | #@note Se genera un fichero con extensión .lock |
---|
| 562 | #@note repo = { REPO, CACHE } |
---|
| 563 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 564 | #@version 1.0 - Adaptación a OpenGnSys 1.0 |
---|
| 565 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 566 | #@date 2011/03/10 |
---|
| 567 | #*/ ## |
---|
| 568 | function ogLockImage () |
---|
| 569 | { |
---|
| 570 | # Variables locales |
---|
| 571 | local IMGDIR |
---|
[914d834] | 572 | |
---|
[a25cc03] | 573 | # Si se solicita, mostrar ayuda. |
---|
| 574 | if [ "$*" == "help" ]; then |
---|
| 575 | ogHelp "$FUNCNAME" "$FUNCNAME [str_repo] path_image" \ |
---|
| 576 | "$FUNCNAME /opt/opengnsys/images/aula1/winxp.img" \ |
---|
| 577 | "$FUNCNAME REPO /aula1/winxp.img" |
---|
| 578 | return |
---|
| 579 | fi |
---|
| 580 | # Error si no se reciben 1 o 2 parámetros. |
---|
[a73649d] | 581 | [ $# == 1 -o $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[a25cc03] | 582 | # Comprobar que existe directorio de imagen |
---|
| 583 | IMGDIR=$(ogGetParentPath $@) || return $? |
---|
| 584 | # Crear fichero de bloqueo. |
---|
[a73649d] | 585 | touch $IMGDIR/$(basename "${!#}").lock 2>/dev/null || ogRaiseError $OG_ERR_NOTWRITE "$*" || return $? |
---|
[a25cc03] | 586 | } |
---|
[914d834] | 587 | |
---|
| 588 | |
---|
| 589 | #/** |
---|
[e39921b] | 590 | # ogRestoreDiskImage str_repo path_image int_npartition |
---|
| 591 | #@brief Restaura (recupera) una imagen de un disco completo. |
---|
| 592 | #@param str_repo repositorio de imágenes o caché local |
---|
| 593 | #@param path_image camino de la imagen |
---|
| 594 | #@param int_ndisk nº de orden del disco |
---|
| 595 | #@return (por determinar) |
---|
| 596 | #@warning Primera versión en pruebas |
---|
| 597 | #@todo Gestionar bloqueos de disco |
---|
| 598 | #@todo Comprobar que no se intenta restaurar de la caché sobre el mismo disco |
---|
| 599 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 600 | #@exception OG_ERR_NOTFOUND fichero de imagen o partición no detectados. |
---|
| 601 | #@exception OG_ERR_LOCKED partición bloqueada por otra operación. |
---|
| 602 | #@exception OG_ERR_IMAGE error al restaurar la imagen del sistema. |
---|
| 603 | #@exception OG_ERR_IMGSIZEPARTITION Tamaño de la particion es menor al tamaño de la imagen. |
---|
| 604 | #@version 1.1.0 - Primera versión para OpenGnsys. |
---|
| 605 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[1c9ef24] | 606 | #@Date 2016/04/08 |
---|
[e39921b] | 607 | #*/ ## |
---|
| 608 | function ogRestoreDiskImage () |
---|
| 609 | { |
---|
| 610 | # Variables locales |
---|
| 611 | local DISK DISKSIZE IMGFILE IMGTYPE IMGSIZE PROGRAM ERRCODE |
---|
| 612 | |
---|
| 613 | # Si se solicita, mostrar ayuda. |
---|
| 614 | if [ "$*" == "help" ]; then |
---|
| 615 | ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk" \ |
---|
| 616 | "$FUNCNAME REPO /aula1/winxp 1" |
---|
| 617 | return |
---|
| 618 | fi |
---|
| 619 | # Error si no se reciben 4 parámetros. |
---|
| 620 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 621 | # Procesar parámetros. |
---|
| 622 | DISK="$(ogDiskToDev $3)" || return $(ogRaiseError $OG_ERR_NOTFOUND " $3 $4"; echo $?) |
---|
| 623 | IMGTYPE="dsk" |
---|
| 624 | IMGFILE=$(ogGetPath "$1" "$2.$IMGTYPE") |
---|
| 625 | [ -r "$IMGFILE" ] || return $(ogRaiseError $OG_ERR_NOTFOUND " $3 $4"; echo $?) |
---|
| 626 | |
---|
| 627 | # comprobamos consistencia de la imagen |
---|
[1c9ef24] | 628 | ogGetImageInfo $IMGFILE >/dev/null || return $(ogRaiseError $OG_ERR_IMAGE " $1 $2"; echo $?) |
---|
[e39921b] | 629 | # Error si la imagen no cabe en la particion. |
---|
| 630 | #IMGSIZE=$(ogGetImageSize "$1" "$2") || return $(ogRaiseError $OG_ERR_IMAGE " $1 $2"; echo $?) |
---|
| 631 | #DISKSIZE=$(ogGetDiskSize $3) |
---|
| 632 | #if [ $IMGSIZE -gt $DISKSIZE ]; then |
---|
| 633 | # ogRaiseError $OG_ERR_IMGSIZEPARTITION "$DISKSIZE < $IMGSIZE" |
---|
| 634 | # return $? |
---|
| 635 | #fi |
---|
| 636 | # Comprobar el bloqueo de la imagen y de la partición. |
---|
| 637 | if ogIsImageLocked "$IMGFILE"; then |
---|
| 638 | ogRaiseError $OG_ERR_LOCKED "$MSG_IMAGE $1, $2.$IMGTYPE" |
---|
| 639 | return $? |
---|
[1feb465] | 640 | fi |
---|
[c680f93] | 641 | if ogIsDiskLocked $3; then |
---|
| 642 | ogRaiseError $OG_ERR_LOCKED "$MSG_DISK $3" |
---|
| 643 | return $? |
---|
| 644 | fi |
---|
[e39921b] | 645 | # Solicitamos la generación de la instruccion a ejecutar |
---|
[1feb465] | 646 | PROGRAM=$(ogRestoreImageSyntax $IMGFILE $DISK) |
---|
[e39921b] | 647 | |
---|
| 648 | # Bloquear el disco |
---|
[1c9ef24] | 649 | ogLockDisk $3 || return $? |
---|
| 650 | trap "ogUnlockDisk $3" 1 2 3 6 9 |
---|
[e39921b] | 651 | |
---|
| 652 | # Ejecutar restauración según el tipo de imagen. |
---|
| 653 | eval $PROGRAM |
---|
| 654 | |
---|
| 655 | ERRCODE=$? |
---|
| 656 | if [ $ERRCODE != 0 ]; then |
---|
| 657 | ogRaiseError $OG_ERR_IMAGE "$IMGFILE, $3, $4" |
---|
| 658 | fi |
---|
[1c9ef24] | 659 | ogUnlockDisk $3 $4 |
---|
[e39921b] | 660 | return $ERRCODE |
---|
| 661 | } |
---|
| 662 | |
---|
| 663 | |
---|
| 664 | #/** |
---|
[914d834] | 665 | # ogRestoreImage str_repo path_image int_ndisk int_npartition |
---|
| 666 | #@brief Restaura una imagen de sistema de archivos en una partición. |
---|
| 667 | #@param str_repo repositorio de imágenes o caché local |
---|
| 668 | #@param path_image camino de la imagen |
---|
| 669 | #@param int_ndisk nº de orden del disco |
---|
| 670 | #@param int_npartition nº de orden de la partición |
---|
| 671 | #@return (por determinar) |
---|
[8e83677] | 672 | #@exception OG_ERR_FORMAT 1 formato incorrecto. |
---|
| 673 | #@exception OG_ERR_NOTFOUND 2 fichero de imagen o partición no detectados. |
---|
| 674 | #@exception OG_ERR_PARTITION 3 # Error en partición de disco. |
---|
| 675 | #@exception OG_ERR_LOCKED 4 partición bloqueada por otra operación. |
---|
| 676 | #@exception OG_ERR_IMAGE 5 error al restaurar la imagen del sistema. |
---|
| 677 | #@exception OG_ERR_IMGSIZEPARTITION 30 Tamaño de la particion es menor al tamaño de la imagen. |
---|
[914d834] | 678 | #@todo Comprobar incongruencias partición-imagen, control de errores, definir parámetros, caché/repositorio, etc. |
---|
| 679 | #@version 0.1 - Integracion para Opengnsys - HIDRA:RestaurarImagen{EXT3, NTFS}.sh; EAC: RestorePartitionFromImage() en Deploy.lib |
---|
| 680 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 681 | #@Date 2008/05/13 |
---|
| 682 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 683 | #@date 2008/10/27 |
---|
| 684 | #@version 0.9 - Primera version muy en pruebas para OpenGnSys |
---|
| 685 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 686 | #@date 2009/09/10 |
---|
[8e83677] | 687 | #@version 1.0 - generacion sintaxis de restauracion |
---|
| 688 | #@author Antonio J. Doblas Viso, Universidad de Malaga |
---|
| 689 | #@date 2011/02/01 |
---|
| 690 | #@version 1.0.1 - Control errores, tamaño particion, fichero-imagen |
---|
| 691 | #@author Antonio J. Doblas Viso, Universidad de Malaga |
---|
| 692 | #@date 2011/05/11 |
---|
[914d834] | 693 | #*/ ## |
---|
| 694 | function ogRestoreImage () |
---|
| 695 | { |
---|
| 696 | # Variables locales |
---|
[cbbb046] | 697 | local PART PARTSIZE IMGFILE IMGTYPE IMGSIZE FSTYPE PROGRAM ERRCODE |
---|
[914d834] | 698 | |
---|
| 699 | # Si se solicita, mostrar ayuda. |
---|
| 700 | if [ "$*" == "help" ]; then |
---|
| 701 | ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk int_npart" \ |
---|
| 702 | "$FUNCNAME REPO /aula1/winxp 1 1" |
---|
| 703 | return |
---|
| 704 | fi |
---|
| 705 | # Error si no se reciben 4 parámetros. |
---|
[1f03f6e] | 706 | [ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[914d834] | 707 | # Procesar parámetros. |
---|
[8e83677] | 708 | PART="$(ogDiskToDev $3 $4)" || return $(ogRaiseError $OG_ERR_NOTFOUND " $3 $4"; echo $?) |
---|
[914d834] | 709 | #IMGTYPE=$(ogGetImageType "$1" "$2") |
---|
| 710 | IMGTYPE=img |
---|
[8e83677] | 711 | IMGFILE=$(ogGetPath "$1" "$2.$IMGTYPE") |
---|
| 712 | [ -r "$IMGFILE" ] || return $(ogRaiseError $OG_ERR_NOTFOUND " $3 $4"; echo $?) |
---|
| 713 | # comprobamos consistencia de la imagen |
---|
| 714 | ogGetImageInfo $IMGFILE >/dev/null || return $(ogRaiseError $OG_ERR_IMAGE " $1 $2"; echo $?) |
---|
| 715 | |
---|
[914d834] | 716 | # Error si la imagen no cabe en la particion. |
---|
[8e83677] | 717 | IMGSIZE=$(ogGetImageSize "$1" "$2") || return $(ogRaiseError $OG_ERR_IMAGE " $1 $2"; echo $?) |
---|
[be3b96a] | 718 | #TODO: |
---|
[8e83677] | 719 | #Si la particion no esta formateado o tiene problemas formateamos |
---|
| 720 | ogMount $3 $4 || ogFormat $3 $4 |
---|
[f8b1b41] | 721 | PARTSIZE=$(ogGetPartitionSize $3 $4) |
---|
[914d834] | 722 | if [ $IMGSIZE -gt $PARTSIZE ]; then |
---|
[8e83677] | 723 | ogRaiseError $OG_ERR_IMGSIZEPARTITION " $PARTSIZE < $IMGSIZE" |
---|
[914d834] | 724 | return $? |
---|
| 725 | fi |
---|
| 726 | # Comprobar el bloqueo de la imagen y de la partición. |
---|
| 727 | if ogIsImageLocked "$IMGFILE"; then |
---|
| 728 | ogRaiseError $OG_ERR_LOCKED "$MSG_IMAGE $1, $2.$IMGTYPE" |
---|
| 729 | return $? |
---|
| 730 | fi |
---|
| 731 | if ogIsLocked $3 $4; then |
---|
| 732 | ogRaiseError $OG_ERR_LOCKED "$MSG_PARTITION $3, $4" |
---|
| 733 | return $? |
---|
| 734 | fi |
---|
[2fc81c4] | 735 | |
---|
| 736 | # Solicitamos la generación de la instruccion a ejecutar |
---|
| 737 | # Atención: no se comprueba el tipo de sistema de archivos. |
---|
| 738 | # Atención: no se comprueba incongruencia entre partición e imagen. |
---|
| 739 | PROGRAM=`ogRestoreImageSyntax $IMGFILE $PART` |
---|
| 740 | |
---|
[914d834] | 741 | # Desmontar y bloquear partición. |
---|
[8e83677] | 742 | ogUnmount $3 $4 2>/dev/null || return $(ogRaiseError $OG_ERR_PARTITION " $3 $4"; echo $?) |
---|
[a73649d] | 743 | ogLock $3 $4 || return $? |
---|
[914d834] | 744 | trap "ogUnlock $3 $4" 1 2 3 6 9 |
---|
| 745 | |
---|
[2fc81c4] | 746 | # Ejecutar restauración según el tipo de imagen. |
---|
[914d834] | 747 | eval $PROGRAM |
---|
| 748 | |
---|
| 749 | ERRCODE=$? |
---|
| 750 | if [ $ERRCODE != 0 ]; then |
---|
| 751 | ogRaiseError $OG_ERR_IMAGE "$IMGFILE, $3, $4" |
---|
| 752 | fi |
---|
| 753 | ogUnlock $3 $4 |
---|
| 754 | return $ERRCODE |
---|
| 755 | } |
---|
| 756 | |
---|
| 757 | |
---|
| 758 | #/** |
---|
[a25cc03] | 759 | # ogRestoreMbrImage str_repo path_image int_ndisk |
---|
| 760 | #@brief Restaura la imagen del sector de arranque de un disco. |
---|
| 761 | #@param str_repo repositorio de imágenes o caché local |
---|
| 762 | #@param path_image camino de la imagen |
---|
| 763 | #@param int_ndisk nº de orden del disco |
---|
| 764 | #@return (por determinar) |
---|
| 765 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 766 | #@exception OG_ERR_NOTFOUND fichero de imagen o partición no detectados. |
---|
| 767 | #@exception OG_ERR_IMAGE error al restaurar la imagen del sistema. |
---|
| 768 | #@version 0.9 - Primera versión en pruebas. |
---|
| 769 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 770 | #@date 2010/01/12 |
---|
| 771 | #@version 1.0 - Adaptación a OpenGnSys 1.0 |
---|
| 772 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 773 | #@date 2011/03/10 |
---|
| 774 | #*/ ## |
---|
| 775 | function ogRestoreMbrImage () |
---|
| 776 | { |
---|
| 777 | # Variables locales |
---|
| 778 | local DISK IMGFILE |
---|
| 779 | # Si se solicita, mostrar ayuda. |
---|
| 780 | if [ "$*" == "help" ]; then |
---|
| 781 | ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk" \ |
---|
| 782 | "$FUNCNAME REPO /aula1/mbr 1" |
---|
| 783 | return |
---|
| 784 | fi |
---|
| 785 | # Error si no se reciben 3 parámetros. |
---|
[a73649d] | 786 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[a25cc03] | 787 | # Procesar parámetros. |
---|
| 788 | DISK=$(ogDiskToDev "$3") || return $? |
---|
| 789 | IMGFILE=$(ogGetPath "$1" "$2.mbr") || return $? |
---|
[8e65e89] | 790 | [ -r "$IMGFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$IMGFILE" || return $? |
---|
[a25cc03] | 791 | |
---|
| 792 | # Restaurar imagen del MBR. |
---|
| 793 | dd if="$IMGFILE" of="$DISK" bs=512 count=1 || ogRaiseError $OG_ERR_IMAGE "$1 $IMGFILE" || return $? |
---|
| 794 | } |
---|
| 795 | |
---|
| 796 | |
---|
| 797 | #/** |
---|
[b52e658] | 798 | # ogRestoreBootLoaderImage str_repo path_image int_ndisk |
---|
| 799 | #@brief Restaura la imagen del boot loader del sector de arranque de un disco. |
---|
| 800 | #@param str_repo repositorio de imágenes o caché local |
---|
| 801 | #@param path_image camino de la imagen |
---|
| 802 | #@param int_ndisk nº de orden del disco |
---|
| 803 | #@return (por determinar) |
---|
| 804 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 805 | #@exception OG_ERR_NOTFOUND fichero de imagen o partición no detectados. |
---|
| 806 | #@exception OG_ERR_IMAGE error al restaurar la imagen del sistema. |
---|
| 807 | #@version 1.0 - Adaptacion de ogRestoreMbrImage para restaurar solo el Boot Loader |
---|
| 808 | #@author Juan Carlos Xifre, SICUZ Universidad de Zaragoza |
---|
| 809 | #@date 2011/03/21 |
---|
| 810 | #*/ ## |
---|
| 811 | function ogRestoreBootLoaderImage () |
---|
| 812 | { |
---|
| 813 | # Variables locales |
---|
| 814 | local DISK IMGFILE |
---|
| 815 | # Si se solicita, mostrar ayuda. |
---|
| 816 | if [ "$*" == "help" ]; then |
---|
| 817 | ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk" \ |
---|
| 818 | "$FUNCNAME REPO /aula1/mbr 1" |
---|
| 819 | return |
---|
| 820 | fi |
---|
| 821 | # Error si no se reciben 3 parámetros. |
---|
[a73649d] | 822 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[b52e658] | 823 | # Procesar parámetros. |
---|
| 824 | DISK=$(ogDiskToDev "$3") || return $? |
---|
| 825 | IMGFILE=$(ogGetPath "$1" "$2.mbr") || return $? |
---|
[8e65e89] | 826 | [ -r "$IMGFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$IMGFILE" || return $? |
---|
[b52e658] | 827 | |
---|
| 828 | # Restaurar imagen del MBR. |
---|
| 829 | dd if="$IMGFILE" of="$DISK" bs=446 count=1 || ogRaiseError $OG_ERR_IMAGE "$1 $IMGFILE" || return $? |
---|
| 830 | } |
---|
| 831 | |
---|
| 832 | #/** |
---|
[a25cc03] | 833 | # ogUnlockImage [str_repo] path_image |
---|
| 834 | #@brief Desbloquea una imagen con uso exclusivo. |
---|
| 835 | #@param str_repo repositorio de imágenes (opcional) |
---|
| 836 | #@param path_image camino de la imagen (sin extensión) |
---|
| 837 | #@return Nada. |
---|
| 838 | #@note repo = { REPO, CACHE } |
---|
| 839 | #@note Se elimina el fichero de bloqueo con extensión .lock |
---|
| 840 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 841 | #@version 1.0 - Adaptación a OpenGnSys 1.0 |
---|
| 842 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 843 | #@date 2011/03/10 |
---|
| 844 | #*/ ## |
---|
| 845 | function ogUnlockImage () |
---|
| 846 | { |
---|
| 847 | # Si se solicita, mostrar ayuda. |
---|
| 848 | if [ "$*" == "help" ]; then |
---|
| 849 | ogHelp "$FUNCNAME" "$FUNCNAME [str_repo] path_image" \ |
---|
| 850 | "$FUNCNAME /opt/opengnsys/images/aula1/winxp.img" \ |
---|
| 851 | "$FUNCNAME REPO /aula1/winxp.img" |
---|
| 852 | return |
---|
| 853 | fi |
---|
| 854 | # Error si no se reciben 1 o 2 parámetros. |
---|
[a73649d] | 855 | [ $# == 1 -o $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[a25cc03] | 856 | |
---|
| 857 | # Borrar fichero de bloqueo para la imagen. |
---|
| 858 | rm -f $(ogGetPath $@.lock) |
---|
| 859 | } |
---|
| 860 | |
---|
| 861 | |
---|
| 862 | #/** |
---|
[914d834] | 863 | # ogGetImageInfo filename |
---|
| 864 | #@brief muestra información sobre la imagen monolitica. |
---|
| 865 | #@param 1 filename path absoluto del fichero imagen |
---|
| 866 | #@return cadena compuesta por clonacion:compresor:sistemaarchivos:tamañoKB |
---|
| 867 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 868 | #@exception OG_ERR_NOTFOUND fichero no encontrado. |
---|
| 869 | #@exception OG_ERR_IMAGE "Image format is not valid $IMGFILE" |
---|
| 870 | #@warning En pruebas iniciales |
---|
| 871 | #@TODO Definir sintaxis de salida (herramienta y compresor en minuscula) |
---|
| 872 | #@TODO Arreglar loop para ntfsclone |
---|
| 873 | #@TODO insertar parametros entrada tipo OG |
---|
| 874 | #@version 1.0 - Primeras pruebas |
---|
| 875 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 876 | #@date 2010/02/08 |
---|
| 877 | #*/ ## |
---|
| 878 | |
---|
[cbbb046] | 879 | function ogGetImageInfo () |
---|
| 880 | { |
---|
[914d834] | 881 | # Si se solicita, mostrar ayuda. |
---|
| 882 | if [ "$*" == "help" ]; then |
---|
| 883 | ogHelp "$FUNCNAME" "$FUNCNAME filename " \ |
---|
| 884 | "$FUNCNAME /opt/opengnsys/images/prueba.img " |
---|
| 885 | return |
---|
| 886 | fi |
---|
| 887 | |
---|
| 888 | # Error si no se reciben 1 parámetros. |
---|
| 889 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 890 | |
---|
| 891 | #comprobando que el parametro uno es un file. |
---|
| 892 | [ -f $1 ] || ogRaiseError $OG_ERR_NOTFOUND "$1" || return $? |
---|
| 893 | |
---|
[51953ae] | 894 | local TOOLS COMPRESSOR IMGFILE FILEHEAD FS FSPLUS SIZE SIZEFACTOR PARTIMAGEINFO PARTCLONEINFO NTFSCLONEINFO IMGDETECT |
---|
[914d834] | 895 | IMGDETECT="FALSE" |
---|
| 896 | |
---|
| 897 | IMGFILE=$1 |
---|
| 898 | FILEHEAD=/tmp/`basename $IMGFILE`.infohead |
---|
| 899 | COMPRESSOR=`file $IMGFILE | awk '{print $2}'` |
---|
| 900 | ogCheckStringInGroup "$COMPRESSOR" "gzip lzop" || ogRaiseError $OG_ERR_IMAGE "Image format is not valid $IMGFILE" || return $? |
---|
| 901 | $($COMPRESSOR -dc $IMGFILE 2>/dev/null | head > $FILEHEAD) || ogRaiseError $OG_ERR_IMAGE "Image format is not valid $IMGFILE" || return $? |
---|
| 902 | |
---|
| 903 | ## buscando Primera opción. |
---|
| 904 | if [ "$IMGDETECT" == "FALSE" ] |
---|
| 905 | then |
---|
[8e9669e] | 906 | PARTCLONEINFO=$(LC_ALL=C partclone.info $FILEHEAD 2>&1) |
---|
[914d834] | 907 | if `echo $PARTCLONEINFO | grep size > /dev/null` |
---|
| 908 | then |
---|
| 909 | TOOLS=PARTCLONE |
---|
| 910 | FS=$(echo $PARTCLONEINFO | awk '{gsub(/\: /,"\n"); print toupper($8);}') |
---|
[d2f8c5a] | 911 | if [[ "$FS" == "HFS" || "$FS" == "HFSPLUS" || "$FS" == "FAT32" ]]; then |
---|
[1cbf9e0] | 912 | FSPLUS=$(echo $PARTCLONEINFO | awk '{gsub(/\: /,"\n"); print toupper($9);}') |
---|
| 913 | echo $PARTCLONEINFO | grep GB > /dev/null && SIZEFACTOR=1000000 || SIZEFACTOR=1024 |
---|
[1131208] | 914 | if [ "$FSPLUS" == "PLUS" ]; then |
---|
[1cbf9e0] | 915 | FS=$FS$FSPLUS |
---|
| 916 | SIZE=$(echo $PARTCLONEINFO | awk -v FACTOR=$SIZEFACTOR '{printf "%d\n", $17*FACTOR;}') |
---|
| 917 | else |
---|
| 918 | SIZE=$(echo $PARTCLONEINFO | awk -v FACTOR=$SIZEFACTOR '{printf "%d\n", $16*FACTOR;}') |
---|
| 919 | fi |
---|
| 920 | else |
---|
| 921 | echo $PARTCLONEINFO | grep GB > /dev/null && SIZEFACTOR=1000000 || SIZEFACTOR=1024 |
---|
| 922 | SIZE=$(echo $PARTCLONEINFO | awk -v FACTOR=$SIZEFACTOR '{gsub(/\: /,"\n"); printf "%d\n", $11*FACTOR;}') |
---|
| 923 | fi |
---|
[914d834] | 924 | IMGDETECT="TRUE" |
---|
| 925 | fi |
---|
| 926 | fi |
---|
| 927 | #buscando segunda opcion. |
---|
| 928 | if [ "$IMGDETECT" == "FALSE" -a ! -f /dev/loop2 ] |
---|
| 929 | then |
---|
| 930 | cat $FILEHEAD | grep -w ntfsclone-image > /dev/null && NTFSCLONEINFO=$(cat $FILEHEAD | ntfsclone --restore --overwrite /dev/loop2 - 2>&1) |
---|
| 931 | if `echo $NTFSCLONEINFO | grep ntfsclone > /dev/null` |
---|
| 932 | then |
---|
| 933 | TOOLS=NTFSCLONE |
---|
| 934 | SIZE=$(echo $NTFSCLONEINFO | awk '{gsub(/\(|\)|\./,""); printf "%d\n",$17/1000;}') |
---|
| 935 | FS=NTFS |
---|
| 936 | IMGDETECT="TRUE" |
---|
| 937 | fi |
---|
| 938 | fi |
---|
| 939 | ## buscando Tercer opción. |
---|
| 940 | if [ "$IMGDETECT" == "FALSE" ] |
---|
| 941 | then |
---|
| 942 | PARTIMAGEINFO=$(partimage -B gui=no imginfo "$FILEHEAD" 2>&1) |
---|
| 943 | if `echo $PARTIMAGEINFO | grep Partition > /dev/null` |
---|
| 944 | then |
---|
| 945 | TOOLS=PARTIMAGE |
---|
| 946 | FS=$(echo $PARTIMAGEINFO | awk '{gsub(/ /,"\n"); print $17;}' | awk '{sub(/\.\.+/," "); print toupper($2)}') |
---|
| 947 | SIZE=$( echo $PARTIMAGEINFO | awk '{gsub(/ /,"\n"); print $36;}' | awk '{sub(/\.\.+/," "); printf "%d\n",$2*1024*1024;}') |
---|
| 948 | IMGDETECT="TRUE" |
---|
[1feb465] | 949 | fi |
---|
| 950 | if file $FILEHEAD 2> /dev/null | grep -q "boot sector"; then |
---|
[a30ad15f] | 951 | TOOLS="partclone.dd" |
---|
[1feb465] | 952 | FS= |
---|
| 953 | SIZE= |
---|
| 954 | IMGDETECT="TRUE" |
---|
| 955 | fi |
---|
[914d834] | 956 | fi |
---|
| 957 | #comprobamos valores #Chequeamos los valores devueltos. |
---|
| 958 | if [ -z "$TOOLS" -o -z "$COMPRESSOR" -o "$IMGDETECT" == "FALSE" ] |
---|
| 959 | then |
---|
| 960 | ogRaiseError $OG_ERR_IMAGE "Image format is not valid $IMGFILE" || return $? |
---|
| 961 | else |
---|
| 962 | COMPRESSOR=$(echo $COMPRESSOR | tr [a-z] [A-Z]) |
---|
| 963 | echo $TOOLS:$COMPRESSOR:$FS:$SIZE |
---|
| 964 | fi |
---|
| 965 | } |
---|
| 966 | |
---|
| 967 | function ogGetImageProgram () |
---|
| 968 | { |
---|
| 969 | local IMGFILE |
---|
| 970 | IMGFILE=$(ogGetPath "$1" "$2.img") || return $? |
---|
[8e65e89] | 971 | [ -r "$IMGFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$IMGFILE" || return $? |
---|
[914d834] | 972 | ogGetImageInfo $IMGFILE | awk -F: '{print $1}' |
---|
| 973 | |
---|
| 974 | } |
---|
| 975 | |
---|
| 976 | function ogGetImageCompressor () |
---|
| 977 | { |
---|
| 978 | local IMGFILE |
---|
| 979 | IMGFILE=$(ogGetPath "$1" "$2.img") || return $? |
---|
[8e65e89] | 980 | [ -r "$IMGFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$IMGFILE" || return $? |
---|
[914d834] | 981 | ogGetImageInfo $IMGFILE | awk -F: '{print $2}' |
---|
| 982 | } |
---|
| 983 | |
---|
| 984 | function ogGetImageType () |
---|
| 985 | { |
---|
| 986 | local IMGFILE |
---|
| 987 | IMGFILE=$(ogGetPath "$1" "$2.img") || return $? |
---|
[8e65e89] | 988 | [ -r "$IMGFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$IMGFILE" || return $? |
---|
[914d834] | 989 | #partimage -B gui=no imginfo "$IMGFILE" 2>&1 | \ |
---|
| 990 | # awk '/^Filesystem/ {sub(/\.\.+/," "); sub(/fs$/,""); print toupper($2);}' |
---|
| 991 | ogGetImageInfo $IMGFILE | awk -F: '{print $3}' |
---|
| 992 | |
---|
| 993 | } |
---|
| 994 | |
---|
| 995 | function ogGetImageSize () |
---|
| 996 | { |
---|
| 997 | # Variables locales |
---|
| 998 | local IMGFILE |
---|
| 999 | |
---|
| 1000 | # Si se solicita, mostrar ayuda. |
---|
| 1001 | if [ "$*" == "help" ]; then |
---|
[8e83677] | 1002 | ogHelp "$FUNCNAME" "$FUNCNAME REPO|CACHE /str_image" \ |
---|
| 1003 | "$FUNCNAME REPO /aula1/winxp ==> 5642158" |
---|
[914d834] | 1004 | return |
---|
| 1005 | fi |
---|
[a73649d] | 1006 | # Error si no se reciben 2 parámetros. |
---|
| 1007 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[914d834] | 1008 | # Error si el fichero de imagen no es accesible. |
---|
| 1009 | IMGFILE=$(ogGetPath "$1" "$2.img") || return $? |
---|
[8e65e89] | 1010 | [ -r "$IMGFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$IMGFILE" || return $? |
---|
[914d834] | 1011 | |
---|
| 1012 | # Devuelve el tamaño de la imagen en KB. |
---|
| 1013 | #partimage -B gui=no imginfo "$IMGFILE" 2>&1 | \ |
---|
| 1014 | # awk '/Partition size/ {sub(/\.\.+/," "); printf "%d\n",$3*1024*1024;}' |
---|
| 1015 | ogGetImageInfo $IMGFILE | awk -F: '{print $4}' |
---|
| 1016 | } |
---|
| 1017 | |
---|