source:
client/nfsexport/scripts/restoreImage
@
893e63fe
Last change on this file since 893e63fe was be85bb2, checked in by , 15 years ago | |
---|---|
|
|
File size: 1.7 KB |
Rev | Line | |
---|---|---|
[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] | 5 | TIME1=$SECONDS |
[f8f4dfa] | 6 | PROG="$(basename $0)" |
7 | if [ $# -ne 4 ]; then | |
[be85bb2] | 8 | ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion" |
[f8f4dfa] | 9 | exit $? |
10 | fi | |
11 | ||
[180a07dd] | 12 | echo "[0] $PROG: Origen=$IMGFILE, Destino=$PART" |
13 | ||
[f8f4dfa] | 14 | # Procesar parámetros de entrada |
[c7d9af7] | 15 | IMGFILE=$(ogGetPath "$1" "$2.img") |
[e42f34e] | 16 | if [ "$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 $? | |
[e42f34e] | 24 | if [ -z "$IMGFILE" ]; then |
[180a07dd] | 25 | echo "[10] Copiando imagen \"$2\" del repositorio a caché local" |
[c7d9af7] | 26 | ogCopyFile "repo" "$2.img" "$IMGDIR" || exit $? |
27 | IMGFILE=$(ogGetPath "cache" "$2.img") | |
[e42f34e] | 28 | fi |
[c7d9af7] | 29 | fi |
30 | if [ -z "$IMGFILE" ]; then | |
31 | ogRaiseError $OG_ERR_NOTFOUND "$1, $2" | |
32 | exit $? | |
[e42f34e] | 33 | fi |
[f8f4dfa] | 34 | PART=$(ogDiskToDev "$3" "$4") || exit $? |
35 | ||
36 | # Restaurar la imagen. | |
[180a07dd] | 37 | echo "[20] Restaurar imagen" |
[1c04494] | 38 | ogRestoreImage "$@" || exit $? |
[f8f4dfa] | 39 | # Restaurar tamaño. |
[180a07dd] | 40 | echo "[80] Extender sistema de archivos." |
[f5432db7] | 41 | ogExtendFs $3 $4 |
[1c04494] | 42 | # Cambiar nombre en sistemas Windows. |
[9fb5086] | 43 | if [ "$(ogGetOsType $3 $4)" = "Windows" ]; then |
44 | HOST=$(ogGetHostname) | |
45 | HOST=${HOST:-"UNKNOWN"} | |
[180a07dd] | 46 | echo "[90] Cambiar nombre Windows a \"$HOST\"." |
[f5432db7] | 47 | ogSetWindowsName $3 $4 "$HOST" |
[1c04494] | 48 | fi |
[f5432db7] | 49 | TIME=$[SECONDS-TIME1] |
[180a07dd] | 50 | echo "[100] Duración de la operación $[TIME/60]m $[TIME%60]s" |
[f8f4dfa] | 51 |
Note: See TracBrowser
for help on using the repository browser.