31 local FS TOOL LEVEL DEV IMGFILE BUFFER PARAM1 PARAM2 PARAM3
33 # Si se solicita, mostrar ayuda. 34 if [
"$*" ==
"help" ]; then
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" 40 # Error si no se reciben entre 2 y 4 parámetros. 41 [ $# -ge 2 -a $# -le 4 ] ||
ogRaiseError $OG_ERR_FORMAT
"$*" ||
return $?
43 # Asignación de parámetros. 47 2) # Sintaxis por defecto OG DEV IMGFILE
51 4) # Sintaxis condicionada.
59 PARAM1=
"ntfsclone --force --save-image -O - $DEV" 62 PARAM1=
"partimage -M -f3 -o -d -B gui=no -c -z0 --volume=0 save $DEV stdout" 65 FS=
"$(ogGetFsType $(ogDevToDisk $DEV 2>/dev/null) 2>/dev/null)" 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" ;;
73 F2FS) PARAM1=
"partclone.f2fs" ;;
74 NILFS2) PARAM1=
"partclone.nilfs2" ;;
75 NTFS) PARAM1=
"partclone.ntfs" ;;
76 EXFAT) PARAM1=
"partclone.exfat" ;;
77 FAT16|FAT32) PARAM1=
"partclone.fat" ;;
78 HFS|HFSPLUS) PARAM1=
"partclone.hfsp" ;;
79 UFS) PARAM1=
"partclone.ufs" ;;
80 VMFS) PARAM1=
"partclone.vmfs" ;;
81 *) PARAM1=
"partclone.imager" ;;
83 # Por compatibilidad, si no existe el ejecutable usar por defecto "parclone.dd". 84 which $PARAM1 &>/dev/null || PARAM1=
"partclone.dd" 85 PARAM1=
"$PARAM1 -d0 -F -c -s $DEV" 86 # Algunas versiones de partclone.dd no tienen opción "-c". 87 [ -z
"$(eval ${PARAM1%% *} --help 2>&1 | grep -- -c)" ] && PARAM1=
"${PARAM1/ -c / }" 90 # Comprobar que existe mbuffer. 91 which
mbuffer &>/dev/null && PARAM2=
"| mbuffer -q -m 40M " || PARAM2=
" " 93 # Nivel de compresion. 95 0|none) PARAM3=
" > " ;;
96 1|lzop) PARAM3=
" | lzop > " ;;
97 2|gzip) PARAM3=
" | gzip -c > " ;;
98 3|bzip) PARAM3=
" | bzip -c > " ;;
102 [ -n
"$PARAM1" ] && echo
"$PARAM1 $PARAM2 $PARAM3 $IMGFILE" 124 local TOOL COMPRESSOR LEVEL PART IMGFILE FILEHEAD INFOIMG
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]" 134 # Error si no se reciben entre 2 y 4 parámetros. 135 [ $# -ge 2 -a $# -le 4 ] ||
ogRaiseError $OG_ERR_FORMAT
"$*" ||
return $?
137 # controlamos que el parametro 1 (imagen) es tipo file. 138 [ -f $1 ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$1" ||
return $?
140 # Si 2 parametros (file-origen-, device-destino-) = ogGetImageFull($1) 141 if [
"$#" -eq 2 ]; then
145 TOOL=`echo $INFOIMG | cut -f1 -d:`
146 COMPRESSOR=`echo $INFOIMG | cut -f2 -d:`
151 # Si cuatro parametros genera sintaxis
152 if [
"$#" -eq 4 ]; then
155 # comprobamos parametro herramienta compresion. 156 TOOL=$(echo $3 | tr [A-Z] [a-z])
158 #comprobar parámetro compresor.
159 LEVEL=$(echo $4 | tr [A-Z] [a-z])
160 #ogCheckProgram $LEVEL 167 COMPRESSOR=
" lzop -dc " 170 COMPRESSOR=
" gzip -dc " 172 "3"|
"bzip" |
"BZIP" )
173 COMPRESSOR=
" bzip -dc " 176 ogRaiseError $OG_ERR_NOTFOUND
"Compressor no valid $TOOL" ||
return $?
180 which
mbuffer > /dev/null && MBUFFER=
"| mbuffer -q -m 40M " || MBUFFER=
" " 184 TOOL=
"| ntfsclone --restore-image --overwrite $PART -" 187 TOOL=
"| partimage -f3 -B gui=no restore $PART stdin" 190 # -C para que no compruebe tamaños
191 TOOL=
"| partclone.restore -d0 -C -I -o $PART" 194 TOOL=
"| pv | dd conv=sync,noerror bs=1M of=$PART" 197 ogRaiseError $OG_ERR_NOTFOUND
"Tools imaging no valid $TOOL" ||
return $?
201 echo
"$COMPRESSOR $IMGFILE $MBUFFER $TOOL" 233 local DISK PROGRAM IMGDIR IMGFILE IMGTYPE ERRCODE
235 # Si se solicita, mostrar ayuda. 236 if [
"$*" ==
"help" ]; then
237 ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk str_repo path_image" \
238 "$FUNCNAME 1 REPO /disk1" 241 # Error si no se reciben entre 3 y 5 parámetros. 242 [ $# -ge 3 -a $# -le 5 ] ||
ogRaiseError $OG_ERR_FORMAT
"$*" ||
return $?
244 # Comprobar que no está bloqueada ni la partición, ni la imagen. 245 DISK=
"$(ogDiskToDev $1)" ||
return $?
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" 259 # No guardar imagen en el propio disco (disco no incluido en el camino del repositorio). 260 if [[ $(
ogGetPath "$2" /) =~ ^$DISK ]]; then
265 # Generar la instruccion a ejecutar antes de aplicar los bloqueos. 267 # Desmontar todos los sistemas de archivos del disco, bloquear disco e imagen.
268 ogUnmountAll $1 2>/dev/null
273 trap
"ogUnlockDisk $1; ogUnlockImage "$3
" "$4.$IMGTYPE
"; rm -f $IMGFILE" 1 2 3 6 9
276 # Controlar salida de error, crear fichero de información y desbloquear partición.
278 if [ $ERRCODE == 0 ]; then
279 echo
"$(ogGetImageInfo $IMGFILE):$(ogGetHostname)" > $IMGFILE.info
284 # Desbloquear disco e imagen.
323 local PART PROGRAM IMGDIR IMGFILE IMGTYPE ERRCODE
325 # Si se solicita, mostrar ayuda. 326 if [
"$*" ==
"help" ]; then
327 ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npart str_repo path_image" \
328 "$FUNCNAME 1 1 REPO /aula1/win7" 331 # Error si no se reciben entre 4 y 6 parámetros. 332 [ $# -ge 4 -a $# -le 6 ] ||
ogRaiseError $OG_ERR_FORMAT
"$*" ||
return $?
334 # Comprobar que no está bloqueada ni la partición, ni la imagen. 335 PART=
"$(ogDiskToDev $1 $2)" ||
return $?
341 IMGTYPE=
"img" # Extensión genérica de imágenes.
342 IMGDIR=$(ogGetParentPath
"$3" "$4")
343 [ -n
"$IMGDIR" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$3 $(dirname $4)" ||
return $?
345 IMGFILE=
"$IMGDIR/$(basename "$4
").$IMGTYPE" 350 # Generar la instruccion a ejecutar antes de aplicar los bloqueos. 352 # Desmontar partición, bloquear partición e imagen.
353 ogUnmount $1 $2 2>/dev/null
358 trap
"ogUnlock $1 $2; ogUnlockImage "$3
" "$4.$IMGTYPE
"; rm -f $IMGFILE" 1 2 3 6 9
361 # Controlar salida de error, crear fichero de información y desbloquear partición.
363 if [ $ERRCODE == 0 ]; then
364 echo
"$(ogGetImageInfo $IMGFILE):$(ogGetHostname)" > $IMGFILE.info
365 cp -f $IMGFILE.info /tmp/image.info
370 # Desbloquear partición e imagen.
398 local DISK IMGDIR IMGFILE
399 # Si se solicita, mostrar ayuda. 400 if [
"$*" ==
"help" ]; then
401 ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk str_repo path_image" \
402 "$FUNCNAME 1 REPO /aula1/mbr" 405 # Error si no se reciben 3 parámetros. 409 IMGDIR=$(ogGetParentPath
"$2" "$3")
410 [ -n
"$IMGDIR" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$2 $(dirname $3)" ||
return $?
411 IMGFILE=
"$IMGDIR/$(basename "$3
").mbr" 413 # Crear imagen del MBR. 414 dd
if=
"$DISK" of=
"$IMGFILE" bs=512 count=1 ||
ogRaiseError $OG_ERR_IMAGE
"$1 $IMGFILE" ||
return $?
436 local DISK IMGDIR IMGFILE
437 # Si se solicita, mostrar ayuda. 438 if [
"$*" ==
"help" ]; then
439 ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk str_repo path_image" \
440 "$FUNCNAME 1 REPO /aula1/mbr" 443 # Error si no se reciben 3 parámetros. 447 IMGDIR=$(ogGetParentPath
"$2" "$3")
448 [ -n
"$IMGDIR" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$2 $(dirname $3)" ||
return $?
449 IMGFILE=
"$IMGDIR/$(basename "$3
").mbr" 451 # Crear imagen del Boot Loader dentro del MBR. 452 dd
if=
"$DISK" of=
"$IMGFILE" bs=446 count=1 ||
ogRaiseError $OG_ERR_IMAGE
"$1 $IMGFILE" ||
return $?
478 local REPO MNTDIR SIZEDATA KERNELVERSION SIZEREQUIRED FACTORGZIP FACTORLZOP FACTORSYNC SIZEFREE
479 local IMGTYPE IMGDIR IMGFILE IMGEXT IMGSIZE
481 # Si se solicita, mostrar ayuda. 482 if [
"$*" ==
"help" ]; then
483 ogHelp "$FUNCNAME" "$FUNCNAME num_disk num_part str_repo path_imgname [monolit|sync|diff]" \
484 "if $FUNCNAME 1 2 REPO Windows10 sync ; then ...; fi" \
485 "if $FUNCNAME 1 6 Ubuntu16 CACHE ; then ...; fi" 488 # Error si no se reciben 1 o 2 parámetros. 489 [ $# -lt 4 ] &&
return $(
ogRaiseError session $OG_ERR_FORMAT
"$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imgname [monolit|sync|diff]" ; echo $?)
491 # Recogemos parametros
496 if [
"$MNTDIR" ==
"" ]; then
501 # Datos contenidos en la particion o en la lista de archivos de contiene la diferencial. 502 if [
"$IMGTYPE" ==
"_DIFF_" ]; then
503 [ -r /tmp/ogimg.info ] ||
return $(
ogRaiseError session $OG_ERR_NOTFOUND
"/tmp/ogimg.info"; echo $?)
505 SIZEDATA=$(grep -v
"\/$" /tmp/ogimg.info | tr
'\n' '\0'| du -x -c --files0-from=- 2>/dev/null|tail -n1 |cut -f1)
508 SIZEDATA=$(df -k | grep $MNTDIR\$ |
awk '{print $3}')
511 #Aplicar factor de compresion
512 if [
"$IMGTYPE" ==
"_SYNC_" -o
"$IMGTYPE" ==
"_DIFF_" ]; then
514 # Sistema de fichero de la imagen según kernel, menor que 3.7 EXT4. comparamos revision 515 KERNELVERSION=$(uname -r|
awk '{printf("%d",$1);sub(/[0-9]*\./,"",$1);printf(".%02d",$1)}')
516 [ $KERNELVERSION \< 3.07 ] && IMGFS=
"EXT4" || IMGFS=${IMGFS:-
"BTRFS"}
517 FACTORSYNC=${FACTORSYNC:-
"130"}
518 # Si IMGFS="BTRFS" la compresion es mayor. 519 [ $IMGFS ==
"BTRFS" ] && let FACTORSYNC=$FACTORSYNC-20
521 let SIZEREQUIRED=$SIZEDATA*$FACTORSYNC/100
522 # El tamaño mínimo del sistema de ficheros btrfs es 250M, ponemos 300 523 [ $SIZEREQUIRED -lt 300000 ] && SIZEREQUIRED=300000
528 let SIZEREQUIRED=$SIZEDATA*$FACTORLZOP
531 #Comprobar espacio libre en el contenedor. 533 [
"$REPO" ==
"REPO" ] && SIZEFREE=$(df -k | grep $OGIMG |
awk '{print $4}')
535 # Comprobamos si existe una imagen con el mismo nombre en $REPO 536 # En sincronizadas restamos tamaño de la imagen y en monoloticas de la .ant 538 _DIFF_) IMGEXT=
"img.diff" 546 IMGDIR=$(ogGetParentPath
"$REPO" "/$4")
547 IMGFILE=$(
ogGetPath "$IMGDIR/$(basename "/$4
").$IMGEXT")
548 if [ -z
"$IMGFILE" ]; then
551 IMGSIZE=$(ls -s
"$IMGFILE" | cut -f1 -d
" ")
554 let SIZEFREE=$SIZEFREE+$IMGSIZE
556 [
"$SIZEREQUIRED" -lt
"$SIZEFREE" ] && ISENOUGHSPACE=TRUE || ISENOUGHSPACE=FALSE
558 echo $SIZEDATA $SIZEREQUIRED $SIZEFREE $ISENOUGHSPACE
579 # Si se solicita, mostrar ayuda. 580 if [
"$*" ==
"help" ]; then
581 ogHelp "$FUNCNAME" "$FUNCNAME [str_repo] path_image" \
582 "if $FUNCNAME /opt/opengnsys/images/aula1/win7.img; then ...; fi" \
583 "if $FUNCNAME REPO /aula1/win7.img; then ...; fi" 586 # Error si no se reciben 1 o 2 parámetros. 587 [ $# -lt 1 -o $# -gt 2 ] &&
return 1
589 # Comprobar si existe el fichero de bloqueo. 590 test -n
"$(ogGetPath $@.lock)" 612 # Si se solicita, mostrar ayuda. 613 if [
"$*" ==
"help" ]; then
614 ogHelp "$FUNCNAME" "$FUNCNAME [str_repo] path_image" \
615 "$FUNCNAME /opt/opengnsys/images/aula1/win7.img" \
616 "$FUNCNAME REPO /aula1/win7.img" 619 # Error si no se reciben 1 o 2 parámetros. 620 [ $# == 1 -o $# == 2 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
621 # Comprobar que existe directorio de imagen 622 IMGDIR=$(ogGetParentPath $@) ||
return $?
623 # Crear fichero de bloqueo.
624 touch $IMGDIR/$(basename
"${!#}").lock 2>/dev/null ||
ogRaiseError $OG_ERR_NOTWRITE
"$*" ||
return $?
650 local DISK DISKSIZE IMGFILE IMGTYPE IMGSIZE PROGRAM ERRCODE
652 # Si se solicita, mostrar ayuda. 653 if [
"$*" ==
"help" ]; then
654 ogHelp "$FUNCNAME" "$FUNCNAME str_repo path_image int_ndisk" \
655 "$FUNCNAME REPO /aula1/win7 1" 658 # Error si no se reciben 4 parámetros. 660 # Procesar parámetros. 661 DISK=
"$(ogDiskToDev $3)" ||
return $(
ogRaiseError $OG_ERR_NOTFOUND
" $3 $4"; echo $?)
664 [ -r
"$IMGFILE" ] ||
return $(
ogRaiseError $OG_ERR_NOTFOUND
" $3 $4"; echo $?)
666 # comprobamos consistencia de la imagen
677 (Fin comentario Doxygen)
679 # Comprobar el bloqueo de la imagen y de la partición. 681 ogRaiseError $OG_ERR_LOCKED
"$MSG_IMAGE $1, $2.$IMGTYPE" 688 # Solicitamos la generación de la instruccion a ejecutar 693 trap
"ogUnlockDisk $3" 1 2 3 6 9
695 # Ejecutar restauración según el tipo de imagen.
699 if [ $ERRCODE != 0 ]; then
740 local PART PARTSIZE IMGFILE IMGTYPE IMGSIZE FSTYPE PROGRAM ERRCODE
742 # Si se solicita, mostrar ayuda. 743 if [
"$*" ==
"help" ]; then
744 ogHelp "$FUNCNAME" "$FUNCNAME str_repo path_image int_ndisk int_npart" \
745 "$FUNCNAME REPO /aula1/win7 1 1" 748 # Error si no se reciben 4 parámetros. 750 # Procesar parámetros. 751 PART=
"$(ogDiskToDev $3 $4)" ||
return $(
ogRaiseError $OG_ERR_NOTFOUND
" $3 $4"; echo $?)
755 [ -r
"$IMGFILE" ] ||
return $(
ogRaiseError $OG_ERR_NOTFOUND
" $3 $4"; echo $?)
756 # comprobamos consistencia de la imagen
759 # Error si la imagen no cabe en la particion.
762 #Si la particion no esta formateado o tiene problemas formateamos
765 if [ $IMGSIZE -gt $PARTSIZE ]; then
766 ogRaiseError $OG_ERR_IMGSIZEPARTITION
" $PARTSIZE < $IMGSIZE" 769 # Comprobar el bloqueo de la imagen y de la partición. 771 ogRaiseError $OG_ERR_LOCKED
"$MSG_IMAGE $1, $2.$IMGTYPE" 779 # Solicitamos la generación de la instruccion a ejecutar 780 # Atención: no se comprueba el tipo de sistema de archivos. 781 # Atención: no se comprueba incongruencia entre partición e imagen. 784 # Desmontar y bloquear partición. 787 trap
"ogUnlock $3 $4" 1 2 3 6 9
789 # Ejecutar restauración según el tipo de imagen.
793 if [ $ERRCODE != 0 ]; then
822 # Si se solicita, mostrar ayuda. 823 if [
"$*" ==
"help" ]; then
824 ogHelp "$FUNCNAME" "$FUNCNAME str_repo path_image int_ndisk" \
825 "$FUNCNAME REPO /aula1/mbr 1" 828 # Error si no se reciben 3 parámetros. 830 # Procesar parámetros. 833 [ -r
"$IMGFILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$IMGFILE" ||
return $?
835 # Restaurar imagen del MBR. 836 dd
if=
"$IMGFILE" of=
"$DISK" bs=512 count=1 ||
ogRaiseError $OG_ERR_IMAGE
"$1 $IMGFILE" ||
return $?
858 # Si se solicita, mostrar ayuda. 859 if [
"$*" ==
"help" ]; then
860 ogHelp "$FUNCNAME" "$FUNCNAME str_repo path_image int_ndisk" \
861 "$FUNCNAME REPO /aula1/mbr 1" 864 # Error si no se reciben 3 parámetros. 866 # Procesar parámetros. 869 [ -r
"$IMGFILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$IMGFILE" ||
return $?
871 # Restaurar imagen del MBR. 872 dd
if=
"$IMGFILE" of=
"$DISK" bs=446 count=1 ||
ogRaiseError $OG_ERR_IMAGE
"$1 $IMGFILE" ||
return $?
890 # Si se solicita, mostrar ayuda. 891 if [
"$*" ==
"help" ]; then
892 ogHelp "$FUNCNAME" "$FUNCNAME [str_repo] path_image" \
893 "$FUNCNAME /opt/opengnsys/images/aula1/win7.img" \
894 "$FUNCNAME REPO /aula1/win7.img" 897 # Error si no se reciben 1 o 2 parámetros. 898 [ $# == 1 -o $# == 2 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
900 # Borrar fichero de bloqueo para la imagen. 924 # Si se solicita, mostrar ayuda. 925 if [
"$*" ==
"help" ]; then
926 ogHelp "$FUNCNAME" "$FUNCNAME path_filename" \
927 "$FUNCNAME /opt/opengnsys/images/prueba.img ==> PARTCLONE:LZOP:NTFS:5642158" 931 # Error si no se recibe 1 parámetro. 934 #comprobando que el parametro uno es un file. 935 [ -f $1 ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$1" ||
return $?
937 local TOOLS COMPRESSOR IMGFILE FILEHEAD FS FSPLUS SIZE SIZEFACTOR PARTIMAGEINFO PARTCLONEINFO NTFSCLONEINFO IMGDETECT
941 FILEHEAD=/tmp/`basename $IMGFILE`.infohead
942 COMPRESSOR=`file $IMGFILE |
awk '{print $2}'`
944 $($COMPRESSOR -dc $IMGFILE 2>/dev/null | head -n 40 > $FILEHEAD) ||
ogRaiseError $OG_ERR_IMAGE
"Image format is not valid $IMGFILE" ||
return $?
946 ## buscando Primera opción.
947 if [
"$IMGDETECT" ==
"FALSE" ]
949 PARTCLONEINFO=$(LC_ALL=C partclone.info $FILEHEAD 2>&1)
950 if `echo $PARTCLONEINFO | grep size > /dev/null`
953 FS=$(echo $PARTCLONEINFO |
awk '{gsub(/: /,"\n"); print toupper($8);}')
954 if [[
"$FS" ==
"HFS" ||
"$FS" ==
"HFSPLUS" ||
"$FS" ==
"FAT32" ]]; then
955 FSPLUS=$(echo $PARTCLONEINFO |
awk '{gsub(/: /,"\n"); print toupper($9);}')
956 echo $PARTCLONEINFO | grep GB > /dev/null && SIZEFACTOR=1000000 || SIZEFACTOR=1024
957 if [
"$FSPLUS" ==
"PLUS" ]; then
959 SIZE=$(echo $PARTCLONEINFO |
awk -v FACTOR=$SIZEFACTOR
'{printf "%d\n", $17*FACTOR;}')
961 SIZE=$(echo $PARTCLONEINFO |
awk -v FACTOR=$SIZEFACTOR
'{printf "%d\n", $16*FACTOR;}')
964 echo $PARTCLONEINFO | grep GB > /dev/null && SIZEFACTOR=1000000 || SIZEFACTOR=1024
965 SIZE=$(echo $PARTCLONEINFO |
awk -v FACTOR=$SIZEFACTOR
'{gsub(/: /,"\n"); printf "%d\n", $11*FACTOR;}')
970 #buscando segunda opcion.
971 if [
"$IMGDETECT" ==
"FALSE" -a ! -f /dev/loop2 ]
973 cat $FILEHEAD | grep -w ntfsclone-image > /dev/null && NTFSCLONEINFO=$(cat $FILEHEAD | ntfsclone --restore --overwrite /dev/loop2 - 2>&1)
974 if `echo $NTFSCLONEINFO | grep ntfsclone > /dev/null`
977 SIZE=$(echo $NTFSCLONEINFO |
awk '{gsub(/\(|\)|\./,""); printf "%d\n",$17/1000;}')
982 ## buscando Tercer opción.
983 if [
"$IMGDETECT" ==
"FALSE" ]
985 PARTIMAGEINFO=$(
partimage -B gui=no imginfo
"$FILEHEAD" 2>&1)
986 if `echo $PARTIMAGEINFO | grep Partition > /dev/null`
989 FS=$(echo $PARTIMAGEINFO |
awk '{gsub(/ /,"\n"); print $17;}' |
awk '{sub(/\.\.+/," "); print toupper($2)}')
990 SIZE=$( echo $PARTIMAGEINFO |
awk '{gsub(/ /,"\n"); print $36;}' |
awk '{sub(/\.\.+/," "); printf "%d\n",$2*1024*1024;}')
993 if file $FILEHEAD 2> /dev/null | grep -q
"boot sector"; then
1000 #comprobamos valores #Chequeamos los valores devueltos. 1001 if [ -z
"$TOOLS" -o -z
"$COMPRESSOR" -o
"$IMGDETECT" ==
"FALSE" ]
1003 ogRaiseError $OG_ERR_IMAGE
"Image format is not valid $IMGFILE" ||
return $?
1005 COMPRESSOR=$(echo $COMPRESSOR | tr [a-z] [A-Z])
1006 echo $TOOLS:$COMPRESSOR:$FS:$SIZE
1028 # Si se solicita, mostrar ayuda. 1029 if [
"$*" ==
"help" ]; then
1030 ogHelp "$FUNCNAME" "$FUNCNAME str_repo path_image" \
1031 "$FUNCNAME REPO prueba ==> PARTCLONE" 1034 # Error si no se reciben 2 parámetros. 1035 [ $# == 2 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
1037 [ -r
"$IMGFILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$IMGFILE" ||
return $?
1058 # Si se solicita, mostrar ayuda. 1059 if [
"$*" ==
"help" ]; then
1060 ogHelp "$FUNCNAME" "$FUNCNAME str_repo path_image" \
1061 "$FUNCNAME REPO prueba ==> LZOP" 1064 # Error si no se reciben 2 parámetros. 1065 [ $# == 2 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
1067 [ -r
"$IMGFILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$IMGFILE" ||
return $?
1089 # Si se solicita, mostrar ayuda. 1090 if [
"$*" ==
"help" ]; then
1091 ogHelp "$FUNCNAME" "$FUNCNAME str_repo path_image" \
1092 "$FUNCNAME REPO prueba ==> NTFS" 1095 # Error si no se reciben 2 parámetros. 1096 [ $# == 2 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
1098 [ -r
"$IMGFILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$IMGFILE" ||
return $?
1122 # Si se solicita, mostrar ayuda. 1123 if [
"$*" ==
"help" ]; then
1124 ogHelp "$FUNCNAME" "$FUNCNAME str repo path_image" \
1125 "$FUNCNAME REPO prueba ==> 5642158" 1128 # Error si no se reciben 2 parámetros. 1129 [ $# == 2 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
1130 # Error si el fichero de imagen no es accesible. 1132 [ -r
"$IMGFILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$IMGFILE" ||
return $?
1134 # Devuelve el tamaño de la imagen en KB.
1135 ogGetImageInfo $IMGFILE |
awk -F:
'{print $4}' 1157 local DISK IMGDIR IMGFILE
1158 # Si se solicita, mostrar ayuda. 1159 if [
"$*" ==
"help" ]; then
1160 ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk path_dir str_image" \
1161 "$FUNCNAME 1 REPO /aula1/gpt" 1164 # Error si no se reciben 3 parámetros. 1165 [ $# == 3 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
1168 IMGDIR=$(ogGetParentPath
"$2" "$3")
1169 [ -n
"$IMGDIR" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$2 $(dirname $3)" ||
return $?
1170 IMGFILE=
"$IMGDIR/$(basename "$3
").gpt" 1172 # Crear imagen de la tabla GPT. 1173 sgdisk -b=
"$IMGFILE" "$DISK" ||
ogRaiseError $OG_ERR_IMAGE
"$1 $IMGFILE" ||
return $?
1194 # Si se solicita, mostrar ayuda. 1195 if [
"$*" ==
"help" ]; then
1196 ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk" \
1197 "$FUNCNAME REPO /aula1/gpt 1" 1200 # Error si no se reciben 3 parámetros. 1201 [ $# == 3 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
1202 # Procesar parámetros. 1205 [ -r
"$IMGFILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$IMGFILE" ||
return $?
1207 # Restaurar tabla GPT del disco. 1208 sgdisk -l=
"$IMGFILE" "$DISK" ||
ogRaiseError $OG_ERR_IMAGE
"$1 $IMGFILE" ||
return $?
function ogDiskToDev()
Devuelve la equivalencia entre el nº de orden del dispositivo (dicso o partición) y el nombre de fich...
function ogGetImageType()
muestra información sobre el sistema de archivos de imagen monolitica. #
function ogCreateMbrImage()
Crea una imagen a partir del sector de arranque de un disco. #.
function ogGetPartitionSize()
Muestra el tamano en KB de una particion determinada. #.
function ogIsDiskLocked()
function ogGetSizeParameters()
Devuelve el tamaño de los datos de un sistema de ficheros, el espacio necesario para la imagen y si c...
function ogRaiseError()
Devuelve el mensaje y el código de error correspondiente. #.
function ogCreateBootLoaderImage()
Crea una imagen del boot loader a partir del sector de arranque de un disco. #.
function ogHelp()
Muestra mensaje de ayuda para una función determinda. #.
function ogCreateGptImage()
Crea una imagen de la tabla de particiones GPT de un disco. #.
function ogCheckProgram()
function ogGetPath()
Inicia el proceso de arranque de un sistema de archivos. #.
function ogRestoreImage()
Restaura una imagen de sistema de archivos en una partición. #.
function ogLockImage()
Bloquea una imagen para uso exclusivo. #.
function ogRestoreBootLoaderImage()
Restaura la imagen del boot loader del sector de arranque de un disco. #.
function ogUnlockDisk()
Elimina el fichero de bloqueo para un disco. #.
function ogGetFreeSize()
muestra informacion del tamaño total, datos y libre. #
function ogGetImageSize()
muestra información sobre el tamaño (KB) del sistema de archivos de imagen monolitica. #
function ogIsImageLocked()
Comprueba si una imagen está bloqueada para uso exclusivo. #.
function ogUnlockImage()
Desbloquea una imagen con uso exclusivo. #.
function ogFindCache()
Detecta la partición caché local. #.
function ogRestoreImageSyntax()
Genera una cadena de texto con la instrucción para crear un fichero imagen #.
function ogGetImageInfo()
muestra información sobre la imagen monolitica. #
function ogCreateImageSyntax()
Genera una cadena de texto con la instrucción para crear un fichero imagen #.
function ogRestoreDiskImage()
Restaura (recupera) una imagen de un disco completo. #.
function ogGetImageCompressor()
muestra información sobre la imagen monolitica. #
function ogCreateImage()
Crea una imagen a partir de una partición. #.
function ogCheckStringInGroup()
Función para determinar si el elemento pertenece a un conjunto #.
function ogLockDisk()
Genera un fichero de bloqueo para un disco en uso exlusivo. #.
function ogCreateDiskImage()
Crea una imagen (copia de seguridad) de un disco completo. #.
function ogRestoreMbrImage()
Restaura la imagen del sector de arranque de un disco. #.
function ogGetImageProgram()
muestra información sobre la imagen monolitica. #
function ogRestoreGptImage()
Restaura la imagen de la tabla de particiones GPT de un disco. #.