source: client/nfsexport/scripts/restoreImage @ 513af22

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

Unificación scripts para ogAdmClient y Browser.

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

  • Property mode set to 100755
File size: 1.7 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 [ $# -ne 4 ]; then
8    ogRaiseError $OG_ERR_FORMAT "Formato: $PROG REPO|CACHE imagen ndisco nparticion"
9    exit $?
10fi
11
12# Iniciación de porcentaje para la barra de progreso del Browser.
13echo "[0,100]"
14echo "[0] $PROG: Origen=$IMGFILE, Destino=$PART"
15
16# Procesar parámetros de entrada
17IMGFILE=$(ogGetPath "$1" "$2.img")
18if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
19    IMGDIR=$(ogGetParentPath "$1" "$2")
20    # Si no existe el directorio de la imagen, crearlo.
21    if [ -z "$IMGDIR" ]; then
22        echo "[5] Creando directorio de imagen \"$1, ${2%/*}\"."
23        ogMakeDir "$1" "${2%/*}" || ogRaiseError $OG_ERR_NOTFOUND "$1, ${2%/*}" || exit $?
24    fi
25    IMGDIR=$(ogGetParentPath "$1" "$2") || ogRaiseError $OG_ERR_NOTFOUND "$1, ${2%/*}" || exit $?
26    if [ -z "$IMGFILE" ]; then
27        echo "[10] Copiando imagen \"$2\" del repositorio a caché local"
28        ogCopyFile "repo" "$2.img" "$IMGDIR" || exit $?
29        IMGFILE=$(ogGetPath "cache" "$2.img")
30    fi
31fi
32if [ -z "$IMGFILE" ]; then
33    ogRaiseError $OG_ERR_NOTFOUND "$1, $2"
34    exit $?
35fi
36PART=$(ogDiskToDev "$3" "$4") || exit $?
37
38# Restaurar la imagen.
39echo "[20] Restaurar imagen"
40ogRestoreImage "$@" || exit $?
41# Restaurar tamaño.
42echo "[80] Extender sistema de archivos."
43ogExtendFs $3 $4
44# Cambiar nombre en sistemas Windows.
45if [ "$(ogGetOsType $3 $4)" = "Windows" ]; then
46    HOST=$(ogGetHostname)
47    HOST=${HOST:-"UNKNOWN"}
48    echo "[90] Cambiar nombre Windows a \"$HOST\"."
49    ogSetWindowsName $3 $4 "$HOST"
50fi
51TIME=$[SECONDS-TIME1]
52echo "[100] Duración de la operación $[TIME/60]m $[TIME%60]s"
53
Note: See TracBrowser for help on using the repository browser.