source: client/shared/scripts/createImage @ 51db584

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 51db584 was 95b340a, checked in by ramon <ramongomez@…>, 14 years ago

Rama version1.0: Variables para valores por defecto en script createImage.

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

  • Property mode set to 100755
File size: 1.8 KB
Line 
1#!/bin/bash
2# createImage - 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 "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen"
9    exit $?
10fi
11
12# Valores por defecto
13IMGPROG="partclone"
14IMGCOMP="lzop"
15IMGEXT="img"
16
17# Si el repositorio es CACHE comprobamos que exista
18if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
19    if ! $(ogFindCache >/dev/null); then
20        ogRaiseError $OG_ERR_NOTFOUND "CACHE"
21        exit $?
22    fi
23fi
24
25# Obtener información de los parámetros de entrada.
26PART=$(ogDiskToDev "$1" "$2") || exit $?
27IMGDIR=$(ogGetParentPath "$3" "/$4")
28# Si no existe, crear subdirectorio de la imagen.
29if [ $? != 0 ]; then
30    echo "[5] Crear subdirectorio de la imagen \"$3 $(dirname "$4")."
31    ogMakeDir "$3" $(dirname "/$4")
32    IMGDIR=$(ogGetParentPath "$3" "/$4") || exit $?
33fi
34IMGFILE=$IMGDIR/$(basename "/$4").$IMGEXT
35# Renombrar el fichero de imagen si ya existe.
36if [ -f "$IMGFILE" ]; then
37    echo "[10] Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"."
38    mv "$IMGFILE" "$IMGFILE.ant"
39    mv "$IMGFILE.torrent" "$IMGFILE.torrent.ant" 2>/dev/null
40fi
41# Mostrar información.
42echo "[15] $PROG: Origen=$PART, Destino=$IMGFILE"
43
44# Comprobar consistencia del sistema de archivos.
45echo "[20] Comprobar sistema de archivos."
46ogUnmount $1 $2
47ogCheckFs $1 $2
48
49echo "[30]: Reducir sistema de archivos."
50ogReduceFs $1 $2 || exit 1
51
52# Crear la imagen.
53echo "[40] Crear imagen."
54ogCreateImage $1 "$2" $3 $4 "$IMGPROG" "$IMGCOMP" || exit $?
55#ogCreateImage $1 "$2" $3 $4 || exit $?
56
57echo "[90] Extender sistema de archivos."
58ogExtendFs $1 $2
59
60TIME=$[SECONDS-TIME1]
61echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
62
Note: See TracBrowser for help on using the repository browser.