diff options
author | ramon <ramongomez@us.es> | 2009-10-19 12:48:35 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2009-10-19 12:48:35 +0000 |
commit | e42f34ed09b02a78a78a4525d282aa456f37db6f (patch) | |
tree | f002b2a6ac6d1e2b758de7e800ff46af91b3b867 | |
parent | 8964f9b26b06f61e20fba15bfe4fb653cc1a31b5 (diff) |
Función ogCopyFile.
git-svn-id: https://opengnsys.es/svn/trunk@391 a21b9725-9963-47de-94b9-378ad31fedc9
-rwxr-xr-x | client/engine/File.lib | 27 | ||||
-rwxr-xr-x | client/nfsexport/scripts/restore-image.sh | 21 | ||||
-rw-r--r-- | doc/opengnsys-logo.png | bin | 0 -> 10079 bytes |
3 files changed, 34 insertions, 14 deletions
diff --git a/client/engine/File.lib b/client/engine/File.lib index 22ef4649..8bee7358 100755 --- a/client/engine/File.lib +++ b/client/engine/File.lib @@ -10,18 +10,27 @@ ##### PRUEBAS -# ogGetPath [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target +# ogCopyFile [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target function ogCopyFile () { -local SOURCE TARGET +local ARGS SOURCE TARGET +ARGS="$@" case "$1" in - /*) SOURCE=$(ogGetFile "$1") # */ (necesario Doxygen) - shift ;; - [1-9]*) SOURCE=$(ogGetFile "$1" "$2" "$3") - shift 3 ;; - *) SOURCE=$(ogGetFile "$1" "$2") - shift 2 ;; + /*) # Camino completo. + SOURCE=$(ogGetPath "$1") + shift ;; + [1-9]*) # ndisco npartición. + SOURCE=$(ogGetPath "$1" "$2" "$3") + shift 3 ;; + *) # Otros: repo, cache, cdrom (no se permiten caminos relativos). + SOURCE=$(ogGetPath "$1" "$2") + shift 2 ;; esac - +#/// Comprobar fichero origen y directorio destino. +[ -n "$SOURCE" ] || ogRaiseError $OG_ERR_NOTFOUND "${ARGS% $*}" || return $? +TARGET=$(ogGetPath "$@") +[ -n "$TARGET" ] || ogRaiseError $OG_ERR_NOTFOUND "$@" || return $? +#/// Copiar fichero. +cp "$SOURCE" "$TARGET" # (definir posible error) } diff --git a/client/nfsexport/scripts/restore-image.sh b/client/nfsexport/scripts/restore-image.sh index 25814472..3cd44ab2 100755 --- a/client/nfsexport/scripts/restore-image.sh +++ b/client/nfsexport/scripts/restore-image.sh @@ -1,5 +1,5 @@ #!/bin/bash -# restore-image.sh - Scirpt de ejemplo para restaurar una imagen. +# Scirpt de ejemplo para restaurar una imagen. # (puede usarse como base para el programa de restauración de imágenes usado por OpenGNSys Admin). PROG="$(basename $0)" @@ -9,13 +9,24 @@ if [ $# -ne 4 ]; then fi # Procesar parámetros de entrada -IMGFILE=$(ogGetPath "$1" "$2.img") || exit $? +if [ "$1" == "CACHE" -o "$1" == "cache" ]; then + # Si la imagen no está en la caché, copiarla del repositorio. + IMGDIR=$(ogGetParentPath "$1" "$2") || exit $? + IMGFILE=$(ogGetPath "$1" "$2") + if [ -z "$IMGFILE" ]; then + echo "Copiando imagen \"$2\" del repositorio a caché local" + ogCopyFile "repo" "$2" "$IMGDIR" || exit $? + IMGFILE=$(ogGetPath "cache" "$2") || exit $? + fi +else + IMGFILE=$(ogGetPath "$1" "$2") || exit $? +fi PART=$(ogDiskToDev "$3" "$4") || exit $? -# Mostrar información. -ogEcho info "$PROG: Origen=$PART, Destino=$IMGFILE" +# Mostrar información. +ogEcho info "$PROG: Origen=$IMGFILE, Destino=$PART" # Restaurar la imagen. -ogRestoreImage "$@" || exit $? +ogRestoreImage "$1" "$2" "$3" "$4" || exit $? # Restaurar tamaño. ogExtendFs $1 $2 diff --git a/doc/opengnsys-logo.png b/doc/opengnsys-logo.png Binary files differnew file mode 100644 index 00000000..e98a2dcd --- /dev/null +++ b/doc/opengnsys-logo.png |