source: client/shared/scripts/initCache @ 46f7d6f

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 46f7d6f was 7102b4f, checked in by ramon <ramongomez@…>, 12 years ago

#601: Cambio en script initCache para crear caché local en cualquier disco.

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

  • Property mode set to 100755
File size: 2.8 KB
Line 
1#!/bin/bash
2# Scirpt de iniciación de la caché local de disco.
3# (puede usarse como base para el programa de restauración de imágenes usado por OpenGnSys Admin).
4# Versión: 0.9.1, 2009/03/17, - Ramón Gómez, Univ. Sevilla - Versión inicial.
5# Versión: 0.9.2, 2010/07/27, - Ramón Gómez, Univ. Sevilla - redefinir parámetro.
6# Version: 1.0.5, 2012/09/18, - Univ. Huelva - Nuevo parametro para indicar el disco donde se creara la CACHE, si no se indica, se usa 1
7
8TIME1=$SECONDS
9PROG="$(basename $0)"
10# Si el numero de parametros es 1, es el tamano de la CACHE
11if [ $# == 1 ]
12then
13        NDISK=1
14        SIZE=$1
15elif [ $# == 2 ]
16then
17        NDISK=$1
18        SIZE=$2
19else
20    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG [int_ndisk] -1 | 0 | size"
21    exit $?
22fi
23
24# Si disco no es mayor o igual que 1, error.
25if [ -n "${NDISK//[-0-9]/}" ] || [ $NDISK -lt 1 ]; then
26    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG [int_ndisk] -1 | 0 | size"
27    exit $?
28fi
29
30# Si tamaño no es numérico o tamaño<-1, error.
31if [ -n "${SIZE//[-0-9]/}" ] || [ $SIZE -lt -1 ]; then
32    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG int_ndisk [-1 | 0 | size]"
33    exit $?
34fi
35# Si tamaño=0, no hacer nada.
36if [ $SIZE -eq 0 ]; then
37    echo "No modificar la caché local."
38    exit
39fi
40# Si tamaño=-1, borrar caché.
41if [ $SIZE -eq -1 ]; then
42    echo "[10] Trabajar sin caché local."
43    ogUnmountCache 2>/dev/null
44    ogDeleteCache
45else
46    # Comprobar disco y particion donde se aloja la cache actualmente, si la hay
47    FINDCACHE=`ogFindCache`
48    echo "[5] ogFindCache: "$FINDCACHE
49    CACHEDISK=${FINDCACHE% *}
50    PART=${FINDCACHE#* }
51
52    # Si la CACHE actual esta definida en otro disco, se elimina
53    if [ "$NDISK" != "$CACHEDISK" ]
54    then
55        echo "[10] Detectada cache en otro disco, eliminarla"
56        ogUnmountCache 2>/dev/null
57        ogDeleteCache
58    fi
59
60    # Si tamaño>0, ...
61    if [ ! $SIZE -gt 0 ]; then
62        ogRaiseError $OG_ERR_FORMAT "$MSG_ERR_FORMAT: !($SIZE>0)"
63        exit $?
64    fi
65    # Si no existe caché o si cambia su tamaño, crearla.
66    CACHESIZE=$(ogGetCacheSize 2>/dev/null)
67    if [ "$SIZE" != "$CACHESIZE" ]; then
68        echo "[10] Crar partición de caché local."
69        ogUnmountCache 2>/dev/null
70        ogCreateCache $NDISK "$SIZE"
71    fi
72    # Si caché no montada y no formateada, formatear.
73    CACHE=$(ogFindCache) || exit $?
74    if ! ogIsFormated $CACHE; then
75        echo "[50] Formatear caché local."
76        ogFormatCache
77    fi
78    echo "[70] Montar caché local."
79    ogMountCache 2>/dev/null
80    # Si error al montar, chequear sistema de archivos y volver a montar.
81    if [ $? != 0 ]; then
82        echo "[80] Comprobar y montar caché local."
83        ogCheckFs $CACHE
84        ogMountCache || exit $?
85    fi
86fi
87# Duración del proceso.
88TIME=$[SECONDS-TIME1]
89echo "[100] Duración de la operación $[TIME/60]m $[TIME%60]s"
90
Note: See TracBrowser for help on using the repository browser.