source: client/nfsexport/scripts/create-image.sh @ 397751b

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 397751b was 1c04494, checked in by ramon <ramongomez@…>, 16 years ago

Correcciones en scripts; metafunción ogGetOsType.

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

  • Property mode set to 100755
File size: 1.3 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
5PROG="$(basename $0)"
6if [ $# -ne 4 ]; then
7    ogRaiseError $OG_ERR_FORMAT "Formato: $PROG ndisco nparticion REPO|CACHE imagen"
8    exit $?
9fi
10
11# Obtener información de los parámetros de entrada.
12PART=$(ogDiskToDev "$1" "$2") || exit $?
13IMGDIR=$(ogGetParentPath "$3" "$4") || exit $?
14IMGFILE="$IMGDIR/$(basename $4).img"
15# Renombrar el fichero de imagen si ya existe.
16if [ -f "$IMGFILE" ]; then
17    mv "$IMGFILE" "$IMGFILE.ant"
18fi
19# Mostrar información.
20ogEcho info "$PROG: Origen=$PART, Destino=$IMGFILE"
21
22# Obtener tamaño de la partición.
23SIZE=$(ogGetPartitionSize "$1" "$2")
24# Reducir el sistema de archvios.
25ogEcho info "$PROG: reducir sistema de archivos."
26REDSIZE=$(ogReduceFs $1 $2) || REDSIZE=$[SIZE+1]
27if [ $REDSIZE -lt $SIZE ]; then
28    ogEcho info "$PROG: redimensionar partición a $REDSIZE KB."
29    ogSetPartitionSize $1 $2 $REDSIZE
30fi
31# Crear la imagen.
32ogEcho info "$PROG: Crear imagen."
33ogCreateImage "$@"
34EXITCODE=$?
35# Restaurar tamaño.
36if [ $REDSIZE -lt $SIZE ]; then
37    ogEcho info "$PROG: redimensionar partición a $SIZE KB."
38    ogSetPartitionSize $1 $2 $SIZE
39    ogEcho info "$PROG: extender sistema de archivos."
40    ogExtendFs $1 $2
41fi
42exit $EXITCODE
43
Note: See TracBrowser for help on using the repository browser.