source: client/nfsexport/scripts/createImage @ 0e39905

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

Solucionado problema con función ogGetParentPath, errata en instalador y script createImage para Consola Web.

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

  • Property mode set to 100755
File size: 1.7 KB
RevLine 
[f8f4dfa]1#!/bin/bash
[c40a6b4]2# create-image.sh - Scirpt de ejemplo para crear una imagen de un sistema de archivos.
[f8f4dfa]3# (puede usarse como base para el programa de creación de imágenes usado por OpenGNSys Admin).
4
[f5432db7]5TIME1=$SECONDS
[f8f4dfa]6PROG="$(basename $0)"
7if [ $# -ne 4 ]; then
[be85bb2]8    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen"
[f8f4dfa]9    exit $?
10fi
11
[180a07dd]12# Mostrar información.
13echo "[0] $PROG: Origen=$PART, Destino=$IMGFILE"
14
[c40a6b4]15# Obtener información de los parámetros de entrada.
[f8f4dfa]16PART=$(ogDiskToDev "$1" "$2") || exit $?
[a3fb8b2]17IMGDIR=$(ogGetParentPath "$3" "/$4")
[180a07dd]18# Si no existe, crear subdirectorio de la imagen.
19if [ $? != 0 ]; then
20    echo "[5] Crear subdirectorio de la imagen \"$3 $(dirname "$4")."
[a3fb8b2]21    ogMakeDir "$3" $(dirname "/$4")
22    IMGDIR=$(ogGetParentPath "$3" "/$4") || exit $?
[180a07dd]23fi
[a3fb8b2]24IMGFILE=$IMGDIR/$(basename "/$4").img
[f8f4dfa]25# Renombrar el fichero de imagen si ya existe.
26if [ -f "$IMGFILE" ]; then
[180a07dd]27    echo "[10] Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"."
[f8f4dfa]28    mv "$IMGFILE" "$IMGFILE.ant"
29fi
30
31# Obtener tamaño de la partición.
[c40a6b4]32SIZE=$(ogGetPartitionSize "$1" "$2")
[f8f4dfa]33# Reducir el sistema de archvios.
[180a07dd]34echo "[15]: Reducir sistema de archivos."
[f8f4dfa]35REDSIZE=$(ogReduceFs $1 $2) || REDSIZE=$[SIZE+1]
[c40a6b4]36if [ $REDSIZE -lt $SIZE ]; then
[180a07dd]37    echo "[25] Redimensionar partición a $REDSIZE KB."
[c40a6b4]38    ogSetPartitionSize $1 $2 $REDSIZE
39fi
[f8f4dfa]40# Crear la imagen.
[180a07dd]41echo "[40] Crear imagen."
[c40a6b4]42ogCreateImage "$@"
43EXITCODE=$?
[f8f4dfa]44# Restaurar tamaño.
[c40a6b4]45if [ $REDSIZE -lt $SIZE ]; then
[180a07dd]46    echo "[85] Redimensionar partición a $SIZE KB."
[c40a6b4]47    ogSetPartitionSize $1 $2 $SIZE
[180a07dd]48    echo "[90] Extender sistema de archivos."
[c40a6b4]49    ogExtendFs $1 $2
50fi
[f5432db7]51TIME=$[SECONDS-TIME1]
[180a07dd]52echo "[100] Duración de la operación $[TIME/60]m $[TIME%60]s"
[c40a6b4]53exit $EXITCODE
[f8f4dfa]54
Note: See TracBrowser for help on using the repository browser.