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