source: client/nfsexport/scripts/restoreImage @ bf1840e9

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 bf1840e9 was 87a7a799, checked in by ramon <ramongomez@…>, 15 years ago

Script restoreImage preparado para nuevos protocolos de clonación; corregir librería dinámcia para partprobe en el Initrd del cliente.

git-svn-id: https://opengnsys.es/svn/trunk@926 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.3 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
8    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT opciones ]"
[f8f4dfa]9    exit $?
10fi
11
12# Procesar parámetros de entrada
[c7d9af7]13IMGFILE=$(ogGetPath "$1" "$2.img")
[87a7a799]14PROTO=${5:-"UNICAST"}
[e42f34e]15if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
[c7d9af7]16    IMGDIR=$(ogGetParentPath "$1" "$2")
17    # Si no existe el directorio de la imagen, crearlo.
[b9a5881]18    if [ -z "$IMGDIR" ]; then
[180a07dd]19        echo "[5] Creando directorio de imagen \"$1, ${2%/*}\"."
[c7d9af7]20        ogMakeDir "$1" "${2%/*}" || ogRaiseError $OG_ERR_NOTFOUND "$1, ${2%/*}" || exit $?
21    fi
22    IMGDIR=$(ogGetParentPath "$1" "$2") || ogRaiseError $OG_ERR_NOTFOUND "$1, ${2%/*}" || exit $?
[87a7a799]23    # Procesar protocolos de transferencia.
24    case "$PROTO" in
25        UNICAST|unicast)
26            # Copiar fichero del repositorio al caché local.
27            if [ -z "$IMGFILE" ]; then
28                echo "[10] Copiando imagen \"$2\" del repositorio a caché local"
29                ogCopyFile "repo" "$2.img" "$IMGDIR" || exit $?
30                IMGFILE=$(ogGetPath "cache" "$2.img")
31            fi
32            ;;
33        MULTICAST|multicast)
34            # Proceso Multicast.
35            ;;
36        TORRENT|torrent)
37            # Proceso Torrent.
38            ;;
39        *)  # Protocolo desconocido.
40            ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT opciones ]"
41            exit $?
42    esac
[c7d9af7]43fi
44if [ -z "$IMGFILE" ]; then
45    ogRaiseError $OG_ERR_NOTFOUND "$1, $2"
46    exit $?
[e42f34e]47fi
[f8f4dfa]48PART=$(ogDiskToDev "$3" "$4") || exit $?
[41d9755]49echo "[20] $PROG: Origen=$IMGFILE, Destino=$PART"
50
[f8f4dfa]51
52# Restaurar la imagen.
[41d9755]53echo "[25] Restaurar imagen"
[1c04494]54ogRestoreImage "$@" || exit $?
[f8f4dfa]55# Restaurar tamaño.
[180a07dd]56echo "[80] Extender sistema de archivos."
[f5432db7]57ogExtendFs $3 $4
[1c04494]58# Cambiar nombre en sistemas Windows.
[9fb5086]59if [ "$(ogGetOsType $3 $4)" = "Windows" ]; then
60    HOST=$(ogGetHostname)
61    HOST=${HOST:-"UNKNOWN"}
[180a07dd]62    echo "[90] Cambiar nombre Windows a \"$HOST\"."
[f5432db7]63    ogSetWindowsName $3 $4 "$HOST"
[1c04494]64fi
[f5432db7]65TIME=$[SECONDS-TIME1]
[180a07dd]66echo "[100] Duración de la operación $[TIME/60]m $[TIME%60]s"
[f8f4dfa]67
Note: See TracBrowser for help on using the repository browser.