diff options
Diffstat (limited to 'client/shared/scripts/restoreDiffImage')
-rwxr-xr-x | client/shared/scripts/restoreDiffImage | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/client/shared/scripts/restoreDiffImage b/client/shared/scripts/restoreDiffImage index 7d16ef90..4de5f31a 100755 --- a/client/shared/scripts/restoreDiffImage +++ b/client/shared/scripts/restoreDiffImage @@ -24,14 +24,17 @@ #@version 1.0 - restauración de imagen con sincronizacion. #@author #@date 2012-12-04 +#@version 1.1.1 - Varios repositorios para un mismo cliente (ticket #679). +#@author Irina Gomez - ETSII Universidad de Sevilla +#@date 2018/11/06 #*/ ## -trap "onexit $1 \"$2\" \"$3\" $4 $5" 1 2 3 6 9 14 15 EXIT +trap "onexit $REPO \"$2\" \"$3\" $4 $5" 1 2 3 6 9 14 15 EXIT # Si salimos con error demontamos la imagen y desbloqueamos la imagen y la particion function onexit() { local exit_status=$? - ogUnmountImage "$1" "$3" "$DIFFTYPE" &>/dev/null + ogUnmountImage "$REPO" "$3" "$DIFFTYPE" &>/dev/null [ $exit_status -ne 4 ] && ogUnlock $4 $5 &>/dev/null exit $exit_status } @@ -59,27 +62,41 @@ ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*" # Procesar parámetros de entrada DIFFTYPE="diff" DIFFEXT="img.diff" +REPO="${1^^}" +# No permite directorios diferentes para OU +OGUNIT="" + +# Si es una ip y es igual a la del equipo restaura desde cache +[ "$REPO" == "$(ogGetIpAddress)" ] && REPO="CACHE" +# Si es una ip y es distinta a la del recurso samba cambiamos de REPO. +ogCheckIpAddress $REPO +if [ $? == 0 -o $REPO == "REPO" ] ; then + # Si falla el cambio -> salimos con error repositorio no valido + ogChangeRepo $REPO ${OGUNIT%/} || exit $(ogRaiseError $OG_ERR_NOTFOUND '$REPO $OGUNIT'; echo $?) + REPO="REPO" +fi + REPODIFFFILE="$(ogGetPath "REPO" "$3.$DIFFEXT")" [ -n "$REPODIFFFILE" ] || exit $(ogRaiseError session $OG_ERR_NOTFOUND "REPO $3.$DIFFEXT";echo $?) # Comprobamos si la imagen o la particion estan bloqueada: -ogIsImageLocked "$1" "$3.$DIFFEXT" && exit $(ogRaiseError session $OG_ERR_LOCKED "$1 $3.$DIFFEXT";echo $?) +ogIsImageLocked "$REPO" "$3.$DIFFEXT" && exit $(ogRaiseError session $OG_ERR_LOCKED "$REPO $3.$DIFFEXT";echo $?) ogIsLocked "$4" "$5" && exit $(ogRaiseError session $OG_ERR_LOCKED "$4 $5";echo $?) -PART=$(ogDiskToDev "$4" "$5" 2>/dev/null ) || exit $(ogRaiseError session $OG_ERR_PARTITION "$1 $3";echo $?) +PART=$(ogDiskToDev "$4" "$5" 2>/dev/null ) || exit $(ogRaiseError session $OG_ERR_PARTITION "$REPO $3";echo $?) # Carga del configurador del engine [ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg # Comprobar que es sincronizable -ogIsSyncImage REPO "$3" diff || exit $(ogRaiseError session $OG_ERR_DONTSYNC_IMAGE "$1 $3";echo $?) +ogIsSyncImage REPO "$3" diff || exit $(ogRaiseError session $OG_ERR_DONTSYNC_IMAGE "$REPO $3";echo $?) # Restauramos la imagen Basica. -restoreBaseImage $1 "$2" "$4" "$5" "$6" "$7" +restoreBaseImage $REPO "$2" "$4" "$5" "$6" "$7" PROTO=${6:-"UNICAST"} -if [ "$1" == "CACHE" -o "$1" == "cache" ]; then +if [ "$REPO" == "CACHE" -o "$REPO" == "cache" ]; then ogEcho log session "[10] $MSG_HELP_updateCache." ogEcho log session " updateCache REPO" "/$3.$DIFFEXT" "$PROTO" "$7" updateCache REPO "/$3.$DIFFEXT" "$PROTO" "$7" @@ -101,20 +118,20 @@ TIME2=$SECONDS ogEcho log session "[40] $MSG_RESTORE $PART" # Montamos la diferencial -ogMountImage "$1" "$3" "$DIFFTYPE" &>/dev/null +ogMountImage "$REPO" "$3" "$DIFFTYPE" &>/dev/null # Comprobar que la imagen diferencial se ha montado -ogWaitSyncImage "$1" "$3" "$DIFFTYPE" "mounted" || exit $(ogRaiseError session $OG_ERR_DONTMOUNT_IMAGE "$1 $3 $DIFFTYPE: time_out $TIMEAUX seg.";echo $?) +ogWaitSyncImage "$REPO" "$3" "$DIFFTYPE" "mounted" || exit $(ogRaiseError session $OG_ERR_DONTMOUNT_IMAGE "$REPO $3 $DIFFTYPE: time_out $TIMEAUX seg.";echo $?) ogMount $4 $5 >/dev/null ogLock $4 $5 # Sincronizamos la partición con la imagen. -ogEcho log session "[60] $MSG_HELP_ogSyncRestore: $1 $3 $DIFFTYPE $4 $5" -ogSyncRestore "$1" "$3" "$DIFFTYPE" $4 $5 +ogEcho log session "[60] $MSG_HELP_ogSyncRestore: $REPO $3 $DIFFTYPE $4 $5" +ogSyncRestore "$REPO" "$3" "$DIFFTYPE" $4 $5 RETVAL=$? [ $RETVAL == 0 ] || ogEcho session warning "$MSG_ERR_SYNCHRONIZING" # Desmontamos la imagen -ogUnmountImage "$1" "$3" "$DIFFTYPE" +ogUnmountImage "$REPO" "$3" "$DIFFTYPE" ogUnlock $4 $5 TIMEAUX2=$[SECONDS-TIME2] @@ -130,7 +147,7 @@ ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL : $[T # Llamar al script de post-configuración del sistema operativo. if which configureOsCustom &>/dev/null; then ogEcho log session "[90] configureOsCustom" - configureOsCustom "$4" "$5" "$1" "$2" + configureOsCustom "$4" "$5" "$REPO" "$2" else ogEcho log session "[90] $MSG_HELP_configureOs." configureOs $4 $5 |