source: client/nfsexport/scripts/create-image.sh @ 0d997c6

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 0d997c6 was f5432db7, checked in by ramon <ramongomez@…>, 16 years ago

Leves correcciones en scripts y funciones.

git-svn-id: https://opengnsys.es/svn/trunk@398 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    mv "$IMGFILE" "$IMGFILE.ant"
19fi
20# Mostrar información.
21ogEcho info "$PROG: Origen=$PART, Destino=$IMGFILE"
22
23# Obtener tamaño de la partición.
24SIZE=$(ogGetPartitionSize "$1" "$2")
25# Reducir el sistema de archvios.
26ogEcho info "$PROG: reducir sistema de archivos."
27REDSIZE=$(ogReduceFs $1 $2) || REDSIZE=$[SIZE+1]
28if [ $REDSIZE -lt $SIZE ]; then
29    ogEcho info "$PROG: redimensionar partición a $REDSIZE KB."
30    ogSetPartitionSize $1 $2 $REDSIZE
31fi
32# Crear la imagen.
33ogEcho info "$PROG: Crear imagen."
34ogCreateImage "$@"
35EXITCODE=$?
36# Restaurar tamaño.
37if [ $REDSIZE -lt $SIZE ]; then
38    ogEcho info "$PROG: redimensionar partición a $SIZE KB."
39    ogSetPartitionSize $1 $2 $SIZE
40    ogEcho info "$PROG: extender sistema de archivos."
41    ogExtendFs $1 $2
42fi
43TIME=$[SECONDS-TIME1]
44ogEcho info "$PROG: Duración de la operación $[TIME/60]m $[TIME%60]s"
45exit $EXITCODE
46
Note: See TracBrowser for help on using the repository browser.