source: client/nfsexport/scripts/create-image.sh @ 9a2cda1e

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 9a2cda1e was c7d9af7, checked in by ramon <ramongomez@…>, 16 years ago

NTFS: formatear; FAT 12/16/32: comprobar y formatear; retoques en scripts.

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

  • Property mode set to 100755
File size: 1.5 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 "Formato: $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") || exit $?
15IMGFILE="$IMGDIR/$(basename $4).img"
16# Renombrar el fichero de imagen si ya existe.
17if [ -f "$IMGFILE" ]; then
18    ogEcho info "Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"."
19    mv "$IMGFILE" "$IMGFILE.ant"
20fi
21# Mostrar información.
22ogEcho info "$PROG: Origen=$PART, Destino=$IMGFILE"
23
24# Obtener tamaño de la partición.
25SIZE=$(ogGetPartitionSize "$1" "$2")
26# Reducir el sistema de archvios.
27ogEcho info "$PROG: reducir sistema de archivos."
28REDSIZE=$(ogReduceFs $1 $2) || REDSIZE=$[SIZE+1]
29if [ $REDSIZE -lt $SIZE ]; then
30    ogEcho info "$PROG: redimensionar partición a $REDSIZE KB."
31    ogSetPartitionSize $1 $2 $REDSIZE
32fi
33# Crear la imagen.
34ogEcho info "$PROG: Crear imagen."
35ogCreateImage "$@"
36EXITCODE=$?
37# Restaurar tamaño.
38if [ $REDSIZE -lt $SIZE ]; then
39    ogEcho info "$PROG: redimensionar partición a $SIZE KB."
40    ogSetPartitionSize $1 $2 $SIZE
41    ogEcho info "$PROG: extender sistema de archivos."
42    ogExtendFs $1 $2
43fi
44TIME=$[SECONDS-TIME1]
45ogEcho info "$PROG: Duración de la operación $[TIME/60]m $[TIME%60]s"
46exit $EXITCODE
47
Note: See TracBrowser for help on using the repository browser.