summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoririna <irinagomez@us.es>2014-03-04 13:07:35 +0000
committeririna <irinagomez@us.es>2014-03-04 13:07:35 +0000
commit30ad471609a53482410d51b66f0c9f764c2e944a (patch)
treefdd9c2b594b417e399b86d509c874ed2f0608789
parent46f7d6f1ff72d67b3aa2963400353678790b18ef (diff)
#565 #636 revisión mensajes de error en las sincronizadas.
git-svn-id: https://opengnsys.es/svn/branches/version1.0@4173 a21b9725-9963-47de-94b9-378ad31fedc9
-rwxr-xr-xadmin/Interface/CrearImagenBasica9
-rwxr-xr-xadmin/Interface/CrearSoftIncremental7
-rwxr-xr-xadmin/Interface/RestaurarImagenBasica10
-rwxr-xr-xadmin/Interface/RestaurarSoftIncremental7
-rwxr-xr-xclient/engine/Rsync.lib31
-rwxr-xr-xclient/shared/lib/httpd/LogCommand.sh6
-rwxr-xr-xclient/shared/scripts/createBaseImage30
-rwxr-xr-xclient/shared/scripts/createDiffImage37
-rwxr-xr-xclient/shared/scripts/deployImage21
-rwxr-xr-xclient/shared/scripts/restoreBaseImage34
-rwxr-xr-xclient/shared/scripts/restoreDiffImage28
-rwxr-xr-xclient/shared/scripts/restoreImage11
-rwxr-xr-xclient/shared/scripts/updateCache39
13 files changed, 139 insertions, 131 deletions
diff --git a/admin/Interface/CrearImagenBasica b/admin/Interface/CrearImagenBasica
index 7efc69e2..20607f9b 100755
--- a/admin/Interface/CrearImagenBasica
+++ b/admin/Interface/CrearImagenBasica
@@ -63,6 +63,7 @@
if [ $7 -eq 1 ]; then
#sincronizacion1
ogCrearImagenBasica "$@"
+ RETVAL=$?
fi
@@ -83,8 +84,16 @@
[ "$4" == "0.0.0.0" ] && DEST="CACHE" || DEST="REPO"
createBaseImage $1 $2 $DEST "$3"
+ RETVAL=$?
fi
[ "$REPO" == "REPO" -a "$boot" != "admin" ] && CambiarAcceso user
+ # Registro de fin de ejecución
+ echo "$MSG_INTERFACE_END $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+
+
+
+ exit $RETVAL
+
diff --git a/admin/Interface/CrearSoftIncremental b/admin/Interface/CrearSoftIncremental
index ccf8d70f..69ee9801 100755
--- a/admin/Interface/CrearSoftIncremental
+++ b/admin/Interface/CrearSoftIncremental
@@ -62,6 +62,7 @@
if [ $8 -eq 1 ]; then
#sincronizacion1
ogCrearSoftIncremental "$@"
+ RETVAL=$?
fi
@@ -82,7 +83,13 @@
CLIENTIP=$(ogGetIpAddress)
[ "$4" == "$CLIENTIP" ] && DEST=CACHE || DEST=REPO
createDiffImage $1 $2 $DEST "$3" "$5"
+ RETVAL=$?
fi
[ "$REPO" == "REPO" -a "$boot" != "admin" ] && CambiarAcceso user
+
+ # Registro de fin de ejecución
+ echo "$MSG_INTERFACE_END $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+
+ exit $RETVAL
diff --git a/admin/Interface/RestaurarImagenBasica b/admin/Interface/RestaurarImagenBasica
index be088cc5..73ddb0e2 100755
--- a/admin/Interface/RestaurarImagenBasica
+++ b/admin/Interface/RestaurarImagenBasica
@@ -47,7 +47,7 @@
# Clear temporary file used as log track by httpdlog
# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
- echo " " > $OGLOGSESSION; echo " " > $OGLOGCOMMAND
+ echo -n "" > $OGLOGSESSION; echo " " > $OGLOGCOMMAND
# Registro de inicio de ejecución
echo "$MSG_INTERFACE_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
@@ -55,6 +55,7 @@
if [ $9 -eq 1 ]; then
#sincronizacion1
ogRestaurarImagenBasica "$@"
+ RETVAL=$?
fi
if [ $9 -eq 2 ]; then
@@ -79,5 +80,10 @@
OPT=${5#*_}
restoreBaseImage $DEST "$3" $1 $2 $PROTO $OPT
-
+ RETVAL=$?
fi
+
+ # Registro de fin de ejecución
+ echo "$MSG_INTERFACE_END $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+
+ exit $RETVAL
diff --git a/admin/Interface/RestaurarSoftIncremental b/admin/Interface/RestaurarSoftIncremental
index f889547b..2774dabc 100755
--- a/admin/Interface/RestaurarSoftIncremental
+++ b/admin/Interface/RestaurarSoftIncremental
@@ -48,6 +48,7 @@
if [ ${10} -eq 1 ]; then
#sincronizacion1
ogRestaurarSoftIncremental "$@"
+ RETVAL=$?
fi
if [ ${10} -eq 2 ]; then
@@ -72,6 +73,10 @@
OPT=${6#*_}
restoreDiffImage $DEST "$3" "$5" $1 $2 $PROTO $OPT
-
+ RETVAL=$?
fi
+ # Registro de fin de ejecución
+ echo "$MSG_INTERFACE_END $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+
+ exit $RETVAL
diff --git a/client/engine/Rsync.lib b/client/engine/Rsync.lib
index b38dc4e1..375f0462 100755
--- a/client/engine/Rsync.lib
+++ b/client/engine/Rsync.lib
@@ -94,7 +94,7 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
fi
# Monto la imagen
ogMountImage $1 "$2" $3 &>/dev/null
- [ $? -eq 0 ] || ogRaiseError $OG_ERR_IMAGE "$3 $4"
+ [ $? -eq 0 ] || return $( ogRaiseError $OG_ERR_IMAGE "$3 $4"; echo $?)
touch "$DIRMOUNT/ogimg.info"
# Si existe dispositivo de loop lo borro.
@@ -138,7 +138,7 @@ if [ $3 == "img" ]; then
IMGTYPE="img"
else
# Comprobamos que las extension sea valida
- ogCheckStringInGroup $5 "img diff" || ogRaiseError $OG_ERR_FORMAT $MSG_SYNC_EXTENSION
+ ogCheckStringInGroup $5 "img diff" || return $( ogRaiseError $OG_ERR_FORMAT "$MSG_SYNC_EXTENSION"; echo $?)
IMGTYPE=$5
if [ "$IMGTYPE" == "diff" ]; then
# Imagen completa con la que comparo la particion.
@@ -206,8 +206,8 @@ else
# Comprobamos que los ficheros de diferencias no esten vacios o salimos con error.
if [ $(grep -v -e "^$" -e "^#" $IMGINFO /tmp/ogimg.ln /tmp/ogimg.rm |wc -l) -eq 0 ]; then
- ogRaiseError $OG_ERR_NOTDIFERENT "$1 $2 $3 $4 $5" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- return ${PIPESTATUS[0]}
+ ogRaiseError $OG_ERR_NOTDIFFERENT "$1 $2 $3 $4 $5"
+ return $0
fi
fi
@@ -232,15 +232,24 @@ fi
function ogAclFilter () {
local IMGACL IMGINFO FILES ACLTMP
+# Ayuda o menos de 5 parametros y la imagen no es basica
+if [ "$*" == "help" ]; then
+ ogHelp "$MSG_HELP_ogAclFilter" \
+ "$FUNCNAME [ no parameters ] "
+ return
+fi
+
IMGACL="/tmp/ogimg.acl"
IMGINFO="/tmp/ogimg.info"
FILES="/tmp/files$$"
ACLTMP="/tmp/acl$$.tmp"
+ACLFILES="/tmp/aclfiles$$"
# comprobamos que existan los archivos de origen. Si no salimos sin error.
[ -f $IMGACL -a -f $IMGINFO ] || return 0
echo "" > $ACLTMP
+grep -n -e "File" -e "Directory" $IMGACL > $ACLFILES
# Al fichero le quitamos las líneas sobrantes: comentarios y lineas vacias.
sed -e s/"^#.*$"//g $IMGINFO > $FILES
@@ -249,13 +258,17 @@ sed -i '/^$/d' $FILES
# Recorremos el listado y extraemos la acl correspondiente al fichero o directorio.
while read LINE; do
- read END INI <<< "$(grep -n -e "File" -e "Directory" $IMGACL| grep -A 1 "$LINE"| awk -F : '!(NR%2){print $1" "p}{p=$1}' )"
+ #read END INI <<< "$(grep -n -e "File" -e "Directory" $IMGACL| grep -A 1 "$LINE"| awk -F : '!(NR%2){print $1" "p}{p=$1}' )"
+ read END INI <<< "$(grep -A 1 "$LINE" $ACLFILES | awk -F : '!(NR%2){print $1" "p}{p=$1}' )"
let NUM=$END-$INI-1
# Si algún archivo no se encuentra, el error lo mandamos a /dev/null
- sed -n -e $INI,+"$NUM"p $IMGACL 2>/dev/null | tee -a $ACLTMP
+ #sed -n -e $INI,+"$NUM"p $IMGACL 2>/dev/null | tee -a $ACLTMP
+ sed -n -e $INI,+"$NUM"p $IMGACL 2>/dev/null >> $ACLTMP
+ echo "aclfilter: $LINE" >> $OGLOGCOMMAND
done < $FILES
cp $ACLTMP $IMGACL
+rm $FILES $ACLTMP $ACLFILES
}
@@ -382,7 +395,7 @@ else
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
-rsync -aHAX$OPTRSYNC $PASSWORD --progress --inplace --delete $FILESFROM "$ORIG/" "$DESTRSYNC" 2>&1| egrep "^sent|^sending|^total|%" >> $OGLOGCOMMAND
+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
rsync -aHAX$OPTRSYNC $PASSWORD --inplace /tmp/ogimg* "$DESTRSYNC"
@@ -464,7 +477,7 @@ if [ "$3" == "diff" ]; then
fi
echo " rsync -aHAX$OPTRSYNC --progress $FILESFROM $ORIG/ $DESTRSYNC" | tee -a $OGLOGSESSION $OGLOGFILE
-rsync -aHAX$OPTRSYNC $PASSWORD --progress $FILESFROM "$ORIG/" "$DESTRSYNC" 2>&1 | egrep "^sent|^sending|^total|%" >> $OGLOGCOMMAND
+rsync -aHAX$OPTRSYNC $PASSWORD --progress $FILESFROM "$ORIG/" "$DESTRSYNC" 2>&1 | egrep "^deleting|^sent|^sending|^total|%" &>> $OGLOGCOMMAND
}
@@ -513,7 +526,7 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
fi
# Comprobamos que se ha montado bien
- [ $? -eq 0 ] || ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $3" || return $?
+ [ $? -eq 0 ] || return $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $3"; echo $?)
echo "/tmp/$DIRMOUNT"
else
diff --git a/client/shared/lib/httpd/LogCommand.sh b/client/shared/lib/httpd/LogCommand.sh
index 0fc65413..09656fc1 100755
--- a/client/shared/lib/httpd/LogCommand.sh
+++ b/client/shared/lib/httpd/LogCommand.sh
@@ -8,7 +8,7 @@ echo "<meta charset='utf-8'>"
echo "<meta http-equiv='Refresh' content='5,URL=./LogCommand.sh'> <link rel='stylesheet' type='text/css' href='oglive.css' />"
echo "<title>Bash as CGI</title></head><body>"
-$(strings -e S $OGLOGCOMMAND > $OGLOGCOMMANDTMP)
+strings -e S $OGLOGCOMMAND > $OGLOGCOMMANDTMP
echo "<table>"
@@ -18,7 +18,7 @@ echo "<tr>"
echo "<TEXTAREA NAME='trackloghead' ROWS='13' COLS='175'>"
#echo "$(head -n 10 /tmp/command.log.tmp | uniq)"
# UHU - 2013/07/05 - Se incluye el simbolo % y la palabra sent para que se muestre la salida de rsync
-echo "$(egrep -v '^bytes|%|sent|^Elapsed:|^Total [Tt]ime:|^-|^\\|^\/' $OGLOGCOMMANDTMP | uniq | head -n 15)"
+egrep -v '^aclfilter|^deleting|^bytes|%|sent|^Elapsed:|^Total [Tt]ime:|^-|^\\|^\/' $OGLOGCOMMANDTMP | uniq | head -n 15
echo "</TEXTAREA>"
echo "</tr>"
@@ -29,7 +29,7 @@ echo "<tr>"
echo "<TEXTAREA NAME='tracklogtail' ROWS='2' COLS='175'>"
#echo "$(tail -n 5 /tmp/command.log.tmp | uniq)"
# UHU - 2013/07/05 - Se incluye el simbolo % y la palabra sent para que se muestre la salida de rsync
-echo "$(egrep '^bytes|%|sent|^Elapsed:|^Total [Tt]ime:|^-|^\\|^\/' $OGLOGCOMMANDTMP | uniq | tail -n 2)"
+egrep '^aclfilter|^deleting|^bytes|%|sent|^Elapsed:|^Total [Tt]ime:|^-|^\\|^\/' $OGLOGCOMMANDTMP | uniq | tail -n 2
echo "</TEXTAREA>"
diff --git a/client/shared/scripts/createBaseImage b/client/shared/scripts/createBaseImage
index 50e41952..a0499c56 100755
--- a/client/shared/scripts/createBaseImage
+++ b/client/shared/scripts/createBaseImage
@@ -24,12 +24,11 @@
#@date 2012-12-04
#*/ ##
-trap "onexit $1 $2 $3 \"$4\"" 1 2 3 6 9 14 15 ERR
+trap "onexit $1 $2 $3 \"$4\"" 1 2 3 6 9 14 15 EXIT
# Si salimos con error demontamos la imagen y desbloqueamos la imagen y la particion
function onexit() {
local exit_status=$?
- echo -e "\n $PROG error ${MSG_INTERFACE_END#*\]} $exit_status" |tee -a $OGLOGFILE $OGLOGSESSION
ogUnmountImage $3 "$4" $IMGEXT &>/dev/null
if [ $exit_status -ne 4 ]; then
ogUnlockImage "$3" "/$4.$IMGEXT"
@@ -62,8 +61,7 @@ if [ "$*" == "help" ]; then
exit 0
fi
-[ $# -ne 4 ] && ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen"
-
+[ $# -ne 4 ] && exit $(ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen" ; echo $?)
# Limpiamos fichero de log
echo " " > $OGLOGCOMMAND
@@ -77,30 +75,29 @@ REPOIP=$(ogGetRepoIp)
# Comprobamos si la imagen o la particion estan bloqueada:
-ogIsImageLocked "$3" "$4.$IMGEXT" && ogRaiseError $OG_ERR_LOCKED "$3 $4.$IMGEXT"
-ogIsLocked "$1" "$2" && ogRaiseError $OG_ERR_LOCKED "$1 $2"
+ogIsImageLocked "$3" "$4.$IMGEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$3 $4.$IMGEXT"; echo $?)
+ogIsLocked "$1" "$2" && exit $(ogRaiseError $OG_ERR_LOCKED "$1 $2"; echo $?)
# Si el repositorio es CACHE comprobamos que exista
if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
- ! ogFindCache >/dev/null && ogRaiseError $OG_ERR_NOTCACHE "CACHE "
+ ! ogFindCache >/dev/null && exit $(ogRaiseError $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 || ogRaiseError $OG_ERR_NOTWRITE "$3" && ogDeleteTree $3 "$DIRTEMP"
+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) || ogRaiseError $OG_ERR_PARTITION "$1 $2"
+PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || exit $(ogRaiseError $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
ogUnmount $1 $2
-ogCheckFs $1 $2 &> $OGLOGCOMMAND || ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2"
+ogCheckFs $1 $2 &> $OGLOGCOMMAND || exit $(ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2"; echo $?)
# Comprobamos que la particion se puede montar
-ORIG=$(ogMount $1 $2) || ogRaiseError $OG_ERR_PARTITION "$1 $2"
-
+ORIG=$(ogMount $1 $2) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $2" ; echo $?)
# Borramos ficheros de paginacion y configuracion
case "$(ogGetFsType $1 $2)" in
@@ -115,7 +112,6 @@ case "$(ogGetFsType $1 $2)" in
;;
esac
-
#Comprobar espacio que requerira la imagen para ser almacenada
SIZEDATA=$(df -k | grep $PART | awk '{print $3}')
#Aplicar factor de compresion
@@ -126,12 +122,10 @@ let SIZEREQUIRED=$SIZEDATA*$ZSYNC/100
[ "$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 ] && ogRaiseError $OG_ERR_CACHESIZE "$3"
-
+[ $SIZEREQUIRED -gt $SIZEFREE ] && exit $(ogRaiseError $OG_ERR_CACHESIZE "$3"; echo $?)
IMGDIR="$(ogGetParentPath "$3" "/$4")"
IMGFILE=${IMGDIR[$3]}/$(basename "/$4").$IMGEXT
-
# Crear la imagen.
echo " " > $OGLOGCOMMAND
TIME2=$SECONDS
@@ -172,9 +166,7 @@ ogUnlock $1 $2
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"
-[ $? -eq 0 ] || ogRaiseError $OG_ERR_IMAGE "$3 $4 img"
-
+ogCheckSyncImage $3 "$4" "img" || exit $(ogRaiseError $OG_ERR_IMAGE "$3 $4 img" ; echo $?)
#resumen de la operacion
IMGSIZE=$(ls -l --block-size=1024 "$IMGFILE" | cut -f5 -d" ")
diff --git a/client/shared/scripts/createDiffImage b/client/shared/scripts/createDiffImage
index 08276383..70b2eb56 100755
--- a/client/shared/scripts/createDiffImage
+++ b/client/shared/scripts/createDiffImage
@@ -26,11 +26,10 @@
#@author
#@date 2012-12-04
#*/ ##
-trap "onexit $1 $2 $3 \"$4\" \"$5\"" 1 2 3 6 9 14 15 ERR
+trap "onexit $1 $2 $3 \"$4\" \"$5\"" 1 2 3 6 9 14 15 EXIT
function onexit() {
local exit_status=$?
- echo -e "\n $PROG error: ${MSG_INTERFACE_END#*\]} $exit_status" |tee -a $OGLOGFILE $OGLOGSESSION
ogUnmountImage $3 "$5" $DIFFTYPE &>/dev/null
ogUnmountImage $3 "$4" $IMGEXT &>/dev/null
if [ $exit_status -ne 4 ]; then
@@ -53,7 +52,6 @@ ZSYNC=${ZSYNC:-"120"}
# Si IMGFS="BTRFS" la compresion es mayor.
[ $IMGFS == "BTRFS" ] && let ZSYNC=$ZSYNC-30
-
TIME1=$SECONDS
PROG="$(basename $0)"
@@ -65,7 +63,7 @@ if [ "$*" == "help" ]; then
exit 0
fi
-[ $# -lt 5 ] && ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE base_image diff_image"
+[ $# -lt 5 ] && exit $(ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE base_image diff_image"; echo $?)
# Valores por defecto en etc/engine.cfg
IMGEXT="img"
@@ -79,32 +77,32 @@ echo -n "" >$OGLOGCOMMAND
echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
# Comprobamos si la imagen diferencial o la particion estan bloqueada:
-ogIsImageLocked "$3" "$5.$DIFFEXT" && ogRaiseError $OG_ERR_LOCKED "$3 $5.$DIFFEXT"
-ogIsLocked "$1" "$2" && ogRaiseError $OG_ERR_LOCKED "$1 $2"
+ogIsImageLocked "$3" "$5.$DIFFEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$3 $5.$DIFFEXT"; echo $?)
+ogIsLocked "$1" "$2" && exit $(ogRaiseError $OG_ERR_LOCKED "$1 $2"; echo $?)
# Comprobar si la imagen completa existe.
-IMGFILE="$(ogGetPath "$3" "$4.$IMGEXT")" || ogRaiseError $OG_ERR_NOTFOUND "$3 $4.$IMGEXT"
+IMGFILE="$(ogGetPath "$3" "$4.$IMGEXT")" || exit $(ogRaiseError $OG_ERR_NOTFOUND "$3 $4.$IMGEXT"; echo $?)
# Comprobar que la imagen completa es sincronizable
-ogIsSyncImage "$3" "$4" "img" || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"
+ogIsSyncImage "$3" "$4" "img" || exit $(ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4"; echo $?)
# Comprobar que no está bloqueada
-ogIsImageLocked "$3" "$4.$IMGEXT" && ogRaiseError $OG_ERR_LOCKED "$3 $4.$IMGEXT"
+ogIsImageLocked "$3" "$4.$IMGEXT" && exit $(ogRaiseError $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 && ogRaiseError $OG_ERR_NOTCACHE "CACHE "
+ ! ogFindCache >/dev/null && exit $(ogRaiseError $OG_ERR_NOTCACHE "CACHE "; echo $?)
fi
echo " " > $OGLOGCOMMAND
# Obtener información de los parámetros de entrada.
-PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || ogRaiseError $OG_ERR_PARTITION "$1 $2"
+PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $2"; echo $?)
#Comprobamos que la partición se puede montar.
-ORIG=$(ogMount $1 $2) || ogRaiseError $OG_ERR_PARTITION "$1 $2"
+ORIG=$(ogMount $1 $2) || exit $(ogRaiseError $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 || ogRaiseError $OG_ERR_NOTWRITE "$3" && ogDeleteTree $3 "$DIRTEMP"
+ogMakeDir $3 "$DIRTEMP" 2>/dev/null || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3" && ogDeleteTree $3 "$DIRTEMP" ; echo $?)
DIFFDIR="$(ogGetParentPath "$3" "/$5")"
DIFFFILE="$DIFFDIR/$5.$DIFFEXT"
@@ -116,8 +114,7 @@ echo " " > $OGLOGCOMMAND
SIZEFS=$(ogGetFsSize $1 $2)
echo "[20] $MSG_HELP_ogCheckFs $1 $2 $SIZEFS (KB) " | tee -a $OGLOGSESSION $OGLOGFILE
ogUnmount $1 $2
-ogCheckFs $1 $2 >$OGLOGCOMMAND || ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2"
-
+ogCheckFs $1 $2 >$OGLOGCOMMAND || exit $(ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2" ; echo $?)
# Borramos ficheros de paginacion y configuracion
FSTYPE=$(ogGetFsType $1 $2)
@@ -143,7 +140,7 @@ echo "[40] $MSG_HELP_createDiffImage: $1 $2 $3 $4" | tee -a $OGLOGSESSION $OGLOG
ogMountImage $3 "$4" $IMGEXT >/dev/null
# Comprobar que la imagen completa se ha montado
-ogWaitMountImage $3 "$4" $IMGEXT || ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$3 $4 $IMGEXT: time_out."
+ogWaitMountImage $3 "$4" $IMGEXT || exit $(ogRaiseError $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
@@ -163,7 +160,7 @@ let SIZEREQUIRED=$SIZEDATA*$ZSYNC/100
[ "$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 ] && ogRaiseError $OG_ERR_CACHESIZE "$3"
+[ $SIZEREQUIRED -gt $SIZEFREE ] && exit $(ogRaiseError $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
@@ -177,7 +174,6 @@ if [ "$FSTYPE" == "NTFS" ]; then
fi
TIMEAUX5=$[SECONDS-TIMEAUX3]
-
# Configuro la informacion del tamaño de los datos en /tmp/ogimg.info
sed -i s/SIZEDATA/"$SIZEDATA"/g /tmp/ogimg.info
@@ -186,7 +182,7 @@ echo "[60] $MSG_HELP_ogCreateFileImage." | tee -a $OGLOGSESSION $OGLOGFILE
ogCreateFileImage $3 "$5" $DIFFTYPE $SIZEREQUIRED
# Esperamos que se monte la imagen despues de crarla en el servidor
-ogWaitMountImage "$3" "$5" "$DIFFTYPE" $SIZEREQUIRED || ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$3 $5 $DIFFTYPE: time_out."
+ogWaitMountImage "$3" "$5" "$DIFFTYPE" $SIZEREQUIRED || exit $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$3 $5 $DIFFTYPE: time_out."; echo $?)
echo "[70] $MSG_HELP_ogSyncCreate" | tee -a $OGLOGSESSION $OGLOGFILE
# Copio los datos a la imagen diferecial :
@@ -210,8 +206,7 @@ ogUnlock $1 $2
echo " " > $OGLOGCOMMAND
# Comprobamos que la imagen esta bien
echo "[95] $MSG_HELP_ogCheckSyncImage" | tee -a $OGLOGSESSION $OGLOGFILE
-ogCheckSyncImage $3 "$5" diff
-[ ${PIPESTATUS[0]} -eq 0 ] || ogRaiseError $OG_ERR_IMAGE "$3 $5 diff"
+ogCheckSyncImage $3 "$5" diff || exit $(ogRaiseError $OG_ERR_IMAGE "$3 $5 diff"; echo $?)
#resumen de la operacion
IMGSIZE=$(ls -l --block-size=1024 "${DIFFFILE}"| cut -f5 -d" ")
diff --git a/client/shared/scripts/deployImage b/client/shared/scripts/deployImage
index 6c06b539..7c3030a0 100755
--- a/client/shared/scripts/deployImage
+++ b/client/shared/scripts/deployImage
@@ -68,10 +68,7 @@ echo " " > $OGLOGCOMMAND
echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
# Si el origen(pariticion) esta bloqueada salir.
-if ogIsLocked $DISK $PART; then
- ogRaiseError $OG_ERR_LOCKED "$MSG_PARTITION, $DISK $PART"
- exit $?
-fi
+ogIsLocked $DISK $PART && exit $(ogRaiseError $OG_ERR_LOCKED "$MSG_PARTITION, $DISK $PART"; echo $?)
echo "Desmontando $DISK $PART" | tee -a $OGLOGSESSION $OGLOGFILE
ogUnmount $DISK $PART 2>/dev/null
@@ -81,7 +78,7 @@ ogUnmount $DISK $PART 2>/dev/null
[ "$REPO" == "$(ogGetIpAddress)" ] && REPO="CACHE"
#Informacioin previa de la imagen
-IMGOS=$(ogGetImageInfo `ogGetPath $REPO $IMGNAME.img`) || exit $(echo "ERROR: $OG_ERR_NOTFOUND $MSG_ERR_NOTFOUND, IMAGEN $REPO $3" | tee -a $OGLOGSESSION $OGLOGFILE; ogRaiseError $OG_ERR_NOTFOUND "$MSG_ERR_NOTFOUND, $REPO $3"; echo $?)
+IMGOS=$(ogGetImageInfo `ogGetPath $REPO $IMGNAME.img`) || exit $(ogRaiseError $OG_ERR_NOTFOUND "$REPO $3"; echo $?)
IMGSIZE=$(ls -s `ogGetPath $REPO $IMGNAME.img`| cut -f1 -d" ")
echo "[1] REPO=$REPO IMG-FILE=$IMGNAME.img SIZE=$IMGSIZE (KB) METADATA=$IMGOS" | tee -a $OGLOGSESSION $OGLOGFILE
@@ -129,14 +126,14 @@ case "$REPO" in
esac
;;
*) # Error: protocolo desconocido.
- ogRaiseError $OG_ERR_FORMAT "$MSG_ERR_FORMAT, $PROTO" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogRaiseError $OG_ERR_FORMAT "$MSG_ERR_FORMAT, $PROTO"
exit $?
;;
esac
;;
*) # Error: repositorio desconocido.
- ogRaiseError $OG_ERR_FORMAT "$MSG_ERR_FORMAT, $REPO" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
+ ogRaiseError $OG_ERR_FORMAT "$MSG_ERR_FORMAT, $REPO"
+ exit $?
;;
esac
@@ -146,24 +143,24 @@ case "$NEXTOPERATION" in
CACHE)
echo "[55] $MSG_HELP_ogRestoreImage : restoreImage CACHE $IMGNAME $DISK $PART UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
restoreImage CACHE "$IMGNAME" "$DISK" "$PART"
- RETVAL=${PIPESTATUS[0]}
+ RETVAL=$0
;;
UNICAST)
echo "[55] $MSG_HELP_ogRestoreImage : restoreImage REPO $IMGNAME $DISK $PART UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
restoreImage REPO "$IMGNAME" "$DISK" "$PART"
- RETVAL=${PIPESTATUS[0]}
+ RETVAL=$0
;;
MULTICAST)
echo "[55] $MSG_HELP_ogRestoreImage : restoreImage REPO $IMGNAME $DISK $PART $PROTO $PROTOOPT" | tee -a $OGLOGSESSION $OGLOGFILE
restoreImage REPO "$IMGNAME" "$DISK" "$PART" $PROTO $PROTOOPT
- RETVAL=${PIPESTATUS[0]}
+ RETVAL=$0
;;
esac
RESUMERESTOREIMAGE=$(grep -m 1 "Total Time:" $OGLOGCOMMAND)
echo " [ ] $RESUMERESTOREIMAGE " | tee -a $OGLOGSESSION $OGLOGFILE
# Si la transferencia ha dado error me salgo.
if [ $RETVAL -ne 0 ] ; then
- ogRaiseError $OG_ERR_IMAGE "$REPO $IMGNAME" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
+ ogRaiseError $OG_ERR_IMAGE "$REPO $IMGNAME" 2>&1
# Muestro registro de fin de ejecución si no viene de Ejecutar Script
[ "$(ogGetCaller)" == "EjecutarScript" ] || echo "$MSG_INTERFACE_END $OG_ERR_IMAGE" | tee -a $OGLOGSESSION $OGLOGFILE
exit $OG_ERR_IMAGE
diff --git a/client/shared/scripts/restoreBaseImage b/client/shared/scripts/restoreBaseImage
index 9986a6c4..7e463c26 100755
--- a/client/shared/scripts/restoreBaseImage
+++ b/client/shared/scripts/restoreBaseImage
@@ -24,13 +24,11 @@
#@date 2012-12-04
#*/ ##
-trap "onexit $1 \"$2\" $3 $4" 1 2 3 6 9 14 15 ERR
+trap "onexit $1 \"$2\" $3 $4" 1 2 3 6 9 14 15 EXIT
# Si salimos con error demontamos la imagen y desbloqueamos la imagen y la particion
function onexit() {
local exit_status=$?
- local MSG="$(ogRaiseError $exit_status \"$1 $2 $3 $4\" 2>&1)"
- echo "$MSG" |tee -a $OGLOGFILE $OGLOGSESSION
ogUnmountImage "$1" "$2" "$IMGEXT" &>/dev/null
[ $exit_status -ne 4 ] && ogUnlock $3 $4 &>/dev/null
exit $exit_status
@@ -40,7 +38,8 @@ function onexit() {
echo -n "" >$OGLOGCOMMAND;
[ "$(ogGetCaller)" == "RestaurarImagenBasica" -o "$(ogGetCaller)" == "restoreDiffImage" ] || echo -n "" > $OGLOGSESSION
-echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGFILE $OGLOGSESSION
+# Mensaje de inicio de script salvo si es llamado desde restoreDiffImage.
+[ "$(ogGetCaller)" == "restoreDiffImage" ] || echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGFILE $OGLOGSESSION
TIME1=$SECONDS
PROG="$(basename $0)"
@@ -50,19 +49,19 @@ if [ "$*" == "help" ]; then
"$PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]" \
"$PROG REPO Windows7 1 1 " \
"$PROG CACHE Ubuntu12 1 6 MULTICAST 9000:full-duplex:239.194.14.00:150M:50:60"
- exit 0
+ exit 0
fi
-[ $# -lt 4 ] && ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"
+[ $# -lt 4 ] && exit $(ogRaiseError $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")" || ogRaiseError $OG_ERR_NOTFOUND "REPO, $2.$IMGEXT"
+REPOFILE="$(ogGetPath "REPO" "$2.$IMGEXT")" || exit $(ogRaiseError $OG_ERR_NOTFOUND "REPO, $2.$IMGEXT"; echo $?)
# Comprobar que es sincronizable (con REPO)
-ogIsSyncImage REPO "$2" $IMGEXT || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $2"
+ogIsSyncImage REPO "$2" $IMGEXT || exit $(ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $2"; echo $?)
# Comprobamos si el sistema de ficheros se puede montar
ogMount "$3" "$4" &>/dev/null || RETVAL=$?
@@ -70,19 +69,19 @@ ogMount "$3" "$4" &>/dev/null || RETVAL=$?
if [ "$RETVAL" ] ; then
# TODO ogGetImageInfo
DIRMOUNT=$(ogMountImage "$1" "$2")
- ogWaitMountImage "$1" "$2" "$IMGEXT" || ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $IMGEXT: time_out."
+ 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" || ogRaiseError $OG_ERR_FILESYS "$3 $4"
- ogMount "$3" "$4" || ogRaiseError $OG_ERR_FILESYS "$3 $4"
+ ogFormat "$3" "$4" "$FSTYPE" || exit $(ogRaiseError $OG_ERR_FILESYS "$3 $4"; echo $?)
+ ogMount "$3" "$4" || exit $(ogRaiseError $OG_ERR_FILESYS "$3 $4"; echo $?)
fi
IMGEXT="img"
# Comprobamos si la imagen o la particion estan bloqueada:
-ogIsImageLocked "$1" "$2.$IMGEXT" && ogRaiseError $OG_ERR_LOCKED "$1 $2.$IMGEXT"
-ogIsLocked "$3" "$4" && ogRaiseError $OG_ERR_LOCKED "$3 $4"
+ogIsImageLocked "$1" "$2.$IMGEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$1 $2.$IMGEXT"; echo $?)
+ogIsLocked "$3" "$4" && exit $(ogRaiseError $OG_ERR_LOCKED "$3 $4"; echo $?)
PROTO=${5:-"UNICAST"}
if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
@@ -91,7 +90,7 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
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
updateCache REPO "/$2.$IMGEXT" "$PROTO" "$6"
- RETVAL=${PIPESTATUS[0]}
+ RETVAL=$0
if [ "$RETVAL" != "0" ]
then
echo "[39] $MSG_SCRIPTS_TASK_END updateCache REPO $2.$IMGEXT $5 $6 con error $RETVAL" | tee -a $OGLOGFILE $OGLOGSESSION
@@ -114,7 +113,7 @@ 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" || ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $2 $IMGEXT: time_out."
+ogWaitMountImage "$1" "$2" "$IMGEXT" || exit $(ogRaiseError $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
ogSyncRestore "$1" "$2" "$IMGEXT" $3 $4
@@ -132,10 +131,9 @@ 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
+if [ "$(ogGetCaller)" != "restoreDiffImage" ];then
echo "[90] $MSG_HELP_configureOs" |tee -a $OGLOGFILE $OGLOGSESSION
- # el || echo es para evitar que se maneje el error.
- configureOs $3 $4 &>>$OGLOGCOMMAND || echo "$?" &>>$OGLOGCOMMAND
+ configureOs $3 $4 2>&1 |tee -a $OGLOGCOMMAND
fi
TIME=$[SECONDS-TIME1]
diff --git a/client/shared/scripts/restoreDiffImage b/client/shared/scripts/restoreDiffImage
index 6793616f..b79c8465 100755
--- a/client/shared/scripts/restoreDiffImage
+++ b/client/shared/scripts/restoreDiffImage
@@ -26,13 +26,11 @@
#@date 2012-12-04
#*/ ##
-trap "onexit $1 \"$3\" $4 $5" 1 2 3 6 9 14 15 ERR
+trap "onexit $1 \"$2\" \"$3\" $4 $5" 1 2 3 6 9 14 15 EXIT
# Si salimos con error demontamos la imagen y desbloqueamos la imagen y la particion
function onexit() {
local exit_status=$?
- local MSG="$(ogRaiseError $exit_status \"$1 $3 $4 $5\" 2>&1)"
- echo "$MSG" |tee -a $OGLOGFILE $OGLOGSESSION
ogUnmountImage "$1" "$3" "$DIFFTYPE" &>/dev/null
[ $exit_status -ne 4 ] && ogUnlock $4 $5 &>/dev/null
exit $exit_status
@@ -54,26 +52,26 @@ if [ "$*" == "help" ]; then
exit 0
fi
-[ $# -lt 5 ] && ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE base_image diff_imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"
+[ $# -lt 5 ] && exit $(ogRaiseError $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
# Procesar parámetros de entrada
DIFFTYPE="diff"
DIFFEXT="img.diff"
-REPODIFFFILE="$(ogGetPath "REPO" "$3.$DIFFEXT")" || ogRaiseError $OG_ERR_NOTFOUND "REPO $3.$DIFFEXT"
+REPODIFFFILE="$(ogGetPath "REPO" "$3.$DIFFEXT")" || exit $(ogRaiseError $OG_ERR_NOTFOUND "REPO $3.$DIFFEXT";echo $?)
# Comprobamos si la imagen o la particion estan bloqueada:
-ogIsImageLocked "$1" "$3.$DIFFEXT" && ogRaiseError $OG_ERR_LOCKED "$1 $3.$DIFFEXT"
-ogIsLocked "$4" "$5" && ogRaiseError $OG_ERR_LOCKED "$4 $5"
+ogIsImageLocked "$1" "$3.$DIFFEXT" && exit $(ogRaiseError $OG_ERR_LOCKED "$1 $3.$DIFFEXT";echo $?)
+ogIsLocked "$4" "$5" && exit $(ogRaiseError $OG_ERR_LOCKED "$4 $5";echo $?)
-PART=$(ogDiskToDev "$4" "$5" 2>/dev/null ) || ogRaiseError $OG_ERR_PARTITION "$1 $3"
+PART=$(ogDiskToDev "$4" "$5" 2>/dev/null ) || exit $(ogRaiseError $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 || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $3"
+ogIsSyncImage REPO "$3" diff || exit $(ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$1 $3";echo $?)
# Restauramos la imagen Basica.
restoreBaseImage $1 "$2" "$4" "$5" "$6" "$7"
@@ -83,7 +81,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
- updateCache REPO "/$3.$DIFFEXT" "$PROTO" "$7" | tee -a $OGLOGCOMMAND
+ updateCache REPO "/$3.$DIFFEXT" "$PROTO" "$7"
RETVAL=${PIPESTATUS[0]}
if [ "$RETVAL" != "0" ]
then
@@ -95,17 +93,16 @@ if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
TIMEAUX1=$[SECONDS-TIME]
echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX1/60]m $[TIMEAUX1%60]s" | tee -a $OGLOGFILE $OGLOGSESSION
-
fi
TIME2=$SECONDS
# Restaurar la imagen.
-echo "[40] $MSG_RESTORE $PART"
+echo "[40] $MSG_RESTORE $PART" | tee -a $OGLOGFILE $OGLOGSESSION
# Montamos la diferencial
ogMountImage "$1" "$3" "$DIFFTYPE" &>/dev/null
# Comprobar que la imagen diferencial se ha montado
-ogWaitMountImage "$1" "$3" "$DIFFTYPE" || ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $3 $DIFFTYPE: time_out $TIMEAUX seg."
+ogWaitMountImage "$1" "$3" "$DIFFTYPE" || exit $(ogRaiseError $OG_ERR_DONTMOUNT_IMAGE "$1 $3 $DIFFTYPE: time_out $TIMEAUX seg.";echo $?)
ogMount $4 $5 >/dev/null
ogLock $4 $5
@@ -126,10 +123,7 @@ ogRestoreInfoImage "$4" "$5" &>$OGLOGCOMMAND
# Llamar al script de post-configuración del sistema operativo.
echo "[90] $MSG_HELP_configureOs." | tee -a $OGLOGFILE $OGLOGSESSION
-
-# el || echo es para evitar que se maneje el error.
-configureOs $4 $5 &>>$OGLOGCOMMAND || echo "$?" &>>$OGLOGCOMMAND
-
+configureOs $4 $5 2>&1 | tee -a $OGLOGCOMMAND
TIME=$[SECONDS-TIME1]
echo "[100] $MSG_SCRIPTS_END $MSG_SCRIPTS_TIME_TOTAL: $[TIME/60]m $[TIME%60]s" |tee -a $OGLOGFILE $OGLOGSESSION
diff --git a/client/shared/scripts/restoreImage b/client/shared/scripts/restoreImage
index 0de16a5c..64c0940d 100755
--- a/client/shared/scripts/restoreImage
+++ b/client/shared/scripts/restoreImage
@@ -5,8 +5,8 @@
TIME1=$SECONDS
PROG="$(basename $0)"
if [ $# -lt 4 ]; then
- ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones protocolo]" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones protocolo]"
+ exit $?
fi
#Load engine configurator from engine.cfg file.
@@ -34,8 +34,8 @@ IMGTYPE="${IMGTYPE:-"img"}"
IMGFILE=$(ogGetPath "$REPO" "$IMGNAME.$IMGTYPE")
IMGDIR=$(ogGetParentPath "$REPO" "$IMGNAME")
if [ "$IMGFILE" == "" -o "$IMGDIR" == "" ]; then
- ogRaiseError $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
+ ogRaiseError $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}"
+ exit $?
fi
# Procesar protocolos de transferencia.
@@ -57,8 +57,7 @@ case "$PROTO" in
RETVAL=${PIPESTATUS[0]}
;;
*) # Protocolo desconocido.
- ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones ]" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
-
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones ]"
exit $?
esac
diff --git a/client/shared/scripts/updateCache b/client/shared/scripts/updateCache
index 820ee3ac..95bbfd99 100755
--- a/client/shared/scripts/updateCache
+++ b/client/shared/scripts/updateCache
@@ -1,6 +1,4 @@
#!/bin/bash
-
-
#/**
# updateCache
#@brief Actualiza la cache del cliente con imagen o fichero iso.
@@ -31,8 +29,8 @@
PROG="$(basename $0)"
if [ $# -lt 3 ]; then
- ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG str_REPO _str_Relative_Path_OGIMG_with_/ PROTOCOLO OPCIONES_PROTOCOLO OPCIONES_UPDATECACHE" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG str_REPO _str_Relative_Path_OGIMG_with_/ PROTOCOLO OPCIONES_PROTOCOLO OPCIONES_UPDATECACHE"
+ exit $?
fi
#Carga del configurador del engine
@@ -41,7 +39,7 @@ fi
# Clear temporary file used as log track by httpdlog
# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
echo " " > $OGLOGCOMMAND
-[ "$(ogGetCaller)" == "deployImage" ] || echo -n "" > $OGLOGSESSION;
+[ "$(ogGetCaller)" == "deployImage" -o "$(ogGetCaller)" == "restoreBaseImage" -o "$(ogGetCaller)" == "restoreDiffImage" ] || echo -n "" > $OGLOGSESSION;
REPOSITORIO="${1^^}"
PROTOCOLO="${3^^}"
@@ -51,16 +49,12 @@ echo $REPOSITORIO $REPOIP $PROTOCOLO $OPTPROTOCOLO
# Si el repositorio local CACHE no existe error 15.
if ! $(ogFindCache >/dev/null); then
- ogRaiseError $OG_ERR_NOTCACHE "CACHE" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
+ ogRaiseError $OG_ERR_NOTCACHE "CACHE"
+ exit $0
fi
# comprobar si la imagen existe (.img, .img.diff o directorio)
-REPOFILE=$(ogGetPath "REPO" "/$2")
-if [ "$REPOFILE" == "" ]; then
- ogRaiseError $OG_ERR_NOTFOUND "REPO /$2" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
-fi
+REPOFILE=$(ogGetPath "REPO" "/$2") || exit $(ogRaiseError $OG_ERR_NOTFOUND "REPO /$2"; echo $?)
echo "$MSG_SCRIPTS_UPDATECACHE_DOUPDATE " | tee -a $OGLOGSESSION $OGLOGFILE
# Distingo si es monolitica o sincronizable
@@ -76,10 +70,7 @@ if [ $? == 0 ]; then
RETVAL=0
else
# Si la imagen es monolitica y ha elegido protocolo = RSYNC salimos con error.
- if [ $PROTOCOLO == "RSYNC" ]; then
- ogRaiseError $OG_ERR_DONTSYNC_IMAGE "REPO $2" 2>&1| tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
- fi
+ [ $PROTOCOLO == "RSYNC" ] && exit $(ogRaiseError $OG_ERR_DONTSYNC_IMAGE "REPO $2"; echo $?)
IMGSYNC=FALSE
#TODO: ogUpdateCacheIsNecesary debe borrar la imagen que tenga igual nombre pero distinto sum-
ogUpdateCacheIsNecesary $1 $2
@@ -125,8 +116,8 @@ fi
if [ "$SIZEREQUIRED" -ge "$CACHESIZE" ]
then
echo "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $SIZEREQUIRED > CACHE = $CACHESIZE" | tee -a $OGLOGSESSION $OGLOGFILE
- ogRaiseError $OG_ERR_CACHESIZE "CACHE" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
+ ogRaiseError $OG_ERR_CACHESIZE "CACHE"
+ exit $?
fi
echo "$MSG_SCRIPTS_UPDATECACHE_IFNOTCACHEDO" | tee -a $OGLOGSESSION $OGLOGFILE
@@ -152,8 +143,8 @@ then
;;
*)
echo "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $FILESIZE > CACHE = $CACHESIZEFREE" | tee -a $OGLOGSESSION $OGLOGFILE
- ogRaiseError $OG_ERR_CACHESIZE "CACHE" 2>&1 | tee -a $OGLOGSESSION $OGLOGFILE
- exit ${PIPESTATUS[0]}
+ ogRaiseError $OG_ERR_CACHESIZE "CACHE"
+ exit $?
;;
esac
fi
@@ -226,12 +217,14 @@ case "$PROTOCOLO" in
RESUMEUPDATECACHE=$(grep -m 1 -B1 "Transfer complete" $OGLOGCOMMAND.tmp)
;;
UNICAST)
- echo "unicast" | tee -a $OGLOGSESSION $OGLOGFILE
+ #echo "unicast" | tee -a $OGLOGSESSION $OGLOGFILE
ogCopyFile $REPOSITORIO "$2" "$IMGDIR" 2>&1 | tee -a $OGLOGCOMMAND
sleep 5
RESUMEUPDATECACHE=$(grep -m 1 "100%" $OGLOGCOMMAND.tmp)
;;
RSYNC)
+ # Si parametro de protocolo no era rsync, mensaje de cambio protocolo
+ [ "${3^^}" == "RSYNC" ] || echo $MSG_SCRIPTS_UPDATECACHE_RSYNCPROTOCOLCHANGE |tee -a $OGLOGSESSION $OGLOGFILE
# Opciones de rsync
USERRSYNC="opengnsys"
PASSWORD=" --password-file=/scripts/passrsync "
@@ -267,8 +260,8 @@ case "$PROTOCOLO" in
ogMountImage REPO "${IMGNAME#\/}" $IMGTYPE >/dev/null
# Esperamos que se monte la imagen en el servidor
ogWaitMountImage REPO "$IMGNAME" $IMGTYPE
- echo "$MSG_HELP_ogSyncCreate" | tee -a $OGLOGSESSION $OGLOGFILE
- echo "rsync -aHAX$OPTRSYNC $USERRSYNC@$REPOIP::ogimages/$DIRMOUNT/ $DIRLOCAL" |tee -a $OGLOGSESSION $OGLOGFILE
+ #echo "$MSG_HELP_ogSyncCreate" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo " rsync -aHAX$OPTRSYNC $USERRSYNC@$REPOIP::ogimages/$DIRMOUNT/ $DIRLOCAL" |tee -a $OGLOGSESSION $OGLOGFILE
rsync -aHAX$OPTRSYNC $PASSWORD "$USERRSYNC@$REPOIP::ogimages/$DIRMOUNT/" "$DIRLOCAL" 2>&1 | egrep "^sent|^sending|^total|%" >> $OGLOGCOMMAND
# RETVAL="1" -> OK RETVAL="2" -> error # valores igual que ogUpdateCacheIsNecesary
[ ${PIPESTATUS[0]} == 0 ] && RETVAL="1"|| RETVAL="2"