summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xadmin/Sources/Services/ogAdmRepoAux12
-rwxr-xr-xclient/engine/Rsync.lib61
-rw-r--r--client/shared/etc/lang.ca_ES.conf1
-rw-r--r--client/shared/etc/lang.en_GB.conf1
-rw-r--r--client/shared/etc/lang.es_ES.conf1
-rwxr-xr-xclient/shared/scripts/createBaseImage72
-rwxr-xr-xclient/shared/scripts/createDiffImage92
-rwxr-xr-xclient/shared/scripts/restoreBaseImage53
-rwxr-xr-xclient/shared/scripts/restoreDiffImage36
9 files changed, 177 insertions, 152 deletions
diff --git a/admin/Sources/Services/ogAdmRepoAux b/admin/Sources/Services/ogAdmRepoAux
index d6e5dac1..6b76ec86 100755
--- a/admin/Sources/Services/ogAdmRepoAux
+++ b/admin/Sources/Services/ogAdmRepoAux
@@ -271,6 +271,18 @@ case "$PARM1" in
rmdir $DIRMOUNT
;;
+ LOCK_IMAGE)
+ # Bloquea el archivo de la imagen.
+ #1 LOCK_IMAGE
+ #2 Nombre_Imagen.extension
+ touch "$REPODIR$PARM2.lock"
+ ;;
+ UNLOCK_IMAGE)
+ # Desloquea el archivo de la imagen.
+ #1 UNLOCK_IMAGE
+ #2 Nombre_Imagen.extension
+ rm "$REPODIR$PARM2.lock"
+ ;;
default)
echolog "Solicitud con parametros \"$PARM\" no realizada, no registrada o con errores"
;;
diff --git a/client/engine/Rsync.lib b/client/engine/Rsync.lib
index ba8edcc0..04f36f23 100755
--- a/client/engine/Rsync.lib
+++ b/client/engine/Rsync.lib
@@ -35,7 +35,7 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
IMGFILE="${IMGDIR}/$(basename "/$2").$IMGEXT"
## Si no existe, crear subdirectorio de la imagen.
if [ $? != 0 ]; then
- echo " $MSG_HELP_ogMakeDir \"$1 $(dirname "$2")." | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " $MSG_HELP_ogMakeDir \"$1 $(dirname "$2")." | tee -a $OGLOGSESSION $OGLOGFILE
ogMakeDir "$1" "$(dirname "/$2")" || return $(ogRaiseError $OG_ERR_NOTWRITE "$3 /$4"; echo $?)
IMGDIR="$(ogGetParentPath "$1" "/$2")" || return $(ogRaiseError $OG_ERR_NOTWRITE "$3 /$4"; echo $?)
fi
@@ -52,7 +52,7 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
if [ "$BACKUP" == "true" ]; then
# Copia seguridad
- echo " $MSG_SCRIPTS_FILE_RENAME \"$IMGFILE\" -> \"$IMGFILE.ant\"." | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " $MSG_SCRIPTS_FILE_RENAME \"$IMGFILE\" -> \"$IMGFILE.ant\"." | tee -a $OGLOGSESSION $OGLOGFILE
cp -f "$IMGFILE" "$IMGFILE.ant"
mv -f "$IMGFILE.torrent" "$IMGFILE.torrent.ant" 2>/dev/null
rm -f "$IMGFILE.sum"
@@ -60,35 +60,35 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
IMGSIZE=$(ls -l --block-size=1024 "$IMGFILE" | awk '{print $5}')
if [ $IMGSIZE -lt $SIZEREQUIRED ];then
- echo " $MSG_SYNC_RESIZE" | tee -a $OGLOGSESSION $OGLOGFILE
- echo " truncate --size=>$SIZEREQUIRED k $IMGFILE" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " $MSG_SYNC_RESIZE" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " truncate --size=>$SIZEREQUIRED k $IMGFILE" | tee -a $OGLOGSESSION $OGLOGFILE
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"
+ ogEcho log session " resize2fs -f $LOOPDEVICE"
resize2fs -f $LOOPDEVICE &> $OGLOGCOMMAND
else
- echo " ogMountImage $1 "$2" $3"
+ ogEcho log session " ogMountImage $1 "$2" $3"
ogMountImage $1 "$2" $3
- echo " btrfs filesystem resize max $DIRMOUNT"
+ ogEcho log session " 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"
+ ogEcho log session " dd if=/dev/zero of=$IMGFILE bs=1024 count=$SIZEREQUIRED"
dd if=/dev/zero of="$IMGFILE" bs=1024 count=$SIZEREQUIRED 2>&1 | tee -a $OGLOGCOMMAND
#Formateamos imagen
losetup $LOOPDEVICE $IMGFILE
# 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"
+ ogEcho log session " mkfs.ext4 -i 4096 -b 4096 -L "${2##*\/}" $LOOPDEVICE"
mkfs.ext4 -i 4096 -b 4096 -L "${2##*\/}" $LOOPDEVICE 2>&1 |tee -a $OGLOGCOMMAND
else
- echo " mkfs.btrfs -L ${2##*\/} $LOOPDEVICE "
+ ogEcho log session " mkfs.btrfs -L ${2##*\/} $LOOPDEVICE "
mkfs.btrfs -L "${2##*\/}" $LOOPDEVICE 2>&1 | tee -a $OGLOGCOMMAND
fi
fi
@@ -102,7 +102,7 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
else
[ -z $REPOIP ] && REPOIP=$(ogGetRepoIp)
- echo " hose $REPOIP 2009 --out sh -c \"echo -ne CREATE_IMAGE $2 $3 $SIZEREQUIRED \"" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " hose $REPOIP 2009 --out sh -c \"echo -ne CREATE_IMAGE $2 $3 $SIZEREQUIRED \"" | tee -a $OGLOGSESSION $OGLOGFILE
hose $REPOIP 2009 --out sh -c "echo -ne CREATE_IMAGE \"$2\" $3 $SIZEREQUIRED"
fi
@@ -177,21 +177,21 @@ SIZEDATA=${SIZEDATA:-"SIZEDATA"}
# 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
+ echo "#EXT4:NO:$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
+ ogEcho log session " rsync -aHAXvn --delete $ORIG/ $DIREMPTY >> $IMGINFO" | tee -a $OGLOGSESSION $OGLOGFILE
rsync -aHAXvn --delete $ORIG/ $DIREMPTY>> $IMGINFO
sed -i -e s/"^sent.*.bytes\/sec"//g -e s/^total.*.speedup.*.$//g -e s/"sending.*.list"//g $IMGINFO
sed -i '/^\.\//d' $IMGINFO
else
# Imagen Diferencial
- echo " rsync -aHAXvn$OPTRSYNC --delete $ORIG/ $DESTRSYNC a $IMGLIST" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " 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
sed -i '/^\.\//d' $IMGLIST
@@ -215,7 +215,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
+ ogEcho log session " ntfs-3g.secaudit -b $PART /" |tee -a $OGLOGSESSION $OGLOGFILE
ntfs-3g.secaudit -b $PART / > $IMGACL
fi
@@ -335,7 +335,7 @@ 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
+ ogEcho log session " ntfs-3g.secaudit -se $PART" |tee -a $OGLOGSESSION $OGLOGFILE
ntfs-3g.secaudit -se $PART /tmp/$IMGACL
# Para evitar que de falso error
echo ""
@@ -394,9 +394,9 @@ else
DESTRSYNC="$USERRSYNC@$REPOIP::ogimages/$DIRMOUNT"
fi
# Sincronizamos los datos de la partición a la imagen
-echo " rsync -aHAX$OPTRSYNC --progress --inplace --delete $FILESFROM $ORIG/ $DESTRSYNC" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " rsync -aHAX$OPTRSYNC --progress --inplace --delete $FILESFROM $ORIG/ $DESTRSYNC" | tee -a $OGLOGSESSION $OGLOGFILE
rsync -aHAX$OPTRSYNC $PASSWORD --progress --inplace --delete $FILESFROM "$ORIG/" "$DESTRSYNC" 2>&1| egrep "^deleting|^sent|^sending|^total|%" &>> $OGLOGCOMMAND
-echo " rsync -aHAX$OPTRSYNC --inplace /tmp/ogimg* $DESTRSYNC" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " rsync -aHAX$OPTRSYNC --inplace /tmp/ogimg* $DESTRSYNC" | tee -a $OGLOGSESSION $OGLOGFILE
rsync -aHAX$OPTRSYNC $PASSWORD --inplace /tmp/ogimg* "$DESTRSYNC"
}
@@ -456,7 +456,7 @@ fi
# Nos traemos listado ficheros y bajamos la imagen
-echo " $MSG_SYNC_RESTORE" |tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " $MSG_SYNC_RESTORE" |tee -a $OGLOGSESSION $OGLOGFILE
# Si la imagen es diferencial nos traemos los archivos de informacion de la imagen.
if [ "$3" == "diff" ]; then
@@ -464,19 +464,19 @@ if [ "$3" == "diff" ]; then
IMGINFO="ogimg.info"
FILESFROM=" --files-from=$DESTRSYNC/$IMGINFO"
- echo " rsync -aHAX$OPTRSYNC --progress $ORIG/ogimg* $DESTRSYNC" |tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " rsync -aHAX$OPTRSYNC --progress $ORIG/ogimg* $DESTRSYNC" |tee -a $OGLOGSESSION $OGLOGFILE
rsync -aHAX$OPTRSYNC $PASSWORD --progress "$ORIG"/ogimg* $DESTRSYNC
# Borramos linea de información de la imagen, sino busca un fichero con ese nombre
sed -i '/^\#/d' $DESTRSYNC/$IMGINFO
cd $DESTRSYNC
# Diferencial: Borramos archivos sobrantes.
- echo " $MSG_SYNC_DELETE" |tee -a $OGLOGFILE
+ ogEcho log session " $MSG_SYNC_DELETE" |tee -a $OGLOGFILE
cat "$DESTRSYNC/ogimg.rm" 2>/dev/null | xargs rm -rf
fi
-echo " rsync -aHAX$OPTRSYNC --progress $FILESFROM $ORIG/ $DESTRSYNC" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " rsync -aHAX$OPTRSYNC --progress $FILESFROM $ORIG/ $DESTRSYNC" | tee -a $OGLOGSESSION $OGLOGFILE
rsync -aHAX$OPTRSYNC $PASSWORD --progress $FILESFROM "$ORIG/" "$DESTRSYNC" 2>&1 | egrep "^deleting|^sent|^sending|^total|%" &>> $OGLOGCOMMAND
@@ -716,7 +716,7 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
losetup $LOOPDEVICE "$IMGFILE"
# Redimensiono sistema de ficheros
- echo resize2fs -fpM $LOOPDEVICE
+ ogEcho log session resize2fs -fpM $LOOPDEVICE
resize2fs -fpM $LOOPDEVICE |tee -a $OGLOGCOMMAND
ogMountImage $1 "$2" ${IMGEXT#*\.}
@@ -729,14 +729,16 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
[ $LOOPDEVICE ] && losetup -d $LOOPDEVICE
# Corto el archivo al tamaño del sistema de ficheros.
- echo " truncate --size=\"$EXTSIZE\"k $IMGFILE "
+ ogEcho log session " truncate --size=\"$EXTSIZE\"k $IMGFILE "
truncate --size="$EXTSIZE"k "$IMGFILE"
+ # Desmonto y desbloqueo la imagen
+ rm "$IMGFILE.lock"
rmdir "$DIRMOUNT"
else
[ -z $REPOIP ] && REPOIP=$(ogGetRepoIp)
- echo " hose $REPOIP 2009 --out sh -c echo -ne REDUCE_IMAGE \"$2\" ${IMGEXT#*\.}"
+ ogEcho log session " hose $REPOIP 2009 --out sh -c echo -ne REDUCE_IMAGE \"$2\" ${IMGEXT#*\.}"
hose $REPOIP 2009 --out sh -c "echo -ne REDUCE_IMAGE \"$2\" ${IMGEXT#*\.}"
fi
@@ -817,12 +819,15 @@ DIRMOUNT="/tmp/ogCheckImage$$"
mkdir "$DIRMOUNT"
# FS de la imagen segun la version del kernel: < 3.7 ext4, si >= btrfs
if [ $(uname -r|cut -d. -f2) -lt 7 ]; then
- mount -t ext4 -o loop "$IMGFILE" "$DIRMOUNT" 1>/dev/null
+ mount -t ext4 -o loop "$IMGFILE" "$DIRMOUNT" 2>&1 | tee -a $OGLOGCOMMAND
+ RETVAL=${PIPESTATUS[0]}
else
- mount -o compress=lzo "$IMGFILE" "$DIRMOUNT" 1>/dev/null
+ mount -o compress=lzo "$IMGFILE" "$DIRMOUNT" 1>/dev/null | tee -a $OGLOGCOMMAND
+ RETVAL=${PIPESTATUS[0]}
fi
ls -C "$DIRMOUNT" | tee -a $OGLOGCOMMAND
-umount "$DIRMOUNT"
+umount "$DIRMOUNT"
rmdir "$DIRMOUNT"
+return $RETVAL
}
diff --git a/client/shared/etc/lang.ca_ES.conf b/client/shared/etc/lang.ca_ES.conf
index 11270470..1fbb708c 100644
--- a/client/shared/etc/lang.ca_ES.conf
+++ b/client/shared/etc/lang.ca_ES.conf
@@ -255,6 +255,7 @@ MSG_SYNC_RESTORE="Trae el listado ficheros y baja la imagen"
MSG_SYNC_DELETE="Diferencial: Borra archivos antiguos"
MSG_SYNC_SLEEP="Espera que se monte la imagen"
# mensajes syncronizadas complementarios a errores
+MSG_SYNC_DIFFERENTFS="El sistema de ficheros de destino no coincide con el de la imagen"
MSG_SYNC_EXTENSION="Las extensiones de la imagenes deben ser img o diff"
MSG_RESTORE="Restaura la imagen en"
diff --git a/client/shared/etc/lang.en_GB.conf b/client/shared/etc/lang.en_GB.conf
index 00186480..6ccf6e41 100644
--- a/client/shared/etc/lang.en_GB.conf
+++ b/client/shared/etc/lang.en_GB.conf
@@ -255,6 +255,7 @@ MSG_SYNC_RESTORE="Trae el listado ficheros y baja la imagen"
MSG_SYNC_DELETE="Diferencial: Borra archivos antiguos"
MSG_SYNC_SLEEP="Espera que se monte la imagen"
# mensajes syncronizadas complementarios a errores
+MSG_SYNC_DIFFERENTFS="El sistema de ficheros de destino no coincide con el de la imagen"
MSG_SYNC_EXTENSION="Las extensiones de la imagenes deben ser img o diff"
MSG_RESTORE="Restaura la imagen en"
diff --git a/client/shared/etc/lang.es_ES.conf b/client/shared/etc/lang.es_ES.conf
index 7d65ec5b..c5e09039 100644
--- a/client/shared/etc/lang.es_ES.conf
+++ b/client/shared/etc/lang.es_ES.conf
@@ -255,6 +255,7 @@ MSG_SYNC_RESTORE="Trae el listado ficheros y baja la imagen"
MSG_SYNC_DELETE="Diferencial: Borra archivos antiguos"
MSG_SYNC_SLEEP="Espera que se monte la imagen"
# mensajes syncronizadas complementarios a errores
+MSG_SYNC_DIFFERENTFS="El sistema de ficheros de destino no coincide con el de la imagen"
MSG_SYNC_EXTENSION="Las extensiones de la imagenes deben ser img o diff"
MSG_RESTORE="Restaura la imagen en"
diff --git a/client/shared/scripts/createBaseImage b/client/shared/scripts/createBaseImage
index 7d4a7ed2..f870cdf7 100755
--- a/client/shared/scripts/createBaseImage
+++ b/client/shared/scripts/createBaseImage
@@ -17,7 +17,7 @@
#@exception OG_ERR_NOTCACHE # 15 si cache no existe 15
#@exception OG_ERR_CACHESIZE # 16 si espacio de la cache local o remota no tiene espacio 16
#@exception OG_ERR_DONTMOUNT_IMAGE # 70 Error al montar una imagen sincronizada
-#@note se toma como punto de partida el script createImage, cambiando solo lo especifico para la imagen sincronizada
+#@note No necesario permiso se escritura por samba en repo.
#@todo: que hacer, si el tamaño de la cache es sufciente, pero no tiene espacio libre
#@version 1.0 - creación imagen con btrfs
#@author
@@ -31,7 +31,11 @@ function onexit() {
local exit_status=$?
ogUnmountImage $3 "$4" $IMGEXT &>/dev/null
if [ $exit_status -ne 4 ]; then
- ogUnlockImage "$3" "/$4.$IMGEXT"
+ if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
+ ogUnlockImage "$3" "/$4.$IMGEXT"
+ else
+ hose $REPOIP 2009 --out sh -c "echo -ne UNLOCK_IMAGE \"$4.$IMGEXT\" "
+ fi
ogUnlock $1 $2
fi
exit $exit_status
@@ -61,13 +65,13 @@ if [ "$*" == "help" ]; then
exit 0
fi
-[ $# -ne 4 ] && exit $(ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen" ; echo $?)
+[ $# -ne 4 ] && exit $(ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen" ; echo $?)
# Limpiamos fichero de log
echo " " > $OGLOGCOMMAND
[ "$(ogGetCaller)" == "RestaurarImagenBasica" ] || echo -n ""> $OGLOGSESSION
-echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*"
# Valores por defecto en etc/engine.cfg
IMGEXT="img"
@@ -75,29 +79,25 @@ REPOIP=$(ogGetRepoIp)
# Comprobamos si la imagen o la particion estan bloqueada:
-ogIsImageLocked "$3" "$4.$IMGEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$3 $4.$IMGEXT"; echo $?)
-ogIsLocked "$1" "$2" && exit $(ogRaiseError $OG_ERR_LOCKED "$1 $2"; echo $?)
+ogIsImageLocked "$3" "$4.$IMGEXT" && exit $(ogRaiseError session $OG_ERR_LOCKED "$3 $4.$IMGEXT"; echo $?)
+ogIsLocked "$1" "$2" && exit $(ogRaiseError session $OG_ERR_LOCKED "$1 $2"; echo $?)
# Si el repositorio es CACHE comprobamos que exista
if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
- ! ogFindCache >/dev/null && exit $(ogRaiseError $OG_ERR_NOTCACHE "CACHE "; echo $?)
+ ! ogFindCache >/dev/null && exit $(ogRaiseError session $OG_ERR_NOTCACHE "CACHE "; echo $?)
fi
-#Comprobamos acceso de escritura.
-DIRTEMP="/$4$(date +%Y%m%d-%H%M%S)"
-ogMakeDir $3 "$DIRTEMP" 2>/dev/null && ogDeleteTree $3 "$DIRTEMP" || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3" ; echo $?)
-
# Obtener información de los parámetros de entrada.
-PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $2" ; echo $?)
+PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || exit $(ogRaiseError session $OG_ERR_PARTITION "$1 $2" ; echo $?)
# Comprobar consistencia del sistema de archivos.
echo " " > $OGLOGCOMMAND
SIZEFS=$(ogGetFsSize $1 $2)
-echo "[20] $MSG_HELP_ogCheckFs $PART $SIZEFS (KB) " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[20] $MSG_HELP_ogCheckFs $PART $SIZEFS (KB) "
ogUnmount $1 $2
-ogCheckFs $1 $2 &> $OGLOGCOMMAND || exit $(ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2"; echo $?)
+ogCheckFs $1 $2 &> $OGLOGCOMMAND || exit $(ogRaiseError session $OG_ERR_PARTITION "ogCheckFs $1 $2"; echo $?)
# Comprobamos que la particion se puede montar
-ORIG=$(ogMount $1 $2) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $2" ; echo $?)
+ORIG=$(ogMount $1 $2) || exit $(ogRaiseError session $OG_ERR_PARTITION "$1 $2" ; echo $?)
# Borramos ficheros de paginacion y configuracion
case "$(ogGetFsType $1 $2)" in
@@ -121,8 +121,8 @@ let SIZEREQUIRED=$SIZEDATA*$ZSYNC/100
#Comprobar espacio libre en el contenedor.
[ "$3" == "CACHE" -o "$3" == "cache" ] && SIZEFREE=$(ogGetFreeSize `ogFindCache`)
[ "$3" == "REPO" -o "$3" == "repo" ] && SIZEFREE=$(df -k | grep $OGIMG | awk '{print $4}')
-echo " $MSG_SCRIPTS_CREATE_SIZE $SIZEREQUIRED $SIZEFREE" | tee -a $OGLOGSESSION $OGLOGFILE
-[ $SIZEREQUIRED -gt $SIZEFREE ] && exit $(ogRaiseError $OG_ERR_CACHESIZE "$3"; echo $?)
+ogEcho log session " $MSG_SCRIPTS_CREATE_SIZE $SIZEREQUIRED $SIZEFREE"
+[ $SIZEREQUIRED -gt $SIZEFREE ] && exit $(ogRaiseError session $OG_ERR_CACHESIZE "$3"; echo $?)
IMGDIR="$(ogGetParentPath "$3" "/$4")"
IMGFILE=${IMGDIR[$3]}/$(basename "/$4").$IMGEXT
@@ -130,47 +130,47 @@ IMGFILE=${IMGDIR[$3]}/$(basename "/$4").$IMGEXT
echo " " > $OGLOGCOMMAND
TIME2=$SECONDS
-ogLockImage "$3" "/$4.$IMGEXT"
+if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
+ ogLockImage "$3" "/$4.$IMGEXT"
+else
+ hose $REPOIP 2009 --out sh -c "echo -ne LOCK_IMAGE \"$4.$IMGEXT\" "
+fi
-echo "[40] $MSG_HELP_ogCreateImage $1 $2 $3 $4 " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[40] $MSG_HELP_ogCreateImage $1 $2 $3 $4 "
# Si existe el fichero de la imagen se hace copia de seguridad y se redimensiona, si no existe se crea.
-echo "[50] $MSG_HELP_ogCreateFileImage." | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[50] $MSG_HELP_ogCreateFileImage."
ogCreateFileImage $3 "$4" $IMGEXT $SIZEREQUIRED
# Creamos la lista del contenido y lo situamos en la particion a copiar.
-echo "[60] $MSG_HELP_ogCreateInfoImage" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[60] $MSG_HELP_ogCreateInfoImage"
ogCreateInfoImage $1 $2 $IMGEXT
TIMEAUX3=$[SECONDS-TIME2]
-echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX3/60]m $[TIMEAUX3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX3/60]m $[TIMEAUX3%60]s"
# Esperamos que el servidor termine de crear y montar la imagen
-ogWaitMountImage "$3" "$4" $IMGEXT $SIZEREQUIRED || exit $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$3 $4 $IMGEXT: time_out."; echo $?)
+ogWaitMountImage "$3" "$4" $IMGEXT $SIZEREQUIRED || exit $(ogRaiseError session $OG_ERR_DONTMOUNT_IMAGE "$3 $4 $IMGEXT: time_out."; echo $?)
# Sincronizamos los datos de la particion con la imagen.
-echo "[70] $MSG_HELP_ogSyncCreate." | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[70] $MSG_HELP_ogSyncCreate."
ogSyncCreate $1 $2 $3 "$4" $IMGEXT
TIMEAUX5=$[SECONDS-TIMEAUX3]
-echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX5/60]m $[TIMEAUX5%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX5/60]m $[TIMEAUX5%60]s"
-# Reducimos la imagen: solo para kernel <= 3.7, imagenes con FS ext4.
-echo "[80] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT" | tee -a $OGLOGSESSION $OGLOGFILE
+# Reducimos la imagen: solo para kernel <= 3.7, imagenes con FS ext4. (Desmonta y desbloquea la imagen)
+ogEcho log session "[80] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT"
ogReduceImage $3 "$4" $IMGEXT
-
-# Desmontamos la Imagen
-ogUnmountImage $3 "$4" $IMGEXT
-ogUnlockImage "$3" "/$4.$IMGEXT"
-ogUnlock $1 $2
+sleep 10
echo " " > $OGLOGCOMMAND
# Comprobamos que la imagen esta bien detectacdo que es un sistema de ficheros.
-echo "[95] $MSG_HELP_ogCheckSyncImage" | tee -a $OGLOGSESSION $OGLOGFILE
-ogCheckSyncImage $3 "$4" "img" || exit $(ogRaiseError $OG_ERR_IMAGE "$3 $4 img" ; echo $?)
+ogEcho log session "[95] $MSG_HELP_ogCheckSyncImage"
+ogCheckSyncImage $3 "$4" "img" || exit $(ogRaiseError session $OG_ERR_IMAGE "$3 $4 img" ; echo $?)
#resumen de la operacion
IMGSIZE=$(ls -l --block-size=1024 "$IMGFILE" | cut -f5 -d" ")
TIME=$[SECONDS-TIME1]
-echo "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
-echo " FileSystem $PART with $SIZEDATA KB data created onto file-image as $4 and used $IMGSIZE KB acros DFS rsync " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s"
+ogEcho log session " FileSystem $PART with $SIZEDATA KB data created onto file-image as $4 and used $IMGSIZE KB acros DFS rsync "
diff --git a/client/shared/scripts/createDiffImage b/client/shared/scripts/createDiffImage
index 70b2eb56..200d10a3 100755
--- a/client/shared/scripts/createDiffImage
+++ b/client/shared/scripts/createDiffImage
@@ -33,8 +33,13 @@ function onexit() {
ogUnmountImage $3 "$5" $DIFFTYPE &>/dev/null
ogUnmountImage $3 "$4" $IMGEXT &>/dev/null
if [ $exit_status -ne 4 ]; then
- ogUnlockImage "$3" "/$4.$IMGEXT" &>/dev/null
- ogUnlockImage "$3" "/$5.$DIFFEXT" &>/dev/null
+ if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
+ ogUnlockImage "$3" "/$4.$IMGEXT" &>/dev/null
+ ogUnlockImage "$3" "/$5.$DIFFEXT" &>/dev/null
+ else
+ hose $REPOIP 2009 --out sh -c "echo -ne UNLOCK_IMAGE \"$4.$IMGEXT\" "
+ hose $REPOIP 2009 --out sh -c "echo -ne UNLOCK_IMAGE \"$5.$DIFFEXT\" "
+ fi
ogUnlock $1 $2 &>/dev/null
fi
exit $exit_status
@@ -63,58 +68,61 @@ if [ "$*" == "help" ]; then
exit 0
fi
-[ $# -lt 5 ] && exit $(ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE base_image diff_image"; echo $?)
+[ $# -lt 5 ] && exit $(ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE base_image diff_image"; echo $?)
# Valores por defecto en etc/engine.cfg
IMGEXT="img"
DIFFEXT="img.diff"
DIFFTYPE="diff"
+REPOIP=$(ogGetRepoIp)
# Limpiamos los archivo de log
echo -n "" >$OGLOGCOMMAND
[ "$(ogGetCaller)" == "RestaurarSoftIncremental" ] || echo -n "" > $OGLOGSESSION
-echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*"
# Comprobamos si la imagen diferencial o la particion estan bloqueada:
-ogIsImageLocked "$3" "$5.$DIFFEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$3 $5.$DIFFEXT"; echo $?)
-ogIsLocked "$1" "$2" && exit $(ogRaiseError $OG_ERR_LOCKED "$1 $2"; echo $?)
+ogIsImageLocked "$3" "$5.$DIFFEXT" && exit $(ogRaiseError session $OG_ERR_LOCKED "$3 $5.$DIFFEXT"; echo $?)
+ogIsLocked "$1" "$2" && exit $(ogRaiseError session $OG_ERR_LOCKED "$1 $2"; echo $?)
# Comprobar si la imagen completa existe.
-IMGFILE="$(ogGetPath "$3" "$4.$IMGEXT")" || exit $(ogRaiseError $OG_ERR_NOTFOUND "$3 $4.$IMGEXT"; echo $?)
+IMGFILE="$(ogGetPath "$3" "$4.$IMGEXT")" || exit $(ogRaiseError session $OG_ERR_NOTFOUND "$3 $4.$IMGEXT"; echo $?)
# Comprobar que la imagen completa es sincronizable
-ogIsSyncImage "$3" "$4" "img" || exit $(ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"; echo $?)
+ogIsSyncImage "$3" "$4" "img" || exit $(ogRaiseError session $OG_ERR_DONTSYNC_IMAGE "$3 $4"; echo $?)
# Comprobar que no está bloqueada
-ogIsImageLocked "$3" "$4.$IMGEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$3 $4.$IMGEXT"; echo $?)
+ogIsImageLocked "$3" "$4.$IMGEXT" && exit $(ogRaiseError session $OG_ERR_LOCKED "$3 $4.$IMGEXT"; echo $?)
# Si el repositorio es CACHE comprobamos que exista
if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
- ! ogFindCache >/dev/null && exit $(ogRaiseError $OG_ERR_NOTCACHE "CACHE "; echo $?)
+ ! ogFindCache >/dev/null && exit $(ogRaiseError session $OG_ERR_NOTCACHE "CACHE "; echo $?)
fi
echo " " > $OGLOGCOMMAND
# Obtener información de los parámetros de entrada.
-PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $2"; echo $?)
+PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || exit $(ogRaiseError session $OG_ERR_PARTITION "$1 $2"; echo $?)
#Comprobamos que la partición se puede montar.
-ORIG=$(ogMount $1 $2) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $2"; echo $?)
+ORIG=$(ogMount $1 $2) || exit $(ogRaiseError session $OG_ERR_PARTITION "$1 $2"; echo $?)
-#Comprobamos acceso de escritura.
-DIRTEMP="/$4$(date +%Y%m%d-%H%M%S)"
-ogMakeDir $3 "$DIRTEMP" 2>/dev/null || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3" && ogDeleteTree $3 "$DIRTEMP" ; echo $?)
DIFFDIR="$(ogGetParentPath "$3" "/$5")"
DIFFFILE="$DIFFDIR/$5.$DIFFEXT"
-ogLockImage "$3" "/$4.$IMGEXT"
-ogLockImage "$3" "/$5.$DIFFEXT"
+if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
+ ogLockImage "$3" "/$4.$IMGEXT"
+ ogLockImage "$3" "/$5.$DIFFEXT"
+else
+ hose $REPOIP 2009 --out sh -c "echo -ne LOCK_IMAGE \"$4.$IMGEXT\" "
+ hose $REPOIP 2009 --out sh -c "echo -ne LOCK_IMAGE \"$5.$DIFFEXT\" "
+fi
# Comprobar consistencia del sistema de archivos.
echo " " > $OGLOGCOMMAND
SIZEFS=$(ogGetFsSize $1 $2)
-echo "[20] $MSG_HELP_ogCheckFs $1 $2 $SIZEFS (KB) " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[20] $MSG_HELP_ogCheckFs $1 $2 $SIZEFS (KB) "
ogUnmount $1 $2
-ogCheckFs $1 $2 >$OGLOGCOMMAND || exit $(ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2" ; echo $?)
+ogCheckFs $1 $2 >$OGLOGCOMMAND || exit $(ogRaiseError session $OG_ERR_PARTITION "ogCheckFs $1 $2" ; echo $?)
# Borramos ficheros de paginacion y configuracion
FSTYPE=$(ogGetFsType $1 $2)
@@ -133,23 +141,23 @@ esac
# Crear la imagen.
echo " " > $OGLOGCOMMAND
TIME2=$SECONDS
-echo "[40] $MSG_HELP_createDiffImage: $1 $2 $3 $4" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[40] $MSG_HELP_createDiffImage: $1 $2 $3 $4"
# Creamos la lista del contenido y lo situamos en la particion a copiar.
# Montamos imagen completa (con la que vamos a comparar)
ogMountImage $3 "$4" $IMGEXT >/dev/null
# Comprobar que la imagen completa se ha montado
-ogWaitMountImage $3 "$4" $IMGEXT || exit $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$3 $4 $IMGEXT: time_out."; echo $?)
+ogWaitMountImage $3 "$4" $IMGEXT || exit $(ogRaiseError session $OG_ERR_DONTMOUNT_IMAGE "$3 $4 $IMGEXT: time_out."; echo $?)
# Creamos la informacion de la imagen.
-echo "[50] $MSG_HELP_ogCreateInfoImage " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[50] $MSG_HELP_ogCreateInfoImage "
ogCreateInfoImage $1 $2 $3 "$4" "${DIFFTYPE}"
#Calculamos el tamaño de la imagen:
ogMount $1 $2 >/dev/null
ogLock $1 $2
-echo -n " $MSG_SCRIPTS_CREATE_SIZE" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session -n " $MSG_SCRIPTS_CREATE_SIZE"
cd $ORIG
SIZEDATA=$(grep -v "\/$" /tmp/ogimg.info | tr '\n' '\0'| du -x -c --files0-from=- 2>/dev/null|tail -n1 |cut -f1)
let SIZEREQUIRED=$SIZEDATA*$ZSYNC/100
@@ -159,18 +167,18 @@ let SIZEREQUIRED=$SIZEDATA*$ZSYNC/100
# Comprueba que quepa en el repositorio
[ "$3" == "CACHE" -o "$3" == "cache" ] && SIZEFREE=$(ogGetFreeSize `ogFindCache`) && ogMountCache >/dev/null
[ "$3" == "REPO" -o "$3" == "repo" ] && SIZEFREE=$(df -k | grep $OGIMG | awk '{print $4}')
-echo " $SIZEREQUIRED $SIZEFREE" | tee -a $OGLOGSESSION $OGLOGFILE
-[ $SIZEREQUIRED -gt $SIZEFREE ] && exit $(ogRaiseError $OG_ERR_CACHESIZE "$3"; echo $?)
+ogEcho log session " $SIZEREQUIRED $SIZEFREE"
+[ $SIZEREQUIRED -gt $SIZEFREE ] && exit $(ogRaiseError session $OG_ERR_CACHESIZE "$3"; echo $?)
TIMEAUX3=$[SECONDS-TIME2]
-echo " $MSG_SCRIPTS_TASK_END $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX3/60]m $[TIMEAUX3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " $MSG_SCRIPTS_TASK_END $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX3/60]m $[TIMEAUX3%60]s"
# Del fichero de acl de la partición extraemos las acl de los ficheros de la diferencial
if [ "$FSTYPE" == "NTFS" ]; then
- echo "[55] $MSG_HELP_ogAclFilter " | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[55] $MSG_HELP_ogAclFilter "
ogAclFilter
TIMEAUX4=$[SECONDS-TIMEAUX3]
- echo " $MSG_SCRIPTS_TASK_END $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX4/60]m $[TIMEAUX4%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " $MSG_SCRIPTS_TASK_END $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX4/60]m $[TIMEAUX4%60]s"
fi
TIMEAUX5=$[SECONDS-TIMEAUX3]
@@ -178,38 +186,30 @@ TIMEAUX5=$[SECONDS-TIMEAUX3]
sed -i s/SIZEDATA/"$SIZEDATA"/g /tmp/ogimg.info
# Creamos o redimensionamos la imagen
-echo "[60] $MSG_HELP_ogCreateFileImage." | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[60] $MSG_HELP_ogCreateFileImage."
ogCreateFileImage $3 "$5" $DIFFTYPE $SIZEREQUIRED
# Esperamos que se monte la imagen despues de crarla en el servidor
-ogWaitMountImage "$3" "$5" "$DIFFTYPE" $SIZEREQUIRED || exit $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$3 $5 $DIFFTYPE: time_out."; echo $?)
+ogWaitMountImage "$3" "$5" "$DIFFTYPE" $SIZEREQUIRED || exit $(ogRaiseError session $OG_ERR_DONTMOUNT_IMAGE "$3 $5 $DIFFTYPE: time_out."; echo $?)
-echo "[70] $MSG_HELP_ogSyncCreate" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[70] $MSG_HELP_ogSyncCreate"
# Copio los datos a la imagen diferecial :
ogSyncCreate $1 $2 $3 "$5" $DIFFTYPE
TIMEAUX6=$[SECONDS-TIMEAUX5]
-echo -e " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX6/60]m $[TIMEAUX6%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session -e " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX6/60]m $[TIMEAUX6%60]s"
# Reducimos la imagen diferencial -> solo para kernel <= 3.7, imagenes con FS ext4
-echo "[80] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[80] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT"
ogReduceImage $3 "$5" $DIFFTYPE
-
-# Desmontamos las imagenes
-ogUnmountImage $3 "$5" $DIFFTYPE
-ogUnmountImage $3 "$4" $IMGEXT
-
-# Desbloqueo las imagenes y la particion.
-ogUnlockImage "$3" "/$4.$IMGEXT"
-ogUnlockImage "$3" "/$5.$DIFFEXT"
-ogUnlock $1 $2
+sleep 10
echo " " > $OGLOGCOMMAND
# Comprobamos que la imagen esta bien
-echo "[95] $MSG_HELP_ogCheckSyncImage" | tee -a $OGLOGSESSION $OGLOGFILE
-ogCheckSyncImage $3 "$5" diff || exit $(ogRaiseError $OG_ERR_IMAGE "$3 $5 diff"; echo $?)
+ogEcho log session "[95] $MSG_HELP_ogCheckSyncImage"
+ogCheckSyncImage $3 "$5" diff || exit $(ogRaiseError session $OG_ERR_IMAGE "$3 $5 diff"; echo $?)
#resumen de la operacion
IMGSIZE=$(ls -l --block-size=1024 "${DIFFFILE}"| cut -f5 -d" ")
TIME=$[SECONDS-TIME1]
-echo "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
-echo " FileSystem $PART with $SIZEDATA KB data created onto file-image as $5 and used $IMGSIZE KB acros DFS rsync " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s"
+ogEcho log session " FileSystem $PART with $SIZEDATA KB data created onto file-image as $5 and used $IMGSIZE KB acros DFS rsync "
diff --git a/client/shared/scripts/restoreBaseImage b/client/shared/scripts/restoreBaseImage
index 3baac9c1..29ec3df4 100755
--- a/client/shared/scripts/restoreBaseImage
+++ b/client/shared/scripts/restoreBaseImage
@@ -39,7 +39,7 @@ echo -n "" >$OGLOGCOMMAND;
[ "$(ogGetCaller)" == "RestaurarImagenBasica" -o "$(ogGetCaller)" == "restoreDiffImage" ] || echo -n "" > $OGLOGSESSION
# Mensaje de inicio de script salvo si es llamado desde restoreDiffImage.
-[ "$(ogGetCaller)" == "restoreDiffImage" ] || echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGFILE $OGLOGSESSION
+[ "$(ogGetCaller)" == "restoreDiffImage" ] || ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*"
TIME1=$SECONDS
PROG="$(basename $0)"
@@ -52,90 +52,95 @@ if [ "$*" == "help" ]; then
exit 0
fi
-[ $# -lt 4 ] && exit $(ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"; echo $?)
+[ $# -lt 4 ] && exit $(ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"; echo $?)
# Carga del configurador del engine
[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
# Procesar parámetros de entrada
-REPOFILE="$(ogGetPath "REPO" "$2.$IMGEXT")" || exit $(ogRaiseError $OG_ERR_NOTFOUND "REPO, $2.$IMGEXT"; echo $?)
+REPOFILE="$(ogGetPath "REPO" "$2.$IMGEXT")" || exit $(ogRaiseError session $OG_ERR_NOTFOUND "REPO, $2.$IMGEXT"; echo $?)
# Comprobar que es sincronizable (con REPO)
-ogIsSyncImage REPO "$2" $IMGEXT || exit $(ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $2"; echo $?)
+ogIsSyncImage REPO "$2" $IMGEXT || exit $(ogRaiseError session $OG_ERR_DONTSYNC_IMAGE "$1 $2"; echo $?)
+
+# Detectamos el sistema de ficheros de la imagen
+# TODO ogGetImageInfo
+DIRMOUNT=$(ogMountImage "$1" "$2")
+ogWaitMountImage "$1" "$2" "$IMGEXT" || exit $(ogRaiseError session $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $IMGEXT: time_out."; echo $?)
+IMGFSTYPE=$(head -1 $DIRMOUNT/ogimg.info |cut -d: -f3)
# Comprobamos si el sistema de ficheros se puede montar
ogMount "$3" "$4" &>/dev/null || RETVAL=$?
# Si da error formateamos el sistema de ficheros.
if [ "$RETVAL" ] ; then
- # TODO ogGetImageInfo
- DIRMOUNT=$(ogMountImage "$1" "$2")
- ogWaitMountImage "$1" "$2" "$IMGEXT" || exit $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $IMGEXT: time_out."; echo $?)
- FSTYPE=$(head -1 $DIRMOUNT/ogimg.info |cut -d: -f3)
ogUnmountImage $1 "$2"
- echo " $MSG_HELP_ogFormat: $3 $4 $FSTYPE" | tee -a $OGLOGFILE
- ogFormat "$3" "$4" "$FSTYPE" || exit $(ogRaiseError $OG_ERR_FILESYS "$3 $4"; echo $?)
- ogMount "$3" "$4" || exit $(ogRaiseError $OG_ERR_FILESYS "$3 $4"; echo $?)
+ ogEcho log session " $MSG_HELP_ogFormat: $3 $4 $IMGFSTYPE"
+ ogFormat "$3" "$4" "$IMGFSTYPE" || exit $(ogRaiseError session $OG_ERR_FILESYS "$3 $4"; echo $?)
+ ogMount "$3" "$4" || exit $(ogRaiseError session $OG_ERR_FILESYS "$3 $4"; echo $?)
fi
+# Warning si el sistema de ficheros de la imagen es distinto del de la particion destino
+[ "$IMGFSTYPE" == "$(ogGetFsType $3 $4)" ] || ogEcho session warning "$MSG_SYNC_DIFFERENTFS"
+
IMGEXT="img"
# Comprobamos si la imagen o la particion estan bloqueada:
-ogIsImageLocked "$1" "$2.$IMGEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$1 $2.$IMGEXT"; echo $?)
-ogIsLocked "$3" "$4" && exit $(ogRaiseError $OG_ERR_LOCKED "$3 $4"; echo $?)
+ogIsImageLocked "$1" "$2.$IMGEXT" && exit $(ogRaiseError session $OG_ERR_LOCKED "$1 $2.$IMGEXT"; echo $?)
+ogIsLocked "$3" "$4" && exit $(ogRaiseError session $OG_ERR_LOCKED "$3 $4"; echo $?)
PROTO=${5:-"UNICAST"}
if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
# Las imagenes sincronizables aunque sean iguales no tienen el mismo sum.
# 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 $OGLOGSESSION
- echo " updateCache REPO" "/$2.$IMGEXT" "$PROTO" "$6" | tee -a $OGLOGFILE $OGLOGSESSION
+ ogEcho log session "[10] $MSG_SCRIPTS_TASK_START updateCache REPO $2.$IMGEXT $PROTO $6"
+ ogEcho log session " updateCache REPO" "/$2.$IMGEXT" "$PROTO" "$6"
updateCache REPO "/$2.$IMGEXT" "$PROTO" "$6"
RETVAL=$?
if [ "$RETVAL" != "0" ]
then
- echo "[39] $MSG_SCRIPTS_TASK_END updateCache REPO $2.$IMGEXT $5 $6 con error $RETVAL" | tee -a $OGLOGFILE $OGLOGSESSION
+ ogEcho log session "[39] $MSG_SCRIPTS_TASK_END updateCache REPO $2.$IMGEXT $5 $6 con error $RETVAL"
# RC=15 No hay cache
# RC=16 no hay espacio sufiente
exit $RETVAL
fi
TIMEAUX1=$[SECONDS-TIME]
- echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX1/60]m $[TIMEAUX1%60]s" | tee -a $OGLOGFILE
+ ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX1/60]m $[TIMEAUX1%60]s"
fi
TIME2=$SECONDS
# Restaurar la imagen.
-echo "[40] $MSG_HELP_ogRestoreImage: $1 $2 $3 $4" | tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[40] $MSG_HELP_ogRestoreImage: $1 $2 $3 $4"
ogLock $3 $4
# Montamos la imagen basica.
ogMountImage "$1" "$2" "$IMGEXT" >/dev/null
# Comprobar que la imagen completa se ha montado.
-ogWaitMountImage "$1" "$2" "$IMGEXT" || exit $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $IMGEXT: time_out."; echo $?)
+ogWaitMountImage "$1" "$2" "$IMGEXT" || exit $(ogRaiseError session $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $IMGEXT: time_out."; echo $?)
# Sincronizamos la partición con la imagen.
-echo "[60] $MSG_HELP_ogSyncRestore: $1 $2 $IMGEXT $3 $4" |tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[60] $MSG_HELP_ogSyncRestore: $1 $2 $IMGEXT $3 $4"
ogSyncRestore "$1" "$2" "$IMGEXT" $3 $4
TIMEAUX2=$[SECONDS-TIME2]
-echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX2/60]m $[TIMEAUX2%60]s" | tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX2/60]m $[TIMEAUX2%60]s"
# Desmontamos imagen basica.
ogUnmountImage "$1" "$2" "$IMGEXT"
# Restableciendo acl
ogUnlock $3 $4
-echo "[70] $MSG_HELP_ogRestoreInfoImage" |tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[70] $MSG_HELP_ogRestoreInfoImage"
ogRestoreInfoImage $3 $4
# Llamar al script de post-configuración del sistema operativo.
# Si a este script lo ha llamado el script restoreDiffImage no post-configuramos
if [ "$(ogGetCaller)" != "restoreDiffImage" ];then
- echo "[90] $MSG_HELP_configureOs" |tee -a $OGLOGFILE $OGLOGSESSION
+ ogEcho log session "[90] $MSG_HELP_configureOs"
configureOs $3 $4
fi
TIME=$[SECONDS-TIME1]
-echo "[100] $MSG_SCRIPTS_END $MSG_SCRIPTS_TIME_TOTAL: $[TIME/60]m $[TIME%60]s" |tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[100] $MSG_SCRIPTS_END $MSG_SCRIPTS_TIME_TOTAL: $[TIME/60]m $[TIME%60]s"
diff --git a/client/shared/scripts/restoreDiffImage b/client/shared/scripts/restoreDiffImage
index 157fe9a5..54edc045 100755
--- a/client/shared/scripts/restoreDiffImage
+++ b/client/shared/scripts/restoreDiffImage
@@ -52,26 +52,26 @@ if [ "$*" == "help" ]; then
exit 0
fi
-[ $# -lt 5 ] && exit $(ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE base_image diff_imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"; echo $?)
+[ $# -lt 5 ] && exit $(ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE base_image diff_imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"; echo $?)
-echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*"
# Procesar parámetros de entrada
DIFFTYPE="diff"
DIFFEXT="img.diff"
-REPODIFFFILE="$(ogGetPath "REPO" "$3.$DIFFEXT")" || exit $(ogRaiseError $OG_ERR_NOTFOUND "REPO $3.$DIFFEXT";echo $?)
+REPODIFFFILE="$(ogGetPath "REPO" "$3.$DIFFEXT")" || exit $(ogRaiseError session $OG_ERR_NOTFOUND "REPO $3.$DIFFEXT";echo $?)
# Comprobamos si la imagen o la particion estan bloqueada:
-ogIsImageLocked "$1" "$3.$DIFFEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$1 $3.$DIFFEXT";echo $?)
-ogIsLocked "$4" "$5" && exit $(ogRaiseError $OG_ERR_LOCKED "$4 $5";echo $?)
+ogIsImageLocked "$1" "$3.$DIFFEXT" && exit $(ogRaiseError session $OG_ERR_LOCKED "$1 $3.$DIFFEXT";echo $?)
+ogIsLocked "$4" "$5" && exit $(ogRaiseError session $OG_ERR_LOCKED "$4 $5";echo $?)
-PART=$(ogDiskToDev "$4" "$5" 2>/dev/null ) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $3";echo $?)
+PART=$(ogDiskToDev "$4" "$5" 2>/dev/null ) || exit $(ogRaiseError session $OG_ERR_PARTITION "$1 $3";echo $?)
# Carga del configurador del engine
[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
# Comprobar que es sincronizable
-ogIsSyncImage REPO "$3" diff || exit $(ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $3";echo $?)
+ogIsSyncImage REPO "$3" diff || exit $(ogRaiseError session $OG_ERR_DONTSYNC_IMAGE "$1 $3";echo $?)
# Restauramos la imagen Basica.
restoreBaseImage $1 "$2" "$4" "$5" "$6" "$7"
@@ -79,35 +79,35 @@ restoreBaseImage $1 "$2" "$4" "$5" "$6" "$7"
PROTO=${6:-"UNICAST"}
if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
- echo "[10] $MSG_HELP_updateCache." | tee -a $OGLOGFILE $OGLOGSESSION
- echo " updateCache REPO" "/$3.$DIFFEXT" "$PROTO" "$7" | tee -a $OGLOGFILE $OGLOGSESSION
+ ogEcho log session "[10] $MSG_HELP_updateCache."
+ ogEcho log session " updateCache REPO" "/$3.$DIFFEXT" "$PROTO" "$7"
updateCache REPO "/$3.$DIFFEXT" "$PROTO" "$7"
RETVAL=$?
if [ "$RETVAL" != "0" ]
then
- echo "[39] $MSG_SCRIPTS_TASK_END updateCache REPO $3.$DIFFEXT $6 $7 con error $RETVAL" | tee -a $OGLOGFILE
+ ogEcho log session "[39] $MSG_SCRIPTS_TASK_END updateCache REPO $3.$DIFFEXT $6 $7 con error $RETVAL"
# RC=15 No hay cache
# RC=16 no hay espacio sufiente
exit $RETVAL
fi
TIMEAUX1=$[SECONDS-TIME]
- echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX1/60]m $[TIMEAUX1%60]s" | tee -a $OGLOGFILE $OGLOGSESSION
+ ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX1/60]m $[TIMEAUX1%60]s"
fi
TIME2=$SECONDS
# Restaurar la imagen.
-echo "[40] $MSG_RESTORE $PART" | tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[40] $MSG_RESTORE $PART"
# Montamos la diferencial
ogMountImage "$1" "$3" "$DIFFTYPE" &>/dev/null
# Comprobar que la imagen diferencial se ha montado
-ogWaitMountImage "$1" "$3" "$DIFFTYPE" || exit $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $3 $DIFFTYPE: time_out $TIMEAUX seg.";echo $?)
+ogWaitMountImage "$1" "$3" "$DIFFTYPE" || exit $(ogRaiseError session $OG_ERR_DONTMOUNT_IMAGE "$1 $3 $DIFFTYPE: time_out $TIMEAUX seg.";echo $?)
ogMount $4 $5 >/dev/null
ogLock $4 $5
# Sincronizamos la partición con la imagen.
-echo "[60] $MSG_HELP_ogSyncRestore: $1 $3 $DIFFTYPE $4 $5" |tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[60] $MSG_HELP_ogSyncRestore: $1 $3 $DIFFTYPE $4 $5"
ogSyncRestore "$1" "$3" "$DIFFTYPE" $4 $5
# Desmontamos la imagen
@@ -115,16 +115,16 @@ ogUnmountImage "$1" "$3" "$DIFFTYPE"
ogUnlock $4 $5
TIMEAUX2=$[SECONDS-TIME2]
-echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX2/60]m $[TIMEAUX2%60]s" | tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX2/60]m $[TIMEAUX2%60]s"
# creando enlaces y restableciendo ACL (en windows)
-echo "[70] $MSG_HELP_ogRestoreInfoImage" |tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[70] $MSG_HELP_ogRestoreInfoImage"
ogRestoreInfoImage "$4" "$5" &>$OGLOGCOMMAND
# Llamar al script de post-configuración del sistema operativo.
-echo "[90] $MSG_HELP_configureOs." | tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[90] $MSG_HELP_configureOs."
configureOs $4 $5
TIME=$[SECONDS-TIME1]
-echo "[100] $MSG_SCRIPTS_END $MSG_SCRIPTS_TIME_TOTAL: $[TIME/60]m $[TIME%60]s" |tee -a $OGLOGFILE $OGLOGSESSION
+ogEcho log session "[100] $MSG_SCRIPTS_END $MSG_SCRIPTS_TIME_TOTAL: $[TIME/60]m $[TIME%60]s"