source: client/nfsexport/scripts/createImage @ 513af22

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

Unificación scripts para ogAdmClient y Browser.

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