source: client/nfsexport/scripts/restoreImage @ 71825d1

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 71825d1 was 41d9755, checked in by ramon <ramongomez@…>, 15 years ago

Pequeñas correcciones en scripts.

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