source: server/bin/createfileimage @ bc3a350

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 bc3a350 was 0109c07, checked in by irina <irinagomez@…>, 11 years ago

#565 se crean script: partclone2sync y clean-mountdirimage. Se controla el error al crear la imagen.

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

  • Property mode set to 100755
File size: 1.8 KB
Line 
1#!/bin/bash
2#/**
3#       createtimage
4#@brief  Crea o redimensiona el archivo de la imagen.
5#@param 1 imagen
6#@param 2 extension [ img|diff ]
7#@param 3 tamaño de la imagen en kb.
8#@return 
9#@exception OG_ERR_FORMAT     # 1 formato incorrecto.
10#@exception OG_ERR_DONTSYNC_IMAGE  #71 Imagen no sincronizable (es monolitica)
11#@version 1.0 - Montar imagen sincronizable
12#@author  Irina Gomez
13#@date   2013-05-23
14#*/ ##
15BASEDIR=/opt/opengnsys
16REPODIR="$BASEDIR/images"
17REPOLOG=$BASEDIR/log/ogAdmRepo.log
18source $BASEDIR/client/etc/lang.$LANG.conf
19
20PROG="$(basename $0)"
21# Si se solicita, mostrar ayuda.
22if [ "$*" == "help" ]; then
23    echo -e " $PROG: $MSG_HELP_ogCreateFileImage \n" \
24            "$MSG_FORMAT: $PROG image [ img|diff ] size_kb \n" \
25            "base -> $PROG Windows7 img 3900000 \n" \
26            "diff -> $PROG Ubuntu12 diff 450000"
27   exit 0
28fi
29
30[ $# -lt 3 ] && echo -e "$PROG: Error: $MSG_ERR_FORMAT \n     $MSG_FORMAT: $PROG image [ img | diff ]  size_Kb "  && exit 1
31
32if [ "$USER" != "root" ]; then
33        echo "$PROG: Error: solo ejecutable por root" >&2
34        exit 1
35fi
36
37IMGEXT="$2"
38
39# Si existe imagen, Comprobamos que no esta bloqueada y que es sincronizable
40IMGFILE="$REPODIR/$1.$IMGEXT"
41if [ -f $IMGFILE ]; then
42   [ -f $IMGFILE.lock ] && echo "$PROG: Error: $MSG_ERR_LOCKED $1 $IMGEXT" && exit 4
43   
44 
45   if ! file $IMGFILE | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " >/dev/null ; then
46        echo "$PROG: Error: $MSG_ERR_DONTSYNC_IMAGE $1 $2"
47        exit 71
48   fi
49fi
50
51touch $IMGFILE.lock
52
53# El tamaño minimo de la imagen es 300000 para poder formatear en fs btrfs.
54SIZEREQUIRED=$3
55[ $SIZEREQUIRED -lt 300000 ] && SIZEREQUIRED=300000
56
57echo  CREATE_IMAGE "$1" $IMGEXT $SIZEREQUIRED
58echo -ne CREATE_IMAGE "$1" $IMGEXT $SIZEREQUIRED| /opt/opengnsys/sbin/ogAdmRepoAux  || exit $?
59echo "Los resultado se registran en $REPOLOG. "
60
61rm $IMGFILE.lock
Note: See TracBrowser for help on using the repository browser.