summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authoririna <irinagomez@us.es>2013-10-11 12:40:20 +0000
committeririna <irinagomez@us.es>2013-10-11 12:40:20 +0000
commitf456755884247a72cf1af575a6e15c8c3fc92442 (patch)
tree0033af7e543e38c3022f704510858de03d086cab /client
parentbe48687d995f88aeb4bb482e96e2c870bd82f568 (diff)
#565 adaptacion diferenciales al cliente 1.0.4., extension diferenciles img.diff
git-svn-id: https://opengnsys.es/svn/branches/version1.0@4059 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client')
-rwxr-xr-xclient/engine/Rsync.lib150
-rwxr-xr-xclient/shared/scripts/createBaseImage20
-rwxr-xr-xclient/shared/scripts/createDiffImage22
-rwxr-xr-xclient/shared/scripts/restoreBaseImage10
-rwxr-xr-xclient/shared/scripts/restoreDiffImage6
-rwxr-xr-xclient/shared/scripts/updateCache44
6 files changed, 176 insertions, 76 deletions
diff --git a/client/engine/Rsync.lib b/client/engine/Rsync.lib
index 8eb00fdb..25a96d36 100755
--- a/client/engine/Rsync.lib
+++ b/client/engine/Rsync.lib
@@ -45,7 +45,6 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
if [ -f "$IMGFILE" ]; then
# Si la imagen esta montada la desmonto
if [ -r "$DIRMOUNT/ogimg.info" ]; then
- echo "umount $DIRMOUNT" | tee -a $OGLOGSESSION $OGLOGFILE
umount "$DIRMOUNT"
[ $? -ne 0 ] && return $(ogRaiseError $OG_ERR_DONTUNMOUNT_IMAGE "$1 $2.$IMGEXT"; echo $?)
fi
@@ -62,27 +61,41 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
if [ $IMGSIZE -lt $SIZEREQUIRED ];then
echo " $MSG_SYNC_RESIZE" | tee -a $OGLOGSESSION $OGLOGFILE
echo " truncate --size=>$SIZEREQUIRED k $IMGFILE" | tee -a $OGLOGSESSION $OGLOGFILE
- truncate --size=">$SIZEREQUIRED"k $IMGFILE &> $OGLOGCOMMAND
- echo " mount -o compress=lzo $IMGFILE $DIRMOUNT"
- mount -o compress=lzo "$IMGFILE" "$DIRMOUNT" &> $OGLOGCOMMAND
- echo " btrfs filesystem resize max $DIRMOUNT"
- btrfs filesystem resize max "$DIRMOUNT" &> $OGLOGCOMMAND
+ truncate --size=">$SIZEREQUIRED"k "$IMGFILE" &> $OGLOGCOMMAND
+ # FS de la imagen segun la version del kernel: < 3.7 ext4, si >= btrfs
+ #if [[ "$(uname -r)" < "3.7" ]]; then
+ if [ $(uname -r|cut -d. -f2) -lt 7 ]; then
+ losetup $LOOPDEVICE "$IMGFILE"
+ echo " resize2fs -f $LOOPDEVICE"
+ resize2fs -f $LOOPDEVICE &> $OGLOGCOMMAND
+
+ else
+ echo " ogMountImage $1 "$2" $3"
+ ogMountImage $1 "$2" $3
+ echo " btrfs filesystem resize max $DIRMOUNT"
+ btrfs filesystem resize max "$DIRMOUNT" &> $OGLOGCOMMAND
+ fi
fi
else
echo " dd if=/dev/zero of=$IMGFILE bs=1024 count=$SIZEREQUIRED"
dd if=/dev/zero of="$IMGFILE" bs=1024 count=$SIZEREQUIRED &> $OGLOGCOMMAND
#Formateamos imagen
losetup $LOOPDEVICE $IMGFILE
- echo " mkfs.btrfs -L ${2##*\/} $LOOPDEVICE "
- mkfs.btrfs -L "${2##*\/}" $LOOPDEVICE &> $OGLOGCOMMAND
+ # FS de la imagen segun la version del kernel: < 3.7 ext4, si >= btrfs
+ #if [[ "$(uname -r)" < "3.7" ]]; then
+ if [ $(uname -r|cut -d. -f2) -lt 7 ]; then
+ echo " mkfs.ext4 -i 4096 -b 4096 -L "${2##*\/}" $LOOPDEVICE"
+ mkfs.ext4 -i 4096 -b 4096 -L "${2##*\/}" $LOOPDEVICE &> $OGLOGCOMMAND
+ else
+ echo " mkfs.btrfs -L ${2##*\/} $LOOPDEVICE "
+ mkfs.btrfs -L "${2##*\/}" $LOOPDEVICE &> $OGLOGCOMMAND
+ fi
fi
- echo " mount -o compress=lzo $IMGFILE $DIRMOUNT"
- mount -o compress=lzo "$IMGFILE" "$DIRMOUNT" &> $OGLOGCOMMAND
- # si ya esta montado $? = 32
- [ $? -eq 0 -o $? -eq 32 ] || ogRaiseError $OG_ERR_IMAGE "$3 $4"
- touch "$DIRMOUNT/ogimg.info"
+ # Monto la imagen
+ ogMountImage $1 "$2" $3 &>/dev/null
+ [ $? -eq 0 ] || ogRaiseError $OG_ERR_IMAGE "$3 $4"
+ touch "$DIRMOUNT/ogimg.info"
- #fi
# Si existe dispositivo de loop lo borro.
[ $LOOPDEVICE ] && losetup -d $LOOPDEVICE 2>&1 &>/dev/null
@@ -159,7 +172,14 @@ rm $ORIG/ogimg.* 2>/dev/null
# En las diferenciales no sabemos el tamaño -> ponemos una constante.
SIZEDATA=${SIZEDATA:-"SIZEDATA"}
-echo "#BRTFS:LZO:$FSTYPE:$SIZEDATA" > $IMGINFO
+# Incluimos información de la imagen. Segun el kernel sera ext4 o btrfs.
+#if [[ "$(uname -r)" < "3.7" ]]; then
+if [ $(uname -r|cut -d. -f2) -lt 7 ]; then
+ echo "#EXT4:LZO:$FSTYPE:$SIZEDATA" > $IMGINFO
+else
+ echo "#BTRFS:LZO:$FSTYPE:$SIZEDATA" > $IMGINFO
+fi
+
if [ "$IMGTYPE" == "img" ]; then
# Imagen Basica
echo " rsync -aHAXvn --delete $ORIG/ $DIREMPTY >> $IMGINFO" | tee -a $OGLOGSESSION $OGLOGFILE
@@ -169,7 +189,6 @@ if [ "$IMGTYPE" == "img" ]; then
else
# Imagen Diferencial
- # TODO en el echo quitar la $OPTRSYNC para que no se vea el fichero de claves
echo " rsync -aHAXvn$OPTRSYNC --delete $ORIG/ $DESTRSYNC a $IMGLIST" | tee -a $OGLOGSESSION $OGLOGFILE
rsync -aHAXvn$OPTRSYNC $PASSWORD --delete "$ORIG/" "$DESTRSYNC" >> $IMGLIST
sed -i -e s/"^sent.*.bytes\/sec"//g -e s/^total.*.speedup.*.$//g -e s/"sending.*.list"//g $IMGLIST
@@ -188,7 +207,7 @@ fi
# Guardamos el contenido de las acl (Solo win) Necesario particion desmontada (esta asi)
ogUnmount $1 $2
if [ $FSTYPE == "NTFS" ]; then
- echo " ntfs-3g.secaudit -b $PART /" |tee -a $OGLOGSESSION $OGLOGFILE
+ echo " ntfs-3g.secaudit -b $PART /" |tee -a $OGLOGSESSION $OGLOGFILE
ntfs-3g.secaudit -b $PART / > $IMGACL
fi
@@ -252,12 +271,14 @@ if [ $(wc -l $DEST/$IMGLN|cut -f1 -d" ") -ne 0 ]; then
fi
# Restauramos acl
-if [ "$(ogGetFsType $1 $2)" == "NTFS" ] ; then
+if [ "$(ogGetFsType $1 $2)" == "NTFS" -a -f $DEST/$IMGACL ] ; then
cd /
cp $DEST/$IMGACL /tmp
ogUnmount "$1" "$2"
echo " ntfs-3g.secaudit -se $PART" |tee -a $OGLOGSESSION $OGLOGFILE
ntfs-3g.secaudit -se $PART /tmp/$IMGACL
+ # Para evitar que de falso error
+ echo ""
fi
}
@@ -416,9 +437,22 @@ fi
DIRMOUNT=$(ogGetMountDir "$2" ${IMGEXT#*\.})
if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
+ # Si está montado nada que hacer.
+ df | grep "$DIRMOUNT$" 2>&1 >/dev/null && echo "/tmp/$DIRMOUNT" && return 0
+
IMGFILE=$(ogGetPath "$1" /"$2.$IMGEXT")
mkdir -p "/tmp/$DIRMOUNT"
- mount -o compress=lzo "$IMGFILE" "/tmp/$DIRMOUNT" 1>/dev/null
+
+ # FS de la imagen segun la version del kernel: < 3.7 ext4, si >= btrfs
+ #if [[ "$(uname -r)" < "3.7" ]]; then
+ if [ $(uname -r|cut -d. -f2) -lt 7 ]; then
+ mount -t ext4 -o loop "$IMGFILE" "/tmp/$DIRMOUNT" 1>/dev/null
+ else
+ mount -o compress=lzo "$IMGFILE" "/tmp/$DIRMOUNT" 1>/dev/null
+ fi
+
+ # Comprobamos que se ha montado bien
+ [ $? -eq 0 ] || ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $3" || return $?
echo "/tmp/$DIRMOUNT"
else
@@ -554,8 +588,6 @@ echo ""
}
-# DA ERROR
-# ERROR: unable to resize 'imagen' - File too large
function ogReduceImage () {
#/**
# ogReduceImage
@@ -567,7 +599,7 @@ function ogReduceImage () {
#@exception OG_ERR_FORMAT # 1 formato incorrecto.
#@exception OG_ERR_NOTFOUND # 2 Fichero o dispositivo no encontrado.
#*/
-local IMGEXT DIRMOUNT AVAILABLE USED IMGDIR IMGFILE ENDSIZE
+local IMGEXT DIRMOUNT AVAILABLE USED IMGDIR IMGFILE ENDSIZE LOOPDEVICE
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \
"$FUNCNAME REPO Ubuntu12" \
@@ -580,7 +612,13 @@ if [ $# -lt 2 ]; then
return $?
fi
+
[ "$3" == "" -o "$3" == "img" ] && IMGEXT="img" || IMGEXT="img.diff"
+IMGDIR=$(ogGetParentPath "$1" "/$2")
+IMGFILE="${IMGDIR}"/$(basename "/$2").$IMGEXT
+
+# Solo es posible para imagenes EXT4. Si no es EXT4 salimos sin error
+file $IMGFILE | grep -i " ext4 filesystem " 2>&1 > /dev/null || return 0
if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
# Al montar se comprueba la existencia de la imagen
@@ -588,21 +626,40 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
AVAILABLE=$(df -k|grep "$DIRMOUNT$"|awk '{print $4}')
# Si el espacio libre menor que 500Mb nos salimos
- if [ $AVAILABLE -lt 500000 ]; then
+ if [ $AVAILABLE -lt 200000 ]; then
ogUnmountImage $1 $2 ${IMGEXT#*\.}
return 0
fi
- # Reducimos el archivo de imagen:
- IMGDIR=$(ogGetParentPath "$1" "/$2")
- IMGFILE=${IMGDIR}/$(basename "/$2").$IMGEXT
- USED=$(df -k|grep "$DIRMOUNT$"|awk '{print $3}')
- let ENDSIZE=$USED+500000
- echo -e -n " btrfs filesystem resize "$ENDSIZE"k $DIRMOUNT \n "
- btrfs filesystem resize "$ENDSIZE"k $DIRMOUNT
+
+ # Calculamos la diferencia entre el tamaño interno y externo
+ EXTSIZE=$(ls -l --block-size=1024 $IMGFILE | cut -f5 -d" ")
+ INTSIZE=$(df -k|grep "$DIRMOUNT"|awk '{print $2}')
+ let EDGESIZE=$EXTSIZE-$INTSIZE
+
ogUnmountImage $1 $2 ${IMGEXT#*\.}
- echo " truncate --size=\"$ENDSIZE\"k $IMGFILE "
- truncate --size="$ENDSIZE"k $IMGFILE
+ LOOPDEVICE=$(losetup -f)
+ losetup $LOOPDEVICE "$IMGFILE"
+
+ # Redimensiono sistema de ficheros
+ echo resize2fs -fpM $LOOPDEVICE
+ resize2fs -fpM $LOOPDEVICE |tee -a $OGLOGCOMMAND
+ ogMountImage $1 $2 ${IMGEXT#*\.}
+
+ # Calculamos el tamaño final del archivo
+ INTSIZE=$(df -k|grep "$DIRMOUNT"|awk '{print $2}')
+ let EXTSIZE=$INTSIZE+$EDGESIZE
+ umount $DIRMOUNT
+
+ # Si existe dispositivo de loop lo borro.
+ [ $LOOPDEVICE ] && losetup -d $LOOPDEVICE
+
+ # Corto el archivo al tamaño del sistema de ficheros.
+ echo " truncate --size=\"$EXTSIZE\"k $IMGFILE "
+ truncate --size="$EXTSIZE"k $IMGFILE
+
+ rmdir $DIRMOUNT
+
else
[ -z $REPOIP ] && REPOIP=$(ogGetRepoIp)
echo " hose $REPOIP 2009 --out sh -c echo -ne REDUCE_IMAGE \"$2\" ${IMGEXT#*\.}"
@@ -614,8 +671,37 @@ fi
+function ogIsSyncImage () {
+#/**
+# ogIsSyncImage
+#@brief Comprueba si la imagen es sincronizable
+#@param 1 Repositorio [ REPO | CACHE ]
+#@param 2 Nombre Imagen
+#@param 3 Tipo Imagen [ img |diff ]
+#@return
+#@exception OG_ERR_FORMAT # 1 formato incorrecto.
+#@exception OG_ERR_NOTFOUND # 2 Fichero o dispositivo no encontrado.
+#*/
+local IMGEXT IMGDIR IMGFILE
+
+if [ "$*" == "help" ]; then
+ ogHelp "$FUNCNAME" "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \
+ "$FUNCNAME REPO Ubuntu12" \
+ "$FUNCNAME CACHE Windows7 diff"
+ return
+fi
+if [ $# -lt 2 ]; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $FUNCNAME [ REPO|CACHE ] image_name [ extension ]"
+ return $?
+fi
+[ "$3" == "" -o "$3" == "img" ] && IMGEXT="img" || IMGEXT="img.diff"
+IMGDIR=$(ogGetParentPath "$1" "/$2")
+IMGFILE="${IMGDIR}"/$(basename "/$2").$IMGEXT
+file "$IMGFILE" | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " >/dev/null
+[ $? -eq 0 ] && return 0 || return $OG_ERR_DONTSYNC_IMAGE
+}
diff --git a/client/shared/scripts/createBaseImage b/client/shared/scripts/createBaseImage
index 3a38631b..d4d853dc 100755
--- a/client/shared/scripts/createBaseImage
+++ b/client/shared/scripts/createBaseImage
@@ -27,18 +27,14 @@
trap "onexit $1 $2 $3 \"$4\"" 1 2 3 6 9 14 15 ERR
# Establecemos factor de compresion
-COMPRESS=90/100
-COMPRESSLINUX=80/100
+# !!! Se configura en las lineas 110 y 116.
# Si salimos con error demontamos la imagen y desbloqueamos la imagen y la particion
function onexit() {
local exit_status=$?
echo "$MSG_ERR_GENERIC $exit_status" |tee -a $OGLOGFILE $OGLOGSESSION
- echo ogUnmountImage $3 "$4" $IMGEXT
ogUnmountImage $3 "$4" $IMGEXT &>/dev/null
- echo ogUnlockImage "$3" "/$4.$IMGEXT"
ogUnlockImage "$3" "/$4.$IMGEXT"
- echo ogUnlock $1 $2
ogUnlock $1 $2
exit $exit_status
}
@@ -49,6 +45,8 @@ TIME1=$SECONDS
# Factor de calculo de Time out al crear imagen: valor por defecto en engine.cfg
CREATESPEED=${CREATESPEED:-"100000*4"}
+# Sistema de fichero de la imagen según kernel, menor que 3.7 EXT4. comparamos revision
+[ $(uname -r|cut -d. -f2) -lt 7 ] && IMGFS="EXT4" || IMGFS="BTRFS"
PROG="$(basename $0)"
# Si se solicita, mostrar ayuda.
@@ -95,11 +93,14 @@ case "$(ogGetFsType $1 $2)" in
EXT[234])
ogCleanLinuxDevices $1 $2
rm -rf $ORIG/tmp/*
- COMPRESS=$COMPRESSLINUX
+ # Compresion linux && ext4 || btrfs
+ [ $IMGFS == "EXT4" ] && COMPRESS=110/100 || COMPRESS=80/100
;;
NTFS)
[ $(ogGetPath $1 $2 pagefile.sys) ] && ogDeleteFile $1 $2 pagefile.sys
[ $(ogGetPath $1 $2 hiberfil.sys) ] && ogDeleteFile $1 $2 hiberfil.sys
+ # Compresion windows && ext4 || btrfs
+ [ $IMGFS == "EXT4" ] && COMPRESS=120/100 || COMPRESS=90/100
;;
esac
@@ -153,8 +154,8 @@ ogSyncCreate $1 $2 $3 "$4" $IMGEXT
# Lo comantamos hasta probar -> da error de ERROR: unable to resize '/tmp/mount/IMG' - No space left on device
# Reducimos la imagen
-#echo "[90] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT" | tee -a $OGLOGSESSION $OGLOGFILE
-#ogReduceImage $3 "$4" $IMGEXT
+echo "[90] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT" | tee -a $OGLOGSESSION $OGLOGFILE
+ogReduceImage $3 "$4" $IMGEXT
# Desmontamos la Imagen
ogUnmountImage $3 "$4" $IMGEXT
@@ -164,7 +165,8 @@ TIMEAUX5=$[SECONDS-TIMEAUX3]
echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX3/60]m $[TIMEAUX3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
# Comprobamos que la imagen esta bien detectacdo que es un sistema de ficheros.
-file $IMGFILE|grep "BTRFS Filesystem" 2>&1 >/dev/null || ogRaiseError $OG_ERR_IMAGE "$3 $4"
+#file $IMGFILE|grep -i -e "BTRFS Filesystem" -e " ext4 filesystem " 2>&1 >/dev/null || ogRaiseError $OG_ERR_IMAGE "$3 $4"
+ogIsImageSync $3 "$4" "img" || ogRaiseError $OG_ERR_IMAGE "$3 $4"
TIMEAUX7=$[SECONDS-TIME2]
echo " $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX7/60]m $[TIMEAUX7%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
diff --git a/client/shared/scripts/createDiffImage b/client/shared/scripts/createDiffImage
index 7292d13c..aa3d1be3 100755
--- a/client/shared/scripts/createDiffImage
+++ b/client/shared/scripts/createDiffImage
@@ -27,6 +27,10 @@
#@date 2012-12-04
#*/ ##
trap "onexit $1 $2 $3 \"$4\" \"$5\"" 1 2 3 6 9 14 15 ERR
+
+# Establecemos factor de compresion
+# !!! Se configura en las lineas 122 y 128.
+
function onexit() {
local exit_status=$?
echo "$MSG_ERR_GENERIC $exit_status" |tee -a $OGLOGFILE $OGLOGSESSION
@@ -38,15 +42,13 @@ function onexit() {
exit $exit_status
}
-# Establecemos factor de compresion
-COMPRESS=90/100
-COMPRESSLINUX=80/100
-
#Carga el configurador del engine desde el fichero engine.cfg
[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
# Factor de calculo de Time out al crear imagen: valor por defecto en engine.cfg
CREATESPEED=${CREATESPEED:-"100000*4"}
+# Sistema de fichero de la imagen según kernel, menor que 3.7 EXT4. comparamos revision
+[ $(uname -r|cut -d. -f2) -lt 7 ] && IMGFS="EXT4" || IMGFS="BTRFS"
TIME1=$SECONDS
@@ -75,7 +77,8 @@ ogIsLocked "$1" "$2" && ogRaiseError $OG_ERR_LOCKED "$1 $2"
IMGFILE=$(ogGetPath "$3" "$4.$IMGEXT") || ogRaiseError $OG_ERR_NOTFOUND "$3 $4.$IMGEXT"
# Comprobar que la imagen completa es sincronizable
-file $IMGFILE | grep " BTRFS Filesystem" >/dev/null || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"
+#file $IMGFILE | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " >/dev/null || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"
+ogIsImageSync "$3" "$4" "img" || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"
# Comprobar que no está bloqueada
ogIsImageLocked "$3" "$4.$IMGEXT" && ogRaiseError $OG_ERR_LOCKED "$3 $4.$IMGEXT"
@@ -113,15 +116,19 @@ TIMEAUX1=$[SECONDS-TIME1]
echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX1/60]m $[TIMEAUX1%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
# Borramos ficheros de paginacion y configuracion
+# Establecemos factor de compresion, varia segun el sistema operativo y el kernel.
case "$(ogGetFsType $1 $2)" in
EXT[234])
ogCleanLinuxDevices $1 $2
rm -rf $ORIG/tmp/*
- COMPRESS=$COMPRESSLINUX
+ # Compresion linux && ext4 || btrfs
+ [ $IMGFS == "EXT4" ] && COMPRESS=110/100 || COMPRESS=80/100
;;
NTFS)
[ $(ogGetPath $1 $2 pagefile.sys) ] && ogDeleteFile $1 $2 pagefile.sys
[ $(ogGetPath $1 $2 hiberfil.sys) ] && ogDeleteFile $1 $2 hiberfil.sys
+ # Compresion windows && ext4 || btrfs
+ [ $IMGFS == "EXT4" ] && COMPRESS=130/100 || COMPRESS=90/100
;;
esac
@@ -203,7 +210,8 @@ ogUnlockImage "$3" "/$5.$DIFFEXT"
ogUnlock $1 $2
# Comprobamos que la imagen esta bien
-file "$DIFFFILE" |grep "BTRFS Filesystem" >/dev/null || ogRaiseError $OG_ERR_IMAGE "$3 $4"
+#file "$DIFFFILE" |grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " >/dev/null || ogRaiseError $OG_ERR_IMAGE "$3 $5"
+ogIsImageSync $3 "$5" diff || ogRaiseError $OG_ERR_IMAGE "$3 $5"
#resumen de la operacion
IMGSIZE=$(ls -l --block-size=1024 ${DIFFFILE}| cut -f5 -d" ")
diff --git a/client/shared/scripts/restoreBaseImage b/client/shared/scripts/restoreBaseImage
index c684e6a3..619e5daa 100755
--- a/client/shared/scripts/restoreBaseImage
+++ b/client/shared/scripts/restoreBaseImage
@@ -58,7 +58,8 @@ fi
REPOFILE=$(ogGetPath "REPO" "$2.$IMGEXT") || ogRaiseError $OG_ERR_NOTFOUND "REPO, $2.$IMGEXT"
# Comprobar que es sincronizable (con REPO)
-file $REPOFILE | grep " BTRFS Filesystem" 2>&1 > /dev/null || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $2"
+#file $REPOFILE | grep -i -e " BTRFS Filesystem" -e " ext4 filesystem " 2>&1 > /dev/null || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $2"
+ogIsImageSync $1 "$2" $IMGEXT || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $2"
# Comprobamos si el sistema de ficheros se puede montar
ogMount "$3" "$4" &>/dev/null || RETVAL=$?
@@ -87,7 +88,8 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
# Sincronizamos si existe el fichero y si no usamos updateCache.
echo "[10] $MSG_SCRIPTS_TASK_START updateCache REPO $2.$IMGEXT $PROTO $6" | tee -a $OGLOGFILE
echo " updateCache REPO" "/$2.$IMGEXT" "$PROTO" "$6" | tee -a $OGLOGFILE
- updateCache REPO "/$2.$IMGEXT" "$PROTO" "$6" &>> $OGLOGCOMMAND
+ #updateCache REPO "/$2.$IMGEXT" "$PROTO" "$6" &>> $OGLOGCOMMAND
+ updateCache REPO "/$2.$IMGEXT" "$PROTO" "$6" 2>&1 | tee -a $OGLOGCOMMAND
RETVAL=$?
if [ "$RETVAL" != "0" ]
then
@@ -127,10 +129,10 @@ ogUnlock $3 $4
echo "[70] $MSG_HELP_ogRestoreInfoImage" |tee -a $OGLOGFILE
ogRestoreInfoImage $3 $4 &>>$OGLOGCOMMAND
-
# Llamar al script de post-configuración del sistema operativo.
echo "[90] $MSG_HELP_configureOs" |tee -a $OGLOGFILE
-configureOs $3 $4 &>>$OGLOGCOMMAND
+# el || echo es para evitar que se maneje el error.
+configureOs $3 $4 &>>$OGLOGCOMMAND || echo "$?" &>>$OGLOGCOMMAND
TIME=$[SECONDS-TIME1]
echo "[100] $MSG_SCRIPTS_END $MSG_SCRIPTS_TIME_TOTAL: $[TIME/60]m $[TIME%60]s" |tee -a $OGLOGFILE
diff --git a/client/shared/scripts/restoreDiffImage b/client/shared/scripts/restoreDiffImage
index dc7a3762..6d1a66a1 100755
--- a/client/shared/scripts/restoreDiffImage
+++ b/client/shared/scripts/restoreDiffImage
@@ -69,7 +69,8 @@ PART=$(ogDiskToDev "$3" "$4" 2>/dev/null ) || ogRaiseError $OG_ERR_PARTITION "$
[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
# Comprobar que es sincronizable
-file $REPODIFFFILE | grep " BTRFS Filesystem" >/dev/null || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"
+#file $REPODIFFFILE | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " >/dev/null || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"
+ogIsImageSync $3 "$4" diff || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"
PROTO=${5:-"UNICAST"}
@@ -120,7 +121,8 @@ ogRestoreInfoImage "$3" "$4" &>$OGLOGCOMMAND
# Llamar al script de post-configuración del sistema operativo.
echo "[90] $MSG_HELP_configureOs."
-configureOs $3 $4
+# el || echo es para evitar que se maneje el error.
+configureOs $3 $4 &>>$OGLOGCOMMAND || echo "$?" &>>$OGLOGCOMMAND
TIME=$[SECONDS-TIME1]
diff --git a/client/shared/scripts/updateCache b/client/shared/scripts/updateCache
index 3c59d19e..94ab4dda 100755
--- a/client/shared/scripts/updateCache
+++ b/client/shared/scripts/updateCache
@@ -55,16 +55,18 @@ REPOFILE=$(ogGetPath "REPO" "/$2") || ogRaiseError $OG_ERR_NOTFOUND "REPO /$2"
echo "$MSG_SCRIPTS_UPDATECACHE_DOUPDATE "
# Distingo si es monolitica o sincronizable
-file $REPOFILE | grep " BTRFS Filesystem" 2>&1 > /dev/null
+file $REPOFILE | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " 2>&1 > /dev/null
if [ $? == 0 ]; then
- IMGTYPE="RSYNC"
- # Para imagen sincronizada, si hay imagen en cache uso rsync, si no otro protocolo
+ IMGSYNC=TRUE
+ # Para imagen sincronizada, si hay imagen en cache siempre protocolo = rsync.
CACHEFILE=$(ogGetPath "CACHE" "/$2") && PROTOCOLO="RSYNC"
# Si es imagen sincronizada siempre da distinto md5. No podemos comprobar -> actualizamos.
RETVAL=0
else
- IMGTYPE="MONOLITICA"
+ # Si la imagen es monolitica y ha elegido protocolo = RSYNC salimos con error.
+ [ $PROTOCOLO == "RSYNC" ] && exit $(ogRaiseError $OG_ERR_DONTSYNC_IMAGE "REPO $2"; exit 1)
+ IMGSYNC=FALSE
#TODO: ogUpdateCacheIsNecesary debe borrar la imagen que tenga igual nombre pero distinto sum-
ogUpdateCacheIsNecesary $1 $2
RETVAL=$?
@@ -81,12 +83,15 @@ REALFILESIZE=$(ls -l --block-size=1024 $(ogGetPath $REPOSITORIO "$2") | cut -f5
# La sincronizada, si existe la imagen en cache el espacio necesario
# es la nueva menos lo que ocupa la que ya hay.
if [ "$PROTOCOLO" == "RSYNC" ]; then
- CACHEFILESIZE=$(ls -l --block-size=1024 $(ogGetPath "CACHE" "$2") | cut -f5 -d" ")
- let SIZEREQUIRED=$CACHEFILESIZE-$FILESIZE
+ if [ "$CACHEFILE" == "" ]; then
+ CACHEFILESIZE=0
+ else
+ CACHEFILESIZE=$(ls -l --block-size=1024 "$CACHEFILE" | cut -f5 -d" ")
+ fi
+ let SIZEREQUIRED=$REALFILESIZE-$CACHEFILESIZE
[ $SIZEREQUIRED -lt 0 ] && SIZEREQUIRED=0
else
SIZEREQUIRED=$FILESIZE
-
fi
echo "$MSG_SCRIPTS_UPDATECACHE_CHECKSIZECACHE"
@@ -128,7 +133,7 @@ then
fi
# Comprobamos que imagen cache igual a la del repo. Si sincronizada no podemos comprobar.
-[ "$IMGTYPE" == "RSYNC" ] || ogUpdateCacheIsNecesary $REPOSITORIO "$2"
+[ "$IMGSYNC" == "TRUE" ] || ogUpdateCacheIsNecesary $REPOSITORIO "$2"
RETVAL=$?
# si RETVAL=0 => actualizamos si RETVAL=1 no actaulizasmo-exit 0 || si RETVAL>2 exit 1
[ "$RETVAL" == "1" ] && exit 0
@@ -204,26 +209,17 @@ case "$PROTOCOLO" in
[ "${2##*.}" == "img" ] && IMGTYPE="img" || IMGTYPE="diff"
IMGNAME="${2%.img*}"
- DIRMOUNT="$(ogGetMountDir "$IMGNAME" $IMGTYPE)"
+ DIRMOUNT=$(ogGetMountDir "$IMGNAME" $IMGTYPE)
DIRLOCAL="/tmp/$DIRMOUNT"
mkdir $DIRLOCAL 2>/dev/null
echo "$MSG_SCRIPTS_UPDATECACHE_CHECKSIZEIMG"
+ # Si la imagen no existe la creo
# Si la imagen del repositorio es mayor, redimensiono la imagen de cache
- if [ $CACHEFILESIZE -lt $REALFILESIZE ]; then
- # Si la imagen esta montada la desmonto
- mount |grep $CACHEFILE >/dev/null && umount $CACHEFILE
- echo " $MSG_SYNC_RESIZE." | tee -a $OGLOGSESSION $OGLOGFILE
- echo " truncate --size=>$REALFILESIZE k $CACHEFILE" | tee -a $OGLOGSESSION $OGLOGFILE
- truncate --size=">$REALFILESIZE"k $CACHEFILE &> $OGLOGCOMMAND
- echo " mount -o compress=lzo $CACHEFILE $DIRLOCAL"
- mount -o compress=lzo $CACHEFILE $DIRLOCAL
- echo " btrfs filesystem resize max $DIRLOCAL"
- btrfs filesystem resize max $DIRLOCAL
+ if [ "$CACHEFILE" == "" -o $CACHEFILESIZE -lt $REALFILESIZE ]; then
+ ogCreateFileImage CACHE "$IMGNAME" $IMGTYPE $REALFILESIZE
TIMEAUX3=$[SECONDS-TIMEAUX3]
echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX3/60]m $[TIMEAUX3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
-
-
fi
# Montamos las imagenes para sincronizarlas
ogMountImage CACHE "$IMGNAME" $IMGTYPE >/dev/null
@@ -245,7 +241,11 @@ echo " [ ] $RESUMEUPDATECACHE " | tee -a $OGLOGSESSION $OGLOGFILE
echo " [ ] $MSG_SCRIPTS_TIME_PARTIAL updateCache $[TIME1/60]m $[TIME1%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
echo " [ ] $MSG_SCRIPTS_TASK_START $MSG_HELP_ogCalculateChecksum " | tee -a $OGLOGSESSION $OGLOGFILE
TIME2=$SECONDS
-if [ "$IMGTYPE" == "MONOLITICA" ]; then
+# Si es imagen sincronizada siempre da distinto md5. No podemos comprobar
+if [ "$IMGSYNC" == "TRUE" ]; then
+ # RETVAL="1" -> OK RETVAL="2" -> error # valores igual que ogUpdateCacheIsNecesary
+ [ $PROTOCOLO == "RSYNC" ] || RETVAL=1
+else
ogUpdateCacheIsNecesary $REPOSITORIO "$2"
RETVAL=$?
fi