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
Rev | Line | |
---|
[f8f4dfa] | 1 | #!/bin/bash |
---|
[c40a6b4] | 2 | # create-image.sh - Scirpt de ejemplo para crear una imagen de un sistema de archivos. |
---|
[f8f4dfa] | 3 | # (puede usarse como base para el programa de creación de imágenes usado por OpenGNSys Admin). |
---|
| 4 | |
---|
[f5432db7] | 5 | TIME1=$SECONDS |
---|
[f8f4dfa] | 6 | PROG="$(basename $0)" |
---|
| 7 | if [ $# -ne 4 ]; then |
---|
| 8 | ogRaiseError $OG_ERR_FORMAT "Formato: $PROG ndisco nparticion REPO|CACHE imagen" |
---|
| 9 | exit $? |
---|
| 10 | fi |
---|
| 11 | |
---|
[c40a6b4] | 12 | # Obtener información de los parámetros de entrada. |
---|
[f8f4dfa] | 13 | PART=$(ogDiskToDev "$1" "$2") || exit $? |
---|
| 14 | IMGDIR=$(ogGetParentPath "$3" "$4") || exit $? |
---|
| 15 | IMGFILE="$IMGDIR/$(basename $4).img" |
---|
| 16 | # Renombrar el fichero de imagen si ya existe. |
---|
| 17 | if [ -f "$IMGFILE" ]; then |
---|
[c7d9af7] | 18 | ogEcho info "Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"." |
---|
[f8f4dfa] | 19 | mv "$IMGFILE" "$IMGFILE.ant" |
---|
| 20 | fi |
---|
| 21 | # Mostrar información. |
---|
| 22 | ogEcho info "$PROG: Origen=$PART, Destino=$IMGFILE" |
---|
| 23 | |
---|
| 24 | # Obtener tamaño de la partición. |
---|
[c40a6b4] | 25 | SIZE=$(ogGetPartitionSize "$1" "$2") |
---|
[f8f4dfa] | 26 | # Reducir el sistema de archvios. |
---|
[1c04494] | 27 | ogEcho info "$PROG: reducir sistema de archivos." |
---|
[f8f4dfa] | 28 | REDSIZE=$(ogReduceFs $1 $2) || REDSIZE=$[SIZE+1] |
---|
[c40a6b4] | 29 | if [ $REDSIZE -lt $SIZE ]; then |
---|
[1c04494] | 30 | ogEcho info "$PROG: redimensionar partición a $REDSIZE KB." |
---|
[c40a6b4] | 31 | ogSetPartitionSize $1 $2 $REDSIZE |
---|
| 32 | fi |
---|
[f8f4dfa] | 33 | # Crear la imagen. |
---|
[1c04494] | 34 | ogEcho info "$PROG: Crear imagen." |
---|
[c40a6b4] | 35 | ogCreateImage "$@" |
---|
| 36 | EXITCODE=$? |
---|
[f8f4dfa] | 37 | # Restaurar tamaño. |
---|
[c40a6b4] | 38 | if [ $REDSIZE -lt $SIZE ]; then |
---|
[1c04494] | 39 | ogEcho info "$PROG: redimensionar partición a $SIZE KB." |
---|
[c40a6b4] | 40 | ogSetPartitionSize $1 $2 $SIZE |
---|
[1c04494] | 41 | ogEcho info "$PROG: extender sistema de archivos." |
---|
[c40a6b4] | 42 | ogExtendFs $1 $2 |
---|
| 43 | fi |
---|
[f5432db7] | 44 | TIME=$[SECONDS-TIME1] |
---|
| 45 | ogEcho info "$PROG: Duración de la operación $[TIME/60]m $[TIME%60]s" |
---|
[c40a6b4] | 46 | exit $EXITCODE |
---|
[f8f4dfa] | 47 | |
---|
Note: See
TracBrowser
for help on using the repository browser.