source: client/shared/scripts/createImage @ 9e63173

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 9e63173 was eb9424f, checked in by ramon <ramongomez@…>, 14 years ago

branches/version1.0: aplicar cambios de la rama trunk para desarrollar version 1.0.1

git-svn-id: https://opengnsys.es/svn/branches/version1.0@1920 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.4 KB
Line 
1#!/bin/bash
2
3#/**
4#         createImage
5#@brief   Scirpt de ejemplo para crear una imagen de un sistema de archivos.
6#@brief (puede usarse como base para el programa de creación de imágenes usado por OpenGnSys Admin).
7#@param 1 disco
8#@param 2 particion
9#@param 3 REPO|CACHE
10#@param 4 imagen
11#@return 
12#@exception OG_ERR_FORMAT     formato incorrecto.
13#@exception OG_ERR_NOTCACHE   #si cache no existe.
14#@exception OG_ERR_REDUCEFS     #error al reducir sistema de archivos.
15#@exception OG_ERR_EXTENDFS     #errror al expandir el sistema de archivos.
16#@note   
17#@todo:
18#@version 1.0 - control de errores para el ogAdmServer
19#@author 
20#@date   
21#*/ ##
22
23
24
25TIME1=$SECONDS
26PROG="$(basename $0)"
27if [ $# -ne 4 ]; then
28    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen"
29    exit $?
30fi
31
32# Valores por defecto
33IMGPROG="partclone"
34IMGCOMP="lzop"
35IMGEXT="img"
36
37# Si el repositorio es CACHE comprobamos que exista
38if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
39    if ! $(ogFindCache >/dev/null); then
40        ogRaiseError $OG_ERR_NOTCACHE "$MSG_ERR_NOTCACHE"
41        exit $?
42    fi
43fi
44
45# Obtener información de los parámetros de entrada.
46PART=$(ogDiskToDev "$1" "$2") || exit $?
47IMGDIR=$(ogGetParentPath "$3" "/$4")
48# Si no existe, crear subdirectorio de la imagen.
49if [ $? != 0 ]; then
50    echo "[5] Crear subdirectorio de la imagen \"$3 $(dirname "$4")."
51    ogMakeDir "$3" $(dirname "/$4")
52    IMGDIR=$(ogGetParentPath "$3" "/$4") || exit $?
53fi
54IMGFILE=$IMGDIR/$(basename "/$4").$IMGEXT
55# Renombrar el fichero de imagen si ya existe.
56if [ -f "$IMGFILE" ]; then
57    echo "[10] Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"."
58    mv "$IMGFILE" "$IMGFILE.ant"
59    mv "$IMGFILE.torrent" "$IMGFILE.torrent.ant" 2>/dev/null
60fi
61# Mostrar información.
62echo "[15] $PROG: Origen=$PART, Destino=$IMGFILE"
63
64# Comprobar consistencia del sistema de archivos.
65echo "[20] Comprobar sistema de archivos."
66ogUnmount $1 $2
67ogCheckFs $1 $2
68
69echo "[30]: Reducir sistema de archivos."
70ogReduceFs $1 $2 || $(ogRaiseError $OG_ERR_REDUCEFS "$1 $2"; exit $?)
71
72# Crear la imagen.
73echo "[40] Crear imagen."
74ogCreateImage $1 "$2" $3 $4 "$IMGPROG" "$IMGCOMP" || exit $?
75#ogCreateImage $1 "$2" $3 $4 || exit $?
76
77echo "[90] Extender sistema de archivos."
78ogExtendFs $1 $2 || $(ogRaiseError $OG_ERR_EXTENDFS "$1 $2"; exit $?)
79
80
81TIME=$[SECONDS-TIME1]
82echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
83
Note: See TracBrowser for help on using the repository browser.