source: client/shared/scripts/restoreImage @ 993c328

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 993c328 was 7f8d5d5, checked in by irina <irinagomez@…>, 11 years ago

#636 log en tiempo real: mejora para unicast y mcast-direct.

git-svn-id: https://opengnsys.es/svn/branches/version1.0@4145 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.6 KB
RevLine 
[f8f4dfa]1#!/bin/bash
[e42f34e]2# Scirpt de ejemplo para restaurar una imagen.
[f8f4dfa]3# (puede usarse como base para el programa de restauración de imágenes usado por OpenGNSys Admin).
4
[f5432db7]5TIME1=$SECONDS
[f8f4dfa]6PROG="$(basename $0)"
[87a7a799]7if [ $# -lt 4 ]; then
[d2f28cf]8    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones protocolo]"
[f8f4dfa]9    exit $?
10fi
11
[d2f28cf]12#Load engine configurator from engine.cfg file.
13#Carga el configurador del engine desde el fichero engine.cfg
14# Valores por defecto: #IMGPROG="partclone" ; #IMGCOMP="lzop" ; #IMGEXT="img" #IMGREDUCE="TRUE"
15[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
16
17# Clear temporary file used as log track by httpdlog
18# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
[7f8d5d5]19echo " " > $OGLOGCOMMAND
20[ "$(ogGetCaller)" == "deployImage" ] || echo -n "" > $OGLOGSESSION;
[d2f28cf]21
22echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
23
[f8f4dfa]24# Procesar parámetros de entrada
[d2f28cf]25REPO="${1^^}"
26IMGNAME="$2"
27DISK="$3"
28PART="$4"
29PROTO="${5^^}"
30PROTO=${PROTO:-"UNICAST"}
31PROTOOPT="$6"
32IMGTYPE="${IMGTYPE:-"img"}"
33# Comprobar que existe la imagen del origen.
34IMGFILE=$(ogGetPath "$REPO" "$IMGNAME.$IMGTYPE") || ogRaiseError $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}" || exit $?
35IMGDIR=$(ogGetParentPath "$REPO" "$IMGNAME") || ogRaiseError $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}" || exit $?
[41d9755]36
[d2f28cf]37# Procesar protocolos de transferencia.
38case "$PROTO" in
39    UNICAST|UNICAST-DIRECT)
40        # Restaurar la imagen.
[7f8d5d5]41        echo "[40] ogRestoreImage $REPO $IMGNAME $DISK $PART UNICAST" | tee -a $OGLOGSESSION $OGLOGFILE
42        ogRestoreImage "$REPO" "$IMGNAME" "$DISK" "$PART" UNICAST 2>&1 | tee -a $OGLOGCOMMAND
[f9e03ad]43        RETVAL=${PIPESTATUS[0]}
[d2f28cf]44        ;;
45    MULTICAST|MULTICAST-DIRECT)
46        PORT=$(echo $PROTOOPT | cut -f1 -d":")
47        TOOL=$(ogGetImageProgram REPO $IMGNAME)
48        COMPRESS=$(ogGetImageCompressor REPO $IMGNAME)
49        #TODO comprobar parametros anteriores
[7f8d5d5]50        echo "[40] ogMcastReceiverPartition $DISK $PART $PORT $TOOL $COMPRESS" | tee -a $OGLOGSESSION $OGLOGFILE
51        ogMcastRequest "$IMGNAME.img" "$PROTOOPT"
52        ogMcastReceiverPartition "$DISK" "$PART" "$PORT" "$TOOL" "$COMPRESS" 2>&1 | tee -a $OGLOGCOMMAND
[f9e03ad]53        RETVAL=${PIPESTATUS[0]}
[d2f28cf]54        ;;
55    *)  # Protocolo desconocido.
56        ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones ]"
57        exit $?
58esac
[b0ff94d]59
[f5432db7]60TIME=$[SECONDS-TIME1]
[7f8d5d5]61echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
[f8f4dfa]62
[f9e03ad]63# Código de salida del comando prinicpal de restauración.
64exit $RETVAL
65
Note: See TracBrowser for help on using the repository browser.