source: client/shared/scripts/restoreImage @ 6903f32

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 6903f32 was b0ff94d, checked in by ramon <ramongomez@…>, 14 years ago

Versión 1.0.2: Correcciones en scripts de arranque y restauración:

  • bootOs - elimina las marcas de Windows (arranque con varios Windows instalados).
  • bootLinux y bootWindows - son enlaces simbólicos de bootOs (posible eliminación).
  • restoreImage - llama a configureOs para proceso de postconfiguración.

Cerrar ticket #444.

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

  • Property mode set to 100755
File size: 3.4 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
[bba08bf]8    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"
[f8f4dfa]9    exit $?
10fi
11
12# Procesar parámetros de entrada
[914d834]13IMGTYPE="img"
[0fbc05e]14IMGFILE=$(ogGetPath "$1" "$2.$IMGTYPE")
[87a7a799]15PROTO=${5:-"UNICAST"}
[e42f34e]16if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
[c7d9af7]17    IMGDIR=$(ogGetParentPath "$1" "$2")
18    # Si no existe el directorio de la imagen, crearlo.
[b9a5881]19    if [ -z "$IMGDIR" ]; then
[180a07dd]20        echo "[5] Creando directorio de imagen \"$1, ${2%/*}\"."
[c7d9af7]21        ogMakeDir "$1" "${2%/*}" || ogRaiseError $OG_ERR_NOTFOUND "$1, ${2%/*}" || exit $?
22    fi
23    IMGDIR=$(ogGetParentPath "$1" "$2") || ogRaiseError $OG_ERR_NOTFOUND "$1, ${2%/*}" || exit $?
[87a7a799]24    # Procesar protocolos de transferencia.
25    case "$PROTO" in
26        UNICAST|unicast)
[0fbc05e]27            # Copiar fichero del repositorio al caché local.
[914d834]28            #IMGTYPE=$(ogGetImageType "repo" "$2")
[9c81eb1e]29            IMGFILE=$(ogGetPath "cache" "$2.$IMGTYPE")
[0fbc05e]30            if [ -z "$IMGFILE" ] || [ $(ogIsNewerFile "repo" "$2.$IMGTYPE" "$IMGFILE") ]; then
31                echo "[10] Copiando imagen \"$2\" del repositorio a caché local"
[9c81eb1e]32                ogCopyFile "repo" "$2.$IMGTYPE" "$IMGDIR"
33            fi
34            # Comprobar si existe el fichero en caché y no en el repositorio.
35            if [ -z "$IMGFILE" ]; then
[914d834]36                #IMGTYPE=$(ogGetImageType "cache" "$2")
[0fbc05e]37                IMGFILE=$(ogGetPath "cache" "$2.$IMGTYPE")
[9c81eb1e]38                if [ -z "$IMGFILE" ]; then
39                    ogRaiseError $OG_ERR_NOTFOUND "cache, $2.$IMGTYPE"
40                    exit $?
41                fi
[87a7a799]42            fi
43            ;;
44        MULTICAST|multicast)
[bba08bf]45            if [ -z "$IMGFILE" ]; then
[0fbc05e]46                echo "[10] Copiando imagen multicast \"$2\" del repositorio a caché local"
[914d834]47                                #IMGTYPE=$(ogGetImageType "repo" "$2")
[0fbc05e]48                PORTBASE=`echo $6 | cut -f1 -d:`
49                echo "ogMcastReceiverFile SOURCE:$PORTBASE TARGET:CACHE $2.$IMGTYPE"
50                ogMcastReceiverFile "$PORTBASE" "CACHE" "$2.$IMGTYPE" || exit $?
51                IMGFILE=$(ogGetPath "cache" "$2.$IMGTYPE")
[bba08bf]52            fi
[87a7a799]53            ;;
54        TORRENT|torrent)
[0fbc05e]55                echo "[9] copiando el fichero torrent Unicast \"$2\" del repositorio a caché local"
[914d834]56                #IMGTYPE=$(ogGetImageType "repo" "$2")
[0fbc05e]57                ogCopyFile "repo" "$2.$IMGTYPE.torrent" "$IMGDIR" || exit $?
58                echo "[10] descargando imagen torrent($6) \"$2\" del repositorio a caché local"
59                ogTorrentStart "CACHE" "$2.$IMGTYPE.torrent" "peer:60" || exit $?                       
60                IMGFILE=$(ogGetPath "cache" "$2.$IMGTYPE")           
[87a7a799]61            ;;
62        *)  # Protocolo desconocido.
63            ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT opciones ]"
64            exit $?
65    esac
[c7d9af7]66fi
67if [ -z "$IMGFILE" ]; then
68    ogRaiseError $OG_ERR_NOTFOUND "$1, $2"
69    exit $?
[e42f34e]70fi
[f8f4dfa]71PART=$(ogDiskToDev "$3" "$4") || exit $?
[41d9755]72
[f8f4dfa]73# Restaurar la imagen.
[0fbc05e]74echo "[40] Restaurar imagen en $PART"
[1c04494]75ogRestoreImage "$@" || exit $?
[f8f4dfa]76# Restaurar tamaño.
[180a07dd]77echo "[80] Extender sistema de archivos."
[f5432db7]78ogExtendFs $3 $4
[b0ff94d]79# Llamar al script de post-configuración del sistema operativo.
80echo "[90] Post-configuracion de aranque del sistema."
81configureOs $3 $4
82
[f5432db7]83TIME=$[SECONDS-TIME1]
[bfeb89a]84echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
[f8f4dfa]85
Note: See TracBrowser for help on using the repository browser.