source: client/nfsexport/scripts/restoreImage @ 57a3d5b

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

Se elimina el parcheo de nombre de usuario de conexión de Windows a la hora de restaurar la imagen. Para modificarlo debe editarse el script restoreImage, descomentando y editando la línea de la función ogSetWinlogonUser.
Close #261.

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

  • Property mode set to 100755
File size: 3.4 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 [ $# -lt 4 ]; then
8    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"
9    exit $?
10fi
11
12# Procesar parámetros de entrada
13IMGTYPE=$(ogGetImageType "$1" "$2")
14IMGFILE=$(ogGetPath "$1" "$2.$IMGTYPE")
15PROTO=${5:-"UNICAST"}
16if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
17    IMGDIR=$(ogGetParentPath "$1" "$2")
18    # Si no existe el directorio de la imagen, crearlo.
19    if [ -z "$IMGDIR" ]; then
20        echo "[5] Creando directorio de imagen \"$1, ${2%/*}\"."
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 $?
24    # Procesar protocolos de transferencia.
25    case "$PROTO" in
26        UNICAST|unicast)
27            # Copiar fichero del repositorio al caché local.
28            IMGTYPE=$(ogGetImageType "repo" "$2")
29            IMGFILE=$(ogGetPath "$1" "$2.$IMGTYPE")
30            if [ -z "$IMGFILE" ] || [ $(ogIsNewerFile "repo" "$2.$IMGTYPE" "$IMGFILE") ]; then
31                echo "[10] Copiando imagen \"$2\" del repositorio a caché local"
32                ogCopyFile "repo" "$2.$IMGTYPE" "$IMGDIR" || exit $?
33                IMGFILE=$(ogGetPath "cache" "$2.$IMGTYPE")
34            fi
35            ;;
36        MULTICAST|multicast)
37            if [ -z "$IMGFILE" ]; then
38                echo "[10] Copiando imagen multicast \"$2\" del repositorio a caché local"
39                IMGTYPE=$(ogGetImageType "repo" "$2")
40                PORTBASE=`echo $6 | cut -f1 -d:`
41                echo "ogMcastReceiverFile SOURCE:$PORTBASE TARGET:CACHE $2.$IMGTYPE"
42                ogMcastReceiverFile "$PORTBASE" "CACHE" "$2.$IMGTYPE" || exit $?
43                IMGFILE=$(ogGetPath "cache" "$2.$IMGTYPE")
44            fi
45            ;;
46        TORRENT|torrent)
47                echo "[9] copiando el fichero torrent Unicast \"$2\" del repositorio a caché local"
48                IMGTYPE=$(ogGetImageType "repo" "$2")
49                ogCopyFile "repo" "$2.$IMGTYPE.torrent" "$IMGDIR" || exit $?
50                echo "[10] descargando imagen torrent($6) \"$2\" del repositorio a caché local"
51                ogTorrentStart "CACHE" "$2.$IMGTYPE.torrent" "peer:60" || exit $?                       
52                IMGFILE=$(ogGetPath "cache" "$2.$IMGTYPE")           
53            ;;
54        *)  # Protocolo desconocido.
55            ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT opciones ]"
56            exit $?
57    esac
58fi
59if [ -z "$IMGFILE" ]; then
60    ogRaiseError $OG_ERR_NOTFOUND "$1, $2"
61    exit $?
62fi
63PART=$(ogDiskToDev "$3" "$4") || exit $?
64
65# Restaurar la imagen.
66echo "[40] Restaurar imagen en $PART"
67ogRestoreImage "$@" || exit $?
68# Restaurar tamaño.
69echo "[80] Extender sistema de archivos."
70ogExtendFs $3 $4
71# Cambiar nombre en sistemas Windows y quitar usuario de acceso por defecto.
72if [ "$(ogGetOsType $3 $4)" = "Windows" ]; then
73    HOST=$(ogGetHostname)
74    HOST=${HOST:-"pc"}
75    echo "[90] Cambiar nombre Windows a \"$HOST\" y usuario de acceso."
76    ogSetWindowsName $3 $4 "$HOST"
77    #ogSetWinlogonUser $3 $4 " "        # Descomentar para cambiar usuario de inicio.
78fi
79TIME=$[SECONDS-TIME1]
80echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
81
Note: See TracBrowser for help on using the repository browser.