summaryrefslogtreecommitdiffstats
path: root/admin/Interface
diff options
context:
space:
mode:
authoradv <adv@uma.es>2012-01-22 21:21:22 +0000
committeradv <adv@uma.es>2012-01-22 21:21:22 +0000
commite272d9e0daceefa365204435ca313dc6ade6c985 (patch)
treea6055177e2914d3b9337d21f7a0bb690cb3b2d29 /admin/Interface
parentfe08e1b92acaf0e92f081ac94add3cdf4e5b05aa (diff)
#477 internacionalización de creacion y restauracion -interface, scripts-
git-svn-id: https://opengnsys.es/svn/branches/version1.0@2458 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/Interface')
-rwxr-xr-xadmin/Interface/CrearImagen43
-rwxr-xr-xadmin/Interface/EjecutarScript32
-rwxr-xr-xadmin/Interface/RestaurarImagen73
3 files changed, 89 insertions, 59 deletions
diff --git a/admin/Interface/CrearImagen b/admin/Interface/CrearImagen
index 1d59da29..89391ed3 100755
--- a/admin/Interface/CrearImagen
+++ b/admin/Interface/CrearImagen
@@ -28,23 +28,20 @@
#Códigos de error de la funcion ogCreateImage
-TIME1=$SECONDS
-
-#TODO: revisar las variables.
-OGLOGSESSION="${OGLOGSESSION=:-/tmp/session.log}"
-OGLOGCOMMAND="${OGLOGCOMMAND=:-/tmp/command.log}"
-OGLOGSESSION="/tmp/session.log"
-OGLOGCOMMAND="/tmp/command.log"
-echo " " > $OGLOGSESSION
-echo " " > $OGLOGCOMMAND
-echo " " > ${OGLOGCOMMAND}.tmp
+TIME1=$SECONDS
-# Registro de ejecución
-echo $* >> $OGLOGFILE
+#Load engine configurator from engine.cfg file.
+#Carga el configurador del engine desde el fichero engine.cfg
+[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
-echo "$*" &>> $OGLOGSESSION | $(tail -n 1 $OGLOGSESSION >> $OGLOGFILE)
+# 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 " " > ${OGLOGCOMMAND}.tmp
+# Registro de inicio de ejecución
+#echo "[START Interface ] Run this command: $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
+echo "$MSG_INTERFACE_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
# Solo ejecutable por OpenGnSys Client.
PATH=$PATH:$(dirname $0)
@@ -80,7 +77,7 @@ fi
if [ -f createImage$ogengine ]; then
- createImage$ogengine "$1" "$2" "$REPO" /"$3" &>> $OGLOGFILE
+ createImage$ogengine "$1" "$2" "$REPO" /"$3" &>> $OGLOGCOMMAND
else
createImage "$1" "$2" "$REPO" /"$3" &>> $OGLOGCOMMAND
fi
@@ -88,13 +85,17 @@ RETVAL=$?
[ "$REPO" == "REPO" -a "$boot" != "admin" ] && CambiarAcceso user
-if [ $RETVAL == 0 ]
-then
- rm $OGLOGFILE
- touch $OGLOGFILE
-else
- echo $RETVAL &>> $OGLOGFILE
-fi
+#if [ $RETVAL == 0 ]
+#then
+#rm $OGLOGFILE
+# touch $OGLOGFILE
+#else
+# echo $RETVAL &>> $OGLOGFILE
+#fi
+
+# Registro de fin de ejecución
+#echo "[END Interface] Command finished with this code: $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+echo "$MSG_INTERFACE_END $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
exit $RETVAL
diff --git a/admin/Interface/EjecutarScript b/admin/Interface/EjecutarScript
index 431164b9..1295885c 100755
--- a/admin/Interface/EjecutarScript
+++ b/admin/Interface/EjecutarScript
@@ -1,27 +1,30 @@
#!/bin/bash
TIME1=$SECONDS
-OGLOGSESSION="${OGLOGSESSION=:-/tmp/session.log}"
-OGLOGCOMMAND="${OGLOGCOMMAND=:-/tmp/command.log}"
-OGLOGSESSION="/tmp/session.log"
-OGLOGCOMMAND="/tmp/command.log"
+#Load engine configurator from engine.cfg file.
+#Carga el configurador del engine desde el fichero engine.cfg
+[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
-echo " " > $OGLOGSESSION
-echo " " > $OGLOGCOMMAND
-echo " " > ${OGLOGCOMMAND}.tmp
+# 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 " " > ${OGLOGCOMMAND}.tmp
-
-echo "START JOBS ***************************** " | tee -a $OGLOGSESSION $OGLOGFILE
+# Registro de inicio de ejecución
+#echo "[START Interface ] Run this command: $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
+echo "$MSG_INTERFACE_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
echo "Instrucciones a ejecutar: *****************************" >> $OGLOGFILE
cat $1 >> $OGLOGFILE
+
echo "Salida de las instrucciones: *****************************" >> $OGLOGFILE
chmod +x $1
$1 &>> $OGLOGCOMMAND
RETVAL=$?
-echo $RETVAL &>> $OGLOGFILE
+
+
+
TIME=$[SECONDS-TIME1]
if [ $RETVAL == 0 ]
then
@@ -29,5 +32,12 @@ then
else
echo "ERROR no operacion no realizada" | tee -a $OGLOGSESSION $OGLOGFILE
fi
-echo "END JOBS ***************************** " | tee -a $OGLOGSESSION $OGLOGFILE
+
+
+# Registro de fin de ejecución
+#echo "[END Interface] Command finished with this code: $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+echo "$MSG_INTERFACE_END $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+
+
+
exit $RETVAL \ No newline at end of file
diff --git a/admin/Interface/RestaurarImagen b/admin/Interface/RestaurarImagen
index f9923fed..1ee08bee 100755
--- a/admin/Interface/RestaurarImagen
+++ b/admin/Interface/RestaurarImagen
@@ -30,29 +30,30 @@
#@version 1.0.1 - Separación de los ficheros-log para ser gestionado por el httpd-log
#@author Antonio J. Doblas Viso. Universidad de Málaga
#@date 2011-05-11
+#@version 1.0.2 - Logica basada en fichero de configuracion engine.cfg
+#@author Antonio J. Doblas Viso. Universidad de Málaga
+#@date 2012-01-11
+PROTO=$5
+PROTOOPT=$6
TIME1=$SECONDS
-#Carga del configurador del engine
+
+#Load engine configurator from engine.cfg file.
+#Carga el configurador del engine desde el fichero engine.cfg
[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
-#OGLOGSESSION="${OGLOGSESSION=:-/tmp/session.log}"
-#OGLOGCOMMAND="${OGLOGCOMMAND=:-/tmp/command.log}"
-#OGLOGSESSION="/tmp/session.log"
-#OGLOGCOMMAND="/tmp/command.log"
+# 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 " " > ${OGLOGCOMMAND}.tmp
-echo " " > $OGLOGSESSION
-echo " " > $OGLOGCOMMAND
-echo " " > ${OGLOGCOMMAND}.tmp
-# Registro de ejecución
-echo $* >> $OGLOGSESSION
-echo "$*" &>> $OGLOGSESSION | $(tail -n 1 $OGLOGSESSION >> $OGLOGFILE)
+# Registro de inicio de ejecución
+#echo "[START Interface ] Run this command: $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
+echo "$MSG_INTERFACE_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
-echo "[1] Iniciando $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
# Si el origen(pariticion) esta bloqueada salir.
-
echo "TODO comprobando si esta bloqueado el $1 $2" | tee -a $OGLOGSESSION $OGLOGFILE
#if ogIsLocked $1 $2; then
# ogRaiseError $OG_ERR_LOCKED "$MSG_PARTITION, $1 $2"
@@ -65,12 +66,18 @@ REPO=${4:-"REPO"}
[ "$REPO" == "$(ogGetIpAddress)" ] && REPO="CACHE"
[ "$REPO" == "CACHE" ] && REPO="CACHE"
+#Informacioin previa de la imagen
+IMGSIZE=$(ls -s `ogGetPath $REPO $3.img`| cut -f1 -d" ")
+IMGOS=$(ogGetImageInfo `ogGetPath $REPO $3.img`)
+
+echo "[1] IMG-FILE=$3 SIZE=$IMGSIZE (KB) METADATA=$IMGOS" | tee -a $OGLOGSESSION $OGLOGFILE
if [ "$REPO" == "CACHE" ]
then
- echo "[2] Iniciando un ogRestoreImage CACHE $3 $1 $2" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo "[2] $MSG_HELP_ogRestoreImage : ogRestoreImage CACHE $3 $1 $2" | tee -a $OGLOGSESSION $OGLOGFILE
ogRestoreImage CACHE "$3" "$1" "$2" &>> $OGLOGCOMMAND
RETVAL=$?
+ RESUMERESTOREIMAGE=$(cat $OGLOGCOMMAND | grep "Total Time:")
fi
@@ -90,14 +97,15 @@ then
updateCache REPO "/$3.img" "$5" "$6" &>> $OGLOGCOMMAND
RETVAL=$?
TIME2=$[SECONDS-TIME2]
- echo " [ ] Duracion del subproceso updateCache $[TIME2/60]m $[TIME2%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo " [ ] $MSG_SCRIPTS_TIME_PARTIAL updateCache $[TIME2/60]m $[TIME2%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
case $RETVAL in
0)
- echo "[50] updateCache (correcto)" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo "[50] updateCache (OK)" | tee -a $OGLOGSESSION $OGLOGFILE
NEXTOPERATION=CACHE
;;
15|16)
- echo "[50] equipo sin CACHE o tamaño insufiente, analizando proceso a realizar según engine.cfg" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo "[50] $MSG_ERR_NOTCACHE ; $MSG_ERR_CACHESIZE " | tee -a $OGLOGSESSION $OGLOGFILE
+ echo "[50] $MSG_SCRIPTS_CHECK_ENGINE " | tee -a $OGLOGSESSION $OGLOGFILE
case "$RESTOREPROTOCOLNOCACHE" in
MULTICAST|multicast)
[ "$5" == "MULTICAST" ] && NEXTOPERATION=MULTICAST
@@ -114,24 +122,28 @@ then
esac
fi
+
TIME3=$SECONDS
+
case $NEXTOPERATION in
CACHE)
- echo "[55] Restaurando la imagen desde la cache con comando: ogRestoreImage CACHE $3 $1 $2 UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo "[55] CACHE $MSG_HELP_ogRestoreImage : ogRestoreImage CACHE $3 $1 $2 UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
ogRestoreImage CACHE "$3" "$1" "$2" &> $OGLOGCOMMAND
RETVAL=$?
+ RESUMERESTOREIMAGE=$(cat $OGLOGCOMMAND | grep "Total Time:")
;;
UNICAST)
- echo "[55] Se restaura la imagen directamente desde el REPO: ogRestoreImage REPO $3 $1 $2 UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo "[55] $5 $MSG_HELP_ogRestoreImage : ogRestoreImage REPO $3 $1 $2 UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
ogRestoreImage REPO "$3" "$1" "$2" &> $OGLOGCOMMAND
RETVAL=$?
+ RESUMERESTOREIMAGE=$(cat $OGLOGCOMMAND | grep "Total Time:")
;;
MULTICAST)
- echo "[55] Se restaura la imagen directamente a la Particion por MULTICAST" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo "[55] $PROTO $PROTOOPT $MSG_HELP_ogRestoreImage " | tee -a $OGLOGSESSION $OGLOGFILE
OPTPROTOCOLO=$6
REPOIP=$(ogGetRepoIp)
- echo "determinando puerto principal y auxiliar." | tee -a $OGLOGSESSION
+ echo " $MSG_SCRIPTS_MULTICAST_PRECHECK_PORT " | tee -a $OGLOGSESSION
PORT=$(echo $OPTPROTOCOLO | cut -f1 -d":")
let PORTAUX=$PORT+1
#TODO: ticket 379
@@ -140,13 +152,13 @@ case $NEXTOPERATION in
#FIN TODO
tools=$(ogGetImageProgram REPO $3)
compressor=$(ogGetImageCompressor REPO $3)
- echo "comprobando puerto $PORTAUX en $REPOIP (sesion multicast en puerto $PORT) " | tee -a $OGLOGSESSION
+ echo " $MSG_SCRIPTS_MULTICAST_CHECK_PORT $REPOIP:$PORTAUX $REPOIP:$PORT" | tee -a $OGLOGSESSION
if (nmap -n -sU -p $PORTAUX $REPOIP | grep open)
then
ogMcastReceiverPartition $1 $2 $PORT $tools $compressor &> $OGLOGCOMMAND
else
# TODO ticket 379 Realizar la petición basada en identificador de operacion
- echo "solicita la apertura: hose $REPOIP 2009 --out sh -c echo -ne START_MULTICAST /$3.img $OPTPROTOCOLO" | tee -a $OGLOGSESSION
+ echo " $MSG_SCRIPTS_MULTICAST_REQUEST_PORT : hose $REPOIP 2009 --out sh -c echo -ne START_MULTICAST /$3.img $OPTPROTOCOLO" | tee -a $OGLOGSESSION $OGLOGFILE
hose $REPOIP 2009 --out sh -c "echo -ne START_MULTICAST /$3.img $OPTPROTOCOLO"
#echo "espero y llamo a: ogMcastReceiverFile $PORT CACHE $2"
sleep 20
@@ -155,24 +167,31 @@ case $NEXTOPERATION in
ogMcastReceiverPartition $1 $2 $PORT $tools $compressor &> $OGLOGCOMMAND
RETVAL=$?
fi
- fi
+ fi
+ RESUMERESTOREIMAGE=$(cat $OGLOGCOMMAND | grep "Total Time:")
;;
REPEAT)
$0 $*
;;
esac
+echo " [ ] $RESUMERESTOREIMAGE " | tee -a $OGLOGSESSION $OGLOGFILE
TIME3=$[SECONDS-TIME3]
-echo " [ ] $RETVAL Duracion del subproceso de restauracion: $[TIME3/60]m $[TIME3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+echo " [ ] $MSG_SCRIPTS_TIME_PARTIAL : $[TIME3/60]m $[TIME3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
#if [ $RETVAL == 0 ]
#then
- echo "[90] Iniciando la Configuracion del Sistema Restaurado" | tee -a $OGLOGSESSION $OGLOGFILE
+ echo "[90] $MSG_SCRIPTS_OS_CONFIGURE " | tee -a $OGLOGSESSION $OGLOGFILE
configureOs "$1" "$2"
#fi
TIME=$[SECONDS-TIME1]
-echo "[100] $RETVAL Duracion de la operacion $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+echo "[100] $MSG_SCRIPTS_TIME_TOTAL $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
+
+# Registro de fin de ejecución
+#echo "[END Interface] Command finished with this code: $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+echo "$MSG_INTERFACE_END $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
+
exit $RETVAL