summaryrefslogtreecommitdiffstats
path: root/client/shared
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2014-03-12 16:30:09 +0000
committerramon <ramongomez@us.es>2014-03-12 16:30:09 +0000
commite7e3140d9e4bd67c0f578c09230d3073986b8367 (patch)
treedbb51ae32e8165d30a8f842225fdc066b06b9671 /client/shared
parent4bf0ddf03d8703ca2b48a421c6b65db7460a69d1 (diff)
#640: Algunos scripts adaptados al nuevo formato de la función {{{ogEcho}}}.
git-svn-id: https://opengnsys.es/svn/branches/version1.0@4182 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client/shared')
-rwxr-xr-xclient/shared/scripts/createImage30
-rwxr-xr-xclient/shared/scripts/deployImage36
-rwxr-xr-xclient/shared/scripts/restoreImage8
-rwxr-xr-xclient/shared/scripts/updateCache66
4 files changed, 69 insertions, 71 deletions
diff --git a/client/shared/scripts/createImage b/client/shared/scripts/createImage
index 3b7053b8..df98ec5b 100755
--- a/client/shared/scripts/createImage
+++ b/client/shared/scripts/createImage
@@ -60,7 +60,7 @@ TIME1=$SECONDS
# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
echo " " > $OGLOGSESSION; echo " " > $OGLOGCOMMAND; echo " " > ${OGLOGCOMMAND}.tmp
-echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*"
# Si el repositorio es CACHE comprobamos que exista
if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
@@ -77,7 +77,7 @@ ogMakeDir $3 /$4$DIRTEMP 2>/dev/null || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3
IMGDIR=$(ogGetParentPath "$3" "/$4")
# Si no existe, crear subdirectorio de la imagen.
if [ $? != 0 ]; then
- echo "[5] $MSG_HELP_ogMakeDir \"$3 $(dirname "$4")." | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[5] $MSG_HELP_ogMakeDir \"$3 $(dirname "$4")."
ogMakeDir "$3" $(dirname "/$4") || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3 /$4"; echo $?)
IMGDIR=$(ogGetParentPath "$3" "/$4") || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3 /$4"; echo $?)
fi
@@ -85,7 +85,7 @@ IMGFILE=$IMGDIR/$(basename "/$4").$IMGEXT
# Renombrar el fichero de imagen si ya existe.
if [ -f "$IMGFILE" ]; then
- echo "[10] $MSG_SCRIPTS_FILE_RENAME \"$IMGFILE\" -> \"$IMGFILE.ant\"." | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[10] $MSG_SCRIPTS_FILE_RENAME \"$IMGFILE\" -> \"$IMGFILE.ant\"."
mv "$IMGFILE" "$IMGFILE.ant"
mv "$IMGFILE.torrent" "$IMGFILE.torrent.ant" 2>/dev/null
mv "$IMGFILE.sum" "$IMGFILE.sum.ant" 2>/dev/null
@@ -108,7 +108,7 @@ else
exit $?
fi
-echo "[16] $PROG: $MSG_SCRIPTS_CREATE_SIZE $SIZEREQUIRED $SIZEFREE" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[16] $PROG: $MSG_SCRIPTS_CREATE_SIZE $SIZEREQUIRED $SIZEFREE"
[ "$SIZEREQUIRED" -gt "$SIZEFREE" ] && exit $(ogRaiseError $OG_ERR_CACHESIZE "$3" || echo $?)
# Ejecuta script personalizado de preconfiguración del sistema operativo modelo.
@@ -119,37 +119,37 @@ fi
# 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 2>/dev/null
ogCheckFs $1 $2 || exit $(ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2" && echo $?)
# Evaluar variable de engine.cfg para reducir el sistema de archivos en la creacion
if [ "$IMGREDUCE" == "TRUE" ]
then
- echo "[30]: $MSG_HELP_ogReduceFs " | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[30]: $MSG_HELP_ogReduceFs"
ogReduceFs $1 $2 &>> $OGLOGCOMMAND || exit $(ogRaiseError $OG_ERR_REDUCEFS "$1 $2"; echo $?)
NEWSIZEFS=$(ogGetFsSize $1 $2)
TIMEAUX=$[SECONDS-TIME1]
- echo " $MSG_SCRIPTS_TIME_PARTIAL ( $NEWSIZEFS KB ) : $[TIMEAUX/60]m $[TIMEAUX%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " $MSG_SCRIPTS_TIME_PARTIAL ( $NEWSIZEFS KB ) : $[TIMEAUX/60]m $[TIMEAUX%60]s"
fi
# Crear la imagen.
echo " " > $OGLOGCOMMAND
TIME2=$SECONDS
-echo "[40] $MSG_HELP_ogCreateImage : ogCreateImage $1 $2 $3 $4 $IMGPROG $IMGCOMP" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[40] $MSG_HELP_ogCreateImage : ogCreateImage $1 $2 $3 $4 $IMGPROG $IMGCOMP"
ogCreateImage "$1" "$2" "$3" "/$4" "$IMGPROG" "$IMGCOMP" &>> $OGLOGCOMMAND || exit $(ogRaiseError $OG_ERR_IMAGE "ogCreteImage"; echo $?)
RESUMECREATEIMAGE=$(grep "Total Time:" $OGLOGCOMMAND)
TIMEAUX2=$[SECONDS-TIME2]
-echo " $RESUMECREATEIMAGE " | tee -a $OGLOGSESSION $OGLOGFILE
-echo " $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX2/60]m $[TIMEAUX2%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " $RESUMECREATEIMAGE "
+ogEcho log session " $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX2/60]m $[TIMEAUX2%60]s"
# Extender sistema de archivos
TIME3=$SECONDS
-echo "[90] Extender sistema de archivos." | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[90] Extender sistema de archivos."
ogExtendFs $1 $2 || exit $(ogRaiseError $OG_ERR_EXTENDFS "$1 $2"; echo $?)
SIZEFS2=$(ogGetFsSize $1 $2)
TIMEAUX3=$[SECONDS-TIME3]
-echo " $MSG_HELP_ogExtendFs $NEWSIZEFS -> $SIZEFS = $SIZEFS2: $[TIMEAUX3/60]m $[TIMEAUX3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " $MSG_HELP_ogExtendFs $NEWSIZEFS -> $SIZEFS = $SIZEFS2: $[TIMEAUX3/60]m $[TIMEAUX3%60]s"
#TODO que hacer si error al extender sistemade archivos
@@ -158,9 +158,9 @@ IMGSIZE=$(ls -s `ogGetPath $3 /$4.img`| cut -f1 -d" ")
IMGOS=$(ogGetImageInfo `ogGetPath $3 /$4.img`)
TIME=$[SECONDS-TIME1]
-echo "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
-echo " FileSystem $PART with $NEWSIZEFS KB data created onto file-image as $4 and used $IMGSIZE KB acros DFS $ogprotocol " | tee -a $OGLOGSESSION $OGLOGFILE
-echo " Image-file $4 metada: $IMGOS " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s"
+ogEcho log session " FileSystem $PART with $NEWSIZEFS KB data created onto file-image as $4 and used $IMGSIZE KB across DFS $ogprotocol"
+ogEcho log session " Image-file $4 metada: $IMGOS"
# Ejecuta scripts personalizado de postconfiguracion del sistema operativo modelo.
if which createImageCustomPost &>/dev/null; then
diff --git a/client/shared/scripts/deployImage b/client/shared/scripts/deployImage
index ca986206..ec108e1f 100755
--- a/client/shared/scripts/deployImage
+++ b/client/shared/scripts/deployImage
@@ -65,12 +65,12 @@ echo " " > $OGLOGCOMMAND
[ "$(ogGetCaller)" == "EjecutarScript" ] || echo -n "" > $OGLOGSESSION
# Registro de inicio de ejecución
-echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*"
# Si el origen(pariticion) esta bloqueada salir.
ogIsLocked $DISK $PART && exit $(ogRaiseError $OG_ERR_LOCKED "$MSG_PARTITION, $DISK $PART"; echo $?)
-echo "Desmontando $DISK $PART" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "Desmontando $DISK $PART"
ogUnmount $DISK $PART 2>/dev/null
# Valor por defecto para el repositorio.
@@ -81,7 +81,7 @@ ogUnmount $DISK $PART 2>/dev/null
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
+ogEcho log session "[1] REPO=$REPO IMG-FILE=$IMGNAME.img SIZE=$IMGSIZE (KB) METADATA=$IMGOS"
# Procesar repositorio.
case "$REPO" in
@@ -99,20 +99,20 @@ case "$REPO" in
# Si protocolo es torrent|torrent-cache o multicast|multicast-cache
TORRENT|TORRENT-CACHE|MULTICAST|MULTICAST-CACHE|UNICAST|UNICAST-CACHE)
- echo "[2] updateCache REPO \"/$IMGNAME.img\" $PROTO $PROTOOPT" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[2] updateCache REPO \"/$IMGNAME.img\" $PROTO $PROTOOPT"
TIME2=$SECONDS
updateCache REPO "/$IMGNAME.img" "$PROTO" "$PROTOOPT"
RETVAL=$?
TIME2=$[SECONDS-TIME2]
- echo " [ ] $MSG_SCRIPTS_TIME_PARTIAL updateCache $[TIME2/60]m $[TIME2%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " [ ] $MSG_SCRIPTS_TIME_PARTIAL updateCache $[TIME2/60]m $[TIME2%60]s"
case $RETVAL in
0)
- echo "[50] updateCache (OK)" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[50] updateCache (OK)"
NEXTOPERATION=CACHE
;;
15|16)
- echo "[50] $MSG_ERR_NOTCACHE ; $MSG_ERR_CACHESIZE " | tee -a $OGLOGSESSION $OGLOGFILE
- echo "[50] $MSG_SCRIPTS_CHECK_ENGINE " | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[50] $MSG_ERR_NOTCACHE ; $MSG_ERR_CACHESIZE "
+ ogEcho log session "[50] $MSG_SCRIPTS_CHECK_ENGINE "
if [ "$RESTOREPROTOCOLNOCACHE" == "MULTICAST" ]; then
case "$PROTO" in
MULTICAST) NEXTOPERATION=MULTICAST ;;
@@ -141,48 +141,48 @@ TIME3=$SECONDS
case "$NEXTOPERATION" in
CACHE)
- echo "[55] $MSG_HELP_ogRestoreImage : restoreImage CACHE $IMGNAME $DISK $PART UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[55] $MSG_HELP_ogRestoreImage : restoreImage CACHE $IMGNAME $DISK $PART UNICAST"
restoreImage CACHE "$IMGNAME" "$DISK" "$PART"
RETVAL=$?
;;
UNICAST)
- echo "[55] $MSG_HELP_ogRestoreImage : restoreImage REPO $IMGNAME $DISK $PART UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[55] $MSG_HELP_ogRestoreImage : restoreImage REPO $IMGNAME $DISK $PART UNICAST"
restoreImage REPO "$IMGNAME" "$DISK" "$PART"
RETVAL=$?
;;
MULTICAST)
- echo "[55] $MSG_HELP_ogRestoreImage : restoreImage REPO $IMGNAME $DISK $PART $PROTO $PROTOOPT" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[55] $MSG_HELP_ogRestoreImage : restoreImage REPO $IMGNAME $DISK $PART $PROTO $PROTOOPT"
restoreImage REPO "$IMGNAME" "$DISK" "$PART" $PROTO $PROTOOPT
RETVAL=$?
;;
esac
RESUMERESTOREIMAGE=$(grep -m 1 "Total Time:" $OGLOGCOMMAND)
-echo " [ ] $RESUMERESTOREIMAGE " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " [ ] $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
# 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
+ [ "$(ogGetCaller)" == "EjecutarScript" ] || ogEcho log session "$MSG_INTERFACE_END $OG_ERR_IMAGE"
exit $OG_ERR_IMAGE
fi
TIME3=$[SECONDS-TIME3]
-echo " [ ] $MSG_SCRIPTS_TIME_PARTIAL : $[TIME3/60]m $[TIME3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session " [ ] $MSG_SCRIPTS_TIME_PARTIAL : $[TIME3/60]m $[TIME3%60]s"
if which configureOsCustom &>/dev/null; then
- echo "[90] configureOsCustom" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[90] configureOsCustom"
configureOsCustom "$DISK" "$PART"
else
- echo "[90] $MSG_SCRIPTS_OS_CONFIGURE " | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[90] $MSG_SCRIPTS_OS_CONFIGURE "
configureOs "$DISK" "$PART"
fi
TIME=$[SECONDS-TIME1]
-echo "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s"
# Registro de fin de ejecución
# Si se ha llamado desde ejecutar script no lo muestro para no repetir.
if [ "$(ogGetCaller)" != "EjecutarScript" ] ; then
- echo "$MSG_INTERFACE_END $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "$MSG_INTERFACE_END $RETVAL"
exit $RETVAL
fi
diff --git a/client/shared/scripts/restoreImage b/client/shared/scripts/restoreImage
index 64c0940d..9d7b4e6e 100755
--- a/client/shared/scripts/restoreImage
+++ b/client/shared/scripts/restoreImage
@@ -34,7 +34,7 @@ IMGTYPE="${IMGTYPE:-"img"}"
IMGFILE=$(ogGetPath "$REPO" "$IMGNAME.$IMGTYPE")
IMGDIR=$(ogGetParentPath "$REPO" "$IMGNAME")
if [ "$IMGFILE" == "" -o "$IMGDIR" == "" ]; then
- ogRaiseError $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}"
+ ogRaiseError $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}"
exit $?
fi
@@ -42,7 +42,7 @@ fi
case "$PROTO" in
UNICAST|UNICAST-DIRECT)
# Restaurar la imagen.
- echo "[40] ogRestoreImage $REPO $IMGNAME $DISK $PART UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[40] ogRestoreImage $REPO $IMGNAME $DISK $PART UNICAST"
ogRestoreImage "$REPO" "$IMGNAME" "$DISK" "$PART" UNICAST 2>&1 | tee -a $OGLOGCOMMAND
RETVAL=${PIPESTATUS[0]}
;;
@@ -51,7 +51,7 @@ case "$PROTO" in
TOOL=$(ogGetImageProgram REPO $IMGNAME)
COMPRESS=$(ogGetImageCompressor REPO $IMGNAME)
#TODO comprobar parametros anteriores
- echo "[40] ogMcastReceiverPartition $DISK $PART $PORT $TOOL $COMPRESS" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[40] ogMcastReceiverPartition $DISK $PART $PORT $TOOL $COMPRESS"
ogMcastRequest "$IMGNAME.img" "$PROTOOPT"
ogMcastReceiverPartition "$DISK" "$PART" "$PORT" "$TOOL" "$COMPRESS" 2>&1 | tee -a $OGLOGCOMMAND
RETVAL=${PIPESTATUS[0]}
@@ -62,7 +62,7 @@ case "$PROTO" in
esac
TIME=$[SECONDS-TIME1]
-echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
# Código de salida del comando prinicpal de restauración.
exit $RETVAL
diff --git a/client/shared/scripts/updateCache b/client/shared/scripts/updateCache
index b6ce1293..11cee1da 100755
--- a/client/shared/scripts/updateCache
+++ b/client/shared/scripts/updateCache
@@ -56,7 +56,7 @@ fi
# comprobar si la imagen existe (.img, .img.diff o directorio)
REPOFILE=$(ogGetPath "REPO" "/$2") || exit $(ogRaiseError $OG_ERR_NOTFOUND "REPO /$2"; echo $?)
-echo "$MSG_SCRIPTS_UPDATECACHE_DOUPDATE " | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_DOUPDATE"
# Distingo si es monolitica o sincronizable
file "$REPOFILE" | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " -e " directory" 2>&1 > /dev/null
if [ $? == 0 ]; then
@@ -85,8 +85,8 @@ CACHESIZE=$(ogGetCacheSize)
CACHESIZEFREE=$(ogGetFreeSize `ogFindCache`)
FILESIZE=$(ls -sk $(ogGetPath $REPOSITORIO "$2") | cut -f1 -d" ")
if [ "$IMGTYPE" == "dir" ]; then
- echo " * $MSG_SCRIPTS_UPDATECACHE_CHECKSIZEDIR" | tee -a $OGLOGSESSION $OGLOGFILE
- echo " du -sk $REPOFILE" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " * $MSG_SCRIPTS_UPDATECACHE_CHECKSIZEDIR"
+ ogEcho log session " du -sk $REPOFILE"
REALFILESIZE=$(du -sk "$REPOFILE"|awk '{print $1}')
else
REALFILESIZE=$(ls -l --block-size=1024 $REPOFILE | cut -f5 -d" ")
@@ -99,8 +99,8 @@ if [ "$PROTOCOLO" == "RSYNC" ]; then
CACHEFILESIZE=0
else
if [ "$IMGTYPE" == "dir" ]; then
- echo " * $MSG_SCRIPTS_UPDATECACHE_CHECKSIZEDIR $CACHEFILESIZE" | tee -a $OGLOGSESSION $OGLOGFILE
- echo " du -sk $CACHEFILE" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " * $MSG_SCRIPTS_UPDATECACHE_CHECKSIZEDIR $CACHEFILESIZE"
+ ogEcho log session " du -sk $CACHEFILE"
CACHEFILESIZE=$(du -sk $CACHEFILE |awk '{print $1}')
else
CACHEFILESIZE=$(ls -l --block-size=1024 "$CACHEFILE" | cut -f5 -d" ")
@@ -115,34 +115,34 @@ fi
#ERROR CACHESIZE 16
if [ "$SIZEREQUIRED" -ge "$CACHESIZE" ]
then
- echo "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $SIZEREQUIRED > CACHE = $CACHESIZE" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $SIZEREQUIRED > CACHE = $CACHESIZE"
ogRaiseError $OG_ERR_CACHESIZE "CACHE"
exit $?
fi
-echo "$MSG_SCRIPTS_UPDATECACHE_IFNOTCACHEDO" | tee -a $OGLOGSESSION $OGLOGFILE
+ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_IFNOTCACHEDO"
#ERROR CACHESIZE 16
if [ "$SIZEREQUIRED" -ge "$CACHESIZEFREE" ]
then
- # echo "[ ] No hay espacio sufiente en la CACHE, detectar que hacer con engine.cfg" | tee -a $OGLOGSESSION $OGLOGFILE
+ # ogEcho log session "[ ] No hay espacio sufiente en la CACHE, detectar que hacer con engine.cfg"
case "$ACTIONCACHEFULL" in
NONE)
NEXTOPERATION=UNICAST
;;
FORMAT)
- echo "[51] $MSG_HELP_ogFormatCache " | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[51] $MSG_HELP_ogFormatCache "
ogUnmountCache
ogFormatCache
ogMountCache
NEXTOPERATION=REPEAT
;;
DELETE)
- echo "[51] #MSG_HELP_ogDeleteTree $OGCAC$OGIMG/* " | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[51] #MSG_HELP_ogDeleteTree $OGCAC$OGIMG/* "
rm -fr $OGCAC$OGIMG/*
NEXOPERATION=REPEAT
;;
*)
- echo "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $FILESIZE > CACHE = $CACHESIZEFREE" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $FILESIZE > CACHE = $CACHESIZEFREE"
ogRaiseError $OG_ERR_CACHESIZE "CACHE"
exit $?
;;
@@ -161,7 +161,7 @@ ogMountCache >/dev/null
## Si no existe, crear subdirectorio para el fichero en la cache.
IMGDIR=$(ogGetParentPath CACHE "/$2")
if [ $? != 0 ]; then
- echo "[5] $MSG_HELP_ogMakeDir \"$2 $(dirname "$2")." | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "[5] $MSG_HELP_ogMakeDir \"$2 $(dirname "$2")."
ogMakeDir CACHE $(dirname "/$2")
IMGDIR=$(ogGetParentPath CACHE "/$2") || exit $?
fi
@@ -170,7 +170,7 @@ TIME1=$SECONDS
case "$PROTOCOLO" in
TORRENT)
- echo "ogCopyFile $1 $2.torrent absolute $OGCAC/$OGIMG" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "ogCopyFile $1 $2.torrent absolute $OGCAC/$OGIMG"
# tiempos
timewait=$(expr $(printf '%d\n' 0x$(ogGetMacAddress | awk -F: '{print $5$6}')) \* 120 / 65535)
ogCopyFile $REPOSITORIO "$2.torrent" "$IMGDIR" 2>&1 | tee -a $OGLOGCOMMAND
@@ -178,16 +178,16 @@ case "$PROTOCOLO" in
#TODO comprobar que el fichero torrent está en cache
# retardamos el inicio -aleatorio de 0 a 120 segundos- al tracker para gestionar mas de +-40 equipos
P2PWAIT=$[ ( $RANDOM % 120 ) + 1 ]
- echo " [ ] $MSG_SCRIPTS_TASK_SLEEP : $P2PWAIT seconds ogTorrentStart CACHE $2.torrent $4" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " [ ] $MSG_SCRIPTS_TASK_SLEEP : $P2PWAIT seconds ogTorrentStart CACHE $2.torrent $4"
sleep $P2PWAIT
- echo " [ ] $MSG_SCRIPTS_TASK_START: ogTorrentStart CACHE $2.torrent $4" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " [ ] $MSG_SCRIPTS_TASK_START: ogTorrentStart CACHE $2.torrent $4"
ogTorrentStart CACHE "$2.torrent" $4 2>&1 | tee -a $OGLOGCOMMAND
RESUMEUPDATECACHE=$(grep -m 1 -B1 "Download" $OGLOGCOMMAND)
;;
MULTICAST)
PORT=$(echo $OPTPROTOCOLO | cut -f1 -d":")
let PORTAUX=$PORT+1
- echo "$MSG_SCRIPTS_UPDATECACHE_CHECKMCASTSESSION : $REPOIP:$PORTAUX:$PORT" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_CHECKMCASTSESSION : $REPOIP:$PORTAUX:$PORT"
#TODO: ticket 379
NUMBER=$[ ( $RANDOM % 30 ) + 1 ]
sleep $NUMBER
@@ -198,17 +198,16 @@ case "$PROTOCOLO" in
else
# TODO ticket 379 Realizar la petición basada en identificador de operacion
- echo "$MSG_SCRIPTS_TASK_START : hose $REPOIP 2009 --out sh -c "echo -ne START_MULTICAST $2 $OPTPROTOCOLO"" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "$MSG_SCRIPTS_TASK_START : hose $REPOIP 2009 --out sh -c \"echo -ne START_MULTICAST $2 $OPTPROTOCOLO\""
hose $REPOIP 2009 --out sh -c "echo -ne START_MULTICAST $2 $OPTPROTOCOLO"
#echo "espero y llamo a: ogMcastReceiverFile $PORT CACHE $2"
sleep 10
if (nmap -n -sU -p $PORTAUX $REPOIP | grep open)
then
ogMcastReceiverFile $PORT CACHE "$2" 2>&1 | tee -a $OGLOGCOMMAND
-
else
- echo "$MSG_SCRIPTS_TASK_ERR : hose $REPOIP 2009 --out sh -c echo -ne START_MULTICAST $2 $OPTPROTOCOLO" | tee -a $OGLOGSESSION $OGLOGFILE
- exit 1
+ ogEcho log session "$MSG_SCRIPTS_TASK_ERR : hose $REPOIP 2009 --out sh -c echo -ne START_MULTICAST $2 $OPTPROTOCOLO"
+ exit 1
fi
fi
#cat $OGLOGCOMMAND.tmp | grep -B1 "Transfer complete"
@@ -217,14 +216,14 @@ case "$PROTOCOLO" in
RESUMEUPDATECACHE=$(grep -m 1 -B1 "Transfer complete" $OGLOGCOMMAND.tmp)
;;
UNICAST)
- #echo "unicast" | tee -a $OGLOGSESSION $OGLOGFILE
+ #ogEcho log session "unicast"
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
+ [ "${3^^}" == "RSYNC" ] || ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_RSYNCPROTOCOLCHANGE"
# Opciones de rsync
USERRSYNC="opengnsys"
PASSWORD=" --password-file=/scripts/passrsync "
@@ -235,7 +234,7 @@ case "$PROTOCOLO" in
if [ -d $REPOFILE ]; then
# Si es sincronizada tipo directorio.
[ -d "$OGCAC$OGIMG/$2" ] || mkdir "$OGCAC$OGIMG/$2"
- echo "rsync -aHAX$OPTRSYNC $USERRSYNC@$REPOIP::ogimages/$2/ $OGCAC$OGIMG/$2" |tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "rsync -aHAX$OPTRSYNC $USERRSYNC@$REPOIP::ogimages/$2/ $OGCAC$OGIMG/$2"
rsync -aHAX$OPTRSYNC $PASSWORD "$USERRSYNC@$REPOIP::ogimages/$2/" "$OGCAC$OGIMG/$2" 2>> $OGLOGCOMMAND | egrep "^sent|^sending|^total%" >> $OGLOGCOMMAND
else
# Si es sincronizada tipo archivo.
@@ -245,23 +244,22 @@ case "$PROTOCOLO" in
DIRMOUNT=$(ogGetMountImageDir "$IMGNAME" $IMGTYPE)
DIRLOCAL="/tmp/$DIRMOUNT"
mkdir "$DIRLOCAL" 2>/dev/null
- echo "$MSG_SCRIPTS_UPDATECACHE_CHECKSIZEIMG" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_CHECKSIZEIMG"
# Si la imagen no existe la creo
# Si la imagen del repositorio es mayor, redimensiono la imagen de cache
if [ "$CACHEFILE" == "" -o $CACHEFILESIZE -lt $REALFILESIZE ]; then
- echo "$MSG_HELP_ogCreateFileImage" | tee -a $OGLOGSESSION $OGLOGFILE
- 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
+ ogEcho log session "$MSG_HELP_ogCreateFileImage"
+ ogCreateFileImage CACHE "$IMGNAME" $IMGTYPE $REALFILESIZE
+ TIMEAUX3=$[SECONDS-TIMEAUX3]
+ ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX3/60]m $[TIMEAUX3%60]s"
fi
# Montamos las imagenes para sincronizarlas. Quitamos / inicial.
ogMountImage CACHE "${IMGNAME#\/}" $IMGTYPE || exit $?
ogMountImage REPO "${IMGNAME#\/}" $IMGTYPE
# Esperamos que se monte la imagen en el servidor
ogWaitMountImage REPO "$IMGNAME" $IMGTYPE || exit $?
- #echo "$MSG_HELP_ogSyncCreate" | tee -a $OGLOGSESSION $OGLOGFILE
- echo " rsync -aHAX$OPTRSYNC $USERRSYNC@$REPOIP::ogimages/$DIRMOUNT/ $DIRLOCAL" |tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " rsync -aHAX$OPTRSYNC $USERRSYNC@$REPOIP::ogimages/$DIRMOUNT/ $DIRLOCAL"
rsync -aHAX$OPTRSYNC $PASSWORD "$USERRSYNC@$REPOIP::ogimages/$DIRMOUNT/" "$DIRLOCAL" 2>>$OGLOGCOMMAND | egrep "^sent|^sending|^total|%" >> $OGLOGCOMMAND
# RETVAL="1" -> OK RETVAL="2" -> error # valores igual que ogUpdateCacheIsNecesary
[ ${PIPESTATUS[0]} -eq 0 ] && RETVAL="1"|| RETVAL="2"
@@ -274,9 +272,9 @@ esac
TIME1=$[SECONDS-TIME1]
-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
+ogEcho log session " [ ] $RESUMEUPDATECACHE "
+ogEcho log session " [ ] $MSG_SCRIPTS_TIME_PARTIAL updateCache $[TIME1/60]m $[TIME1%60]s"
+ogEcho log session " [ ] $MSG_SCRIPTS_TASK_START $MSG_HELP_ogCalculateChecksum "
TIME2=$SECONDS
# Si es imagen sincronizada siempre da distinto md5. No podemos comprobar
if [ "$IMGSYNC" == "TRUE" ]; then
@@ -288,7 +286,7 @@ else
fi
if [ "$(ogGetCaller)" != "deployImage" ]; then
TIME2=$[SECONDS-TIME2]
- echo " [ ] $MSG_SCRIPTS_TIME_PARTIAL $MSG_HELP_ogCalculateChecksum $[TIME2/60]m $[TIME2%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogEcho log session " [ ] $MSG_SCRIPTS_TIME_PARTIAL $MSG_HELP_ogCalculateChecksum $[TIME2/60]m $[TIME2%60]s"
fi
# si RETVAL=0 => actualizamos si RETVAL=1 no actaulizamos-exit 0 || si RETVAL>2 exit 1
[ "$RETVAL" == "0" ] && exit 1