source: repoman/bin/createfileimage @ eeade34

v1.2.0
Last change on this file since eeade34 was 744ecd6, checked in by irina <irinagomez@…>, 7 years ago

#770 Script de servidor sincronizadas: si no existe fichero de idioma toma por defecto el castellano.

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

  • Property mode set to 100755
File size: 2.0 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
18# Cargamos los mensajes en el idioma del sistema.
19# Comprobamos que el fichero de idioma existe. Si no "es_ES" por defecto.
20ls $BASEDIR/client/etc/lang.$LANG.conf &>/dev/null
21[ $? -eq 0 ] || LANG="es_ES"
22source $BASEDIR/client/etc/lang.$LANG.conf
23
24PROG="$(basename $0)"
25# Si se solicita, mostrar ayuda.
26if [ "$*" == "help" ]; then
27    echo -e " $PROG: $MSG_HELP_ogCreateFileImage \n" \
28            "$MSG_FORMAT: $PROG image [ img|diff ] size_kb \n" \
29            "base -> $PROG Windows7 img 3900000 \n" \
30            "diff -> $PROG Ubuntu12 diff 450000"
31   exit 0
32fi
33
34[ $# -lt 3 ] && echo -e "$PROG: Error: $MSG_ERR_FORMAT \n     $MSG_FORMAT: $PROG image [ img | diff ]  size_Kb "  && exit 1
35
36if [ "$USER" != "root" ]; then
37        echo "$PROG: Error: solo ejecutable por root" >&2
38        exit 1
39fi
40
41IMGEXT="$2"
42
43# Si existe imagen, Comprobamos que no esta bloqueada y que es sincronizable
44IMGFILE="$REPODIR/$1.$IMGEXT"
45if [ -f $IMGFILE ]; then
46   [ -f $IMGFILE.lock ] && echo "$PROG: Error: $MSG_ERR_LOCKED $1 $IMGEXT" && exit 4
47   
48 
49   if ! file $IMGFILE | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " >/dev/null ; then
50        echo "$PROG: Error: $MSG_ERR_DONTSYNC_IMAGE $1 $2"
51        exit 71
52   fi
53fi
54
55touch $IMGFILE.lock
56
57# El tamaño minimo de la imagen es 300000 para poder formatear en fs btrfs.
58SIZEREQUIRED=$3
59[ $SIZEREQUIRED -lt 300000 ] && SIZEREQUIRED=300000
60
61echo  CREATE_IMAGE "$1" $IMGEXT $SIZEREQUIRED
62echo -ne CREATE_IMAGE "$1" $IMGEXT $SIZEREQUIRED| /opt/opengnsys/sbin/ogAdmRepoAux  || exit $?
63echo "Los resultado se registran en $REPOLOG. "
64
65rm $IMGFILE.lock
Note: See TracBrowser for help on using the repository browser.