Solución ticket:181 - Script {{{initCache}}} soporta valor -1 para borrar caché y valor 0 para no hacer nada.

git-svn-id: https://opengnsys.es/svn/trunk@1070 a21b9725-9963-47de-94b9-378ad31fedc9
remotes/github/debian-pkg
ramon 2010-06-28 14:00:42 +00:00
parent 71d382b689
commit 8abcdfe153
1 changed files with 20 additions and 4 deletions

View File

@ -1,21 +1,37 @@
#!/bin/bash
# Scirpt de iniciación de la caché local de disco.
# (puede usarse como base para el programa de restauración de imágenes usado por OpenGnSys Admin).
# Versión: 0.91, 2009/03/17, - Ramón Gómez, Universidad de Sevilla
# Versión: 0.9.1, 2009/03/17, - Ramón Gómez, Univ. Sevilla - Versión inicial.
# Versión: 0.9.2, 2010/07/27, - Ramón Gómez, Univ. Sevilla - redefinir parámetro.
TIME1=$SECONDS
PROG="$(basename $0)"
if [ $# -ne 1 ]; then
ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG tamaño"
ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG -1 | 0 | tamaño"
exit $?
fi
# Si tamaño=0, borrar caché.
if [ $1 == 0 ]; then
# Si tamaño no es numérico o tamaño<-1, error.
if [ -n "${1//[-0-9]/}" ] || [ $1 -lt -1 ]; then
ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG -1 | 0 | tamaño"
exit $?
fi
# Si tamaño=0, no hacer nada.
if [ $1 -eq 0 ]; then
echo "No modificar la caché local."
exit
fi
# Si tamaño=-1, borrar caché.
if [ $1 -eq -1 ]; then
echo "[10] Trabajar sin caché local."
ogUnmountCache 2>/dev/null
ogDeleteCache
else
# Si tamaño>0, ...
if [ ! $1 -gt 0 ]; then
ogRaiseError $OG_ERR_FORMAT "$MSG_ERR_FORMAT: !($1>0)"
exit $?
fi
# Si no existe caché o si cambia su tamaño, crearla.
SIZE=$(ogGetCacheSize 2>/dev/null)
if [ "$1" != "$SIZE" ]; then