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