source: client/shared/scripts/restoreImage @ d473bb92

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 d473bb92 was d2f28cf, checked in by ramon <ramongomez@…>, 12 years ago

#537 #533: Integrar código del ticket:337 en rama de versión.

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

  • Property mode set to 100755
File size: 2.3 KB
Line 
1#!/bin/bash
2# Scirpt de ejemplo para restaurar una imagen.
3# (puede usarse como base para el programa de restauración de imágenes usado por OpenGNSys Admin).
4
5TIME1=$SECONDS
6PROG="$(basename $0)"
7if [ $# -lt 4 ]; then
8    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones protocolo]"
9    exit $?
10fi
11
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
19echo " " > $OGLOGSESSION; echo " " > $OGLOGCOMMAND; echo " " > ${OGLOGCOMMAND}.tmp
20
21echo "[1] $MSG_SCRIPTS_START $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
22
23# Procesar parámetros de entrada
24REPO="${1^^}"
25IMGNAME="$2"
26DISK="$3"
27PART="$4"
28PROTO="${5^^}"
29PROTO=${PROTO:-"UNICAST"}
30PROTOOPT="$6"
31IMGTYPE="${IMGTYPE:-"img"}"
32# Comprobar que existe la imagen del origen.
33IMGFILE=$(ogGetPath "$REPO" "$IMGNAME.$IMGTYPE") || ogRaiseError $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}" || exit $?
34IMGDIR=$(ogGetParentPath "$REPO" "$IMGNAME") || ogRaiseError $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}" || exit $?
35
36# Procesar protocolos de transferencia.
37case "$PROTO" in
38    UNICAST|UNICAST-DIRECT)
39        # Restaurar la imagen.
40        echo "[40] ogRestoreImage $REPO $IMGNAME $DISK $PART UNICAST"
41        ogRestoreImage "$REPO" "$IMGNAME" "$DISK" "$PART" UNICAST | tee -a $OGLOGCOMMAND  || exit $?
42        ;;
43    MULTICAST|MULTICAST-DIRECT)
44        PORT=$(echo $PROTOOPT | cut -f1 -d":")
45        TOOL=$(ogGetImageProgram REPO $IMGNAME)
46        COMPRESS=$(ogGetImageCompressor REPO $IMGNAME)
47        #TODO comprobar parametros anteriores
48        ogMcastRequest "$IMGNAME.img" "$PROTOOPT"
49        ogMcastReceiverPartition "$DISK" "$PART" "$PORT" "$TOOL" "$COMPRESS" | tee -a $OGLOGCOMMAND
50        RETVAL=$?
51        ;;
52    *)  # Protocolo desconocido.
53        ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones ]"
54        exit $?
55esac
56
57TIME=$[SECONDS-TIME1]
58echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
59
Note: See TracBrowser for help on using the repository browser.