source: client/nfsexport/scripts/createImage @ f4b737d

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 f4b737d was 51553f0, checked in by adv <adv@…>, 15 years ago

trunk createImage: corrección, confusión test

git-svn-id: https://opengnsys.es/svn/trunk@956 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.2 KB
RevLine 
[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]5TIME1=$SECONDS
[f8f4dfa]6PROG="$(basename $0)"
7if [ $# -ne 4 ]; then
[be85bb2]8    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen"
[f8f4dfa]9    exit $?
10fi
11
[defcdab]12# Si el repositorio es CACHE comprobamos que exista
[51553f0]13[ $3 == "REPO" -o $3 == "repo" ] || `ogFindCache >/dev/null` || ogRaiseError $OG_ERR_NOTFOUND "CACHE"|| exit $?
[defcdab]14
15
[c40a6b4]16# Obtener información de los parámetros de entrada.
[f8f4dfa]17PART=$(ogDiskToDev "$1" "$2") || exit $?
[a3fb8b2]18IMGDIR=$(ogGetParentPath "$3" "/$4")
[180a07dd]19# Si no existe, crear subdirectorio de la imagen.
20if [ $? != 0 ]; then
21    echo "[5] Crear subdirectorio de la imagen \"$3 $(dirname "$4")."
[a3fb8b2]22    ogMakeDir "$3" $(dirname "/$4")
23    IMGDIR=$(ogGetParentPath "$3" "/$4") || exit $?
[180a07dd]24fi
[a3fb8b2]25IMGFILE=$IMGDIR/$(basename "/$4").img
[f8f4dfa]26# Renombrar el fichero de imagen si ya existe.
27if [ -f "$IMGFILE" ]; then
[180a07dd]28    echo "[10] Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"."
[f8f4dfa]29    mv "$IMGFILE" "$IMGFILE.ant"
30fi
[41d9755]31# Mostrar información.
32echo "[15] $PROG: Origen=$PART, Destino=$IMGFILE"
[f8f4dfa]33
34# Obtener tamaño de la partición.
[c40a6b4]35SIZE=$(ogGetPartitionSize "$1" "$2")
[f8f4dfa]36# Reducir el sistema de archvios.
[41d9755]37echo "[20]: Reducir sistema de archivos."
[f8f4dfa]38REDSIZE=$(ogReduceFs $1 $2) || REDSIZE=$[SIZE+1]
[c40a6b4]39if [ $REDSIZE -lt $SIZE ]; then
[180a07dd]40    echo "[25] Redimensionar partición a $REDSIZE KB."
[c40a6b4]41    ogSetPartitionSize $1 $2 $REDSIZE
42fi
[f8f4dfa]43# Crear la imagen.
[180a07dd]44echo "[40] Crear imagen."
[defcdab]45#ejemplo test herramienta de clonacion
46#ogCreateImage "$@" partclone lzop
[c40a6b4]47ogCreateImage "$@"
48EXITCODE=$?
[f8f4dfa]49# Restaurar tamaño.
[c40a6b4]50if [ $REDSIZE -lt $SIZE ]; then
[180a07dd]51    echo "[85] Redimensionar partición a $SIZE KB."
[c40a6b4]52    ogSetPartitionSize $1 $2 $SIZE
[180a07dd]53    echo "[90] Extender sistema de archivos."
[c40a6b4]54    ogExtendFs $1 $2
55fi
[defcdab]56
57# Creamos fichero torrent. si REPO tracker=ipREPO, si CACHE tracker=ipLocal
58[ "$3" == "REPO" ] && IPTORRENT=`mount | grep ":/opt/opengnsys/images" | cut -f1 -d:` \
59           || IPTORRENT=`ogGetIpAddress`
60echo "[95] Crear torrent $3 $4 $IPTORRENT"
61ogCreateTorrent "$3" "$4" "$IPTORRENT"
62
[f5432db7]63TIME=$[SECONDS-TIME1]
[180a07dd]64echo "[100] Duración de la operación $[TIME/60]m $[TIME%60]s"
[c40a6b4]65exit $EXITCODE
[f8f4dfa]66
Note: See TracBrowser for help on using the repository browser.