diff options
-rwxr-xr-x | admin/Interface/CrearImagenBasica | 11 | ||||
-rwxr-xr-x | admin/Interface/CrearSoftIncremental | 10 | ||||
-rwxr-xr-x | client/engine/Rsync.lib | 121 | ||||
-rw-r--r-- | client/shared/etc/lang.es_ES.conf | 4 | ||||
-rwxr-xr-x | client/shared/scripts/createBaseImage | 8 | ||||
-rwxr-xr-x | client/shared/scripts/createDiffImage | 7 |
6 files changed, 125 insertions, 36 deletions
diff --git a/admin/Interface/CrearImagenBasica b/admin/Interface/CrearImagenBasica index 9fd487f4..f302aa8e 100755 --- a/admin/Interface/CrearImagenBasica +++ b/admin/Interface/CrearImagenBasica @@ -44,6 +44,14 @@ #Carga el configurador del engine desde el fichero engine.cfg [ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg + # Si el destino es REPO y el cliente no está en modo "admin"; activar repositorio para escritura, + if [ "$REPO" == "REPO" -a "$boot" != "admin" ] + then + CambiarAcceso admin &>> $OGLOGFILE + RETVAL=$? + [ $RETVAL -gt 0 ] && exit $RETVAL + fi + # Clear temporary file used as log track by httpdlog # Limpia los ficheros temporales usados como log de seguimiento para httpdlog echo " " > $OGLOGSESSION; echo " " > $OGLOGCOMMAND; echo " " > ${OGLOGCOMMAND}.tmp @@ -73,3 +81,6 @@ createBaseImage $1 $2 $DEST "$3" fi + + [ "$REPO" == "REPO" -a "$boot" != "admin" ] && CambiarAcceso user + diff --git a/admin/Interface/CrearSoftIncremental b/admin/Interface/CrearSoftIncremental index 8bba0dd3..9fe6df8f 100755 --- a/admin/Interface/CrearSoftIncremental +++ b/admin/Interface/CrearSoftIncremental @@ -43,6 +43,15 @@ #Carga el configurador del engine desde el fichero engine.cfg [ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg + # Si el destino es REPO y el cliente no está en modo "admin"; activar repositorio para escritura, + if [ "$REPO" == "REPO" -a "$boot" != "admin" ] + then + CambiarAcceso admin &>> $OGLOGFILE + RETVAL=$? + [ $RETVAL -gt 0 ] && exit $RETVAL + fi + + # Clear temporary file used as log track by httpdlog # Limpia los ficheros temporales usados como log de seguimiento para httpdlog echo " " > $OGLOGSESSION; echo " " > $OGLOGCOMMAND; echo " " > ${OGLOGCOMMAND}.tmp @@ -73,3 +82,4 @@ fi + [ "$REPO" == "REPO" -a "$boot" != "admin" ] && CambiarAcceso user diff --git a/client/engine/Rsync.lib b/client/engine/Rsync.lib index c7ac6ed7..5e8be2ae 100755 --- a/client/engine/Rsync.lib +++ b/client/engine/Rsync.lib @@ -13,7 +13,8 @@ function ogCreateFileImage () { local SIZEREQUIRED IMGDIR IMGFILE DIRMOUNT LOOPDEVICE IMGSIZE IMGEXT if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME [ REPO|CACHE ] image_name extension size(K)" \ + ogHelp "$FUNCNAME" : "$MSG_HELP_ogCreateFileImage" \ + "$FUNCNAME [ REPO|CACHE ] image_name extension size(K)" \ "$FUNCNAME REPO Ubuntu12 img 300000" \ "$FUNCNAME CACHE Windows7 diff 20000000" return @@ -121,9 +122,10 @@ local IMGTYPE IMGDIRAUX DIRMOUNT DESTRSYNC PASSWORD OPTRSYNC USERRSYNC ORIG FST # Ayuda o menos de 5 parametros y la imagen no es basica if [ "$*" == "help" -o $# -lt 5 -a "$3" != "img" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME num_disk num_part [ REPO|CACHE ] [ base_image_name ] extension " \ - "base image -> $FUNCNAME 1 2 img" \ - "diff image -> $FUNCNAME 1 1 CACHE Windows7 diff " + ogHelp "$FUNCNAME" : "$MSG_HELP_ogCreateInfoImage" \ + "$FUNCNAME num_disk num_part [ REPO|CACHE ] [ base_image_name ] extension " \ + "base image -> $FUNCNAME 1 2 img" \ + "diff image -> $FUNCNAME 1 1 CACHE Windows7 diff " return fi @@ -262,9 +264,10 @@ local DEST PART IMGACL IMGLN OPTLN LINEA DESTLN ORIGLN TYPELN # Ayuda o menos de 5 parametros y la imagen no es basica if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME num_disk num_part" \ - "base image -> $FUNCNAME 1 2 " \ - "diff image -> $FUNCNAME 1 1 " + ogHelp "$FUNCNAME": "$MSG_HELP_ogRestoreInfoImage" \ + "$FUNCNAME num_disk num_part" \ + "base image -> $FUNCNAME 1 2 " \ + "diff image -> $FUNCNAME 1 1 " return fi @@ -334,9 +337,10 @@ function ogSyncCreate () { local ORIG DIRAUX DIRMOUNT DESTRSYNC USERRSYNC PASSWORD OPTRSYNC if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME num_disk num_part [ REPO|CACHE ] image_name extension " \ - "$FUNCNAME 1 2 REPO Ubuntu12 img" \ - "$FUNCNAME 1 1 CACHE Windows7 diff " + ogHelp "$FUNCNAME": "$MSG_HELP_ogSyncCreate" \ + "$FUNCNAME num_disk num_part [ REPO|CACHE ] image_name extension " \ + "$FUNCNAME 1 2 REPO Ubuntu12 img" \ + "$FUNCNAME 1 1 CACHE Windows7 diff " return fi @@ -389,9 +393,10 @@ function ogSyncRestore () { local DIRMOUNT ORIG DESTRSYNC PASSWORD OPTRSYNC USERRSYNC IMGINFO FILESFROM if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME [ REPO|CACHE ] image_name extension num_disk num_part " \ - "$FUNCNAME REPO Ubuntu12 img 1 2" \ - "$FUNCNAME CACHE Windows7 diff 1 1" + ogHelp "$FUNCNAME": "$MSG_HELP_ogSyncRestore" \ + "$FUNCNAME [ REPO|CACHE ] image_name extension num_disk num_part " \ + "$FUNCNAME REPO Ubuntu12 img 1 2" \ + "$FUNCNAME CACHE Windows7 diff 1 1" return fi @@ -464,10 +469,11 @@ function ogMountImage () { local IMGEXT IMGFILE DIRMOUNT if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ - "$FUNCNAME REPO Ubuntu12" \ - "$FUNCNAME CACHE Windows7 diff" - return + ogHelp "$FUNCNAME": "$MSG_HELP_ogMountImage" \ + "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ + "$FUNCNAME REPO Ubuntu12" \ + "$FUNCNAME CACHE Windows7 diff" + return fi @@ -522,9 +528,10 @@ function ogUnmountImage () { local IMGTYPE DIRMOUNT if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ - "$FUNCNAME REPO Ubuntu12" \ - "$FUNCNAME CACHE Windows7 diff" + ogHelp "$FUNCNAME": "$MSG_HELP_ogUnmountImage" \ + "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ + "$FUNCNAME REPO Ubuntu12" \ + "$FUNCNAME CACHE Windows7 diff" return fi @@ -556,9 +563,10 @@ function ogGetMountImageDir () { #*/ local DIRMOUNT if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME image_name [ extension ]" \ - "$FUNCNAME Ubuntu12" \ - "$FUNCNAME Windows7 diff" + ogHelp "$FUNCNAME": "$MSG_HELP_ogGetMountImageDir" \ + "$FUNCNAME image_name [ extension ]" \ + "$FUNCNAME Ubuntu12" \ + "$FUNCNAME Windows7 diff" return fi @@ -593,9 +601,10 @@ TIME=$SECONDS # Ayuda o menos de 5 parametros y la imagen no es basica if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME [ REPO | CACHE ] image_name extension [ image_size ] " \ - "$FUNCNAME REPO Ubuntu12 img 30000000" \ - "$FUNCNAME CACHE Windows7 diff " + ogHelp "$FUNCNAME": "$MSG_HELP_ogWaitMountImage" \ + "$FUNCNAME [ REPO | CACHE ] image_name extension [ image_size ] " \ + "$FUNCNAME REPO Ubuntu12 img 30000000" \ + "$FUNCNAME CACHE Windows7 diff " return fi @@ -642,9 +651,10 @@ function ogReduceImage () { #*/ local IMGEXT DIRMOUNT AVAILABLE USED IMGDIR IMGFILE ENDSIZE LOOPDEVICE if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ - "$FUNCNAME REPO Ubuntu12" \ - "$FUNCNAME CACHE Windows7 diff" + ogHelp "$FUNCNAME": "$MSG_HELP_ogReduceImage" \ + "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ + "$FUNCNAME REPO Ubuntu12" \ + "$FUNCNAME CACHE Windows7 diff" return fi @@ -726,9 +736,10 @@ function ogIsSyncImage () { local IMGEXT IMGDIR IMGFILE if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ - "$FUNCNAME REPO Ubuntu12" \ - "$FUNCNAME CACHE Windows7 diff" + ogHelp "$FUNCNAME": "$MSG_HELP_ogIsSyncImage" \ + "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ + "$FUNCNAME REPO Ubuntu12" \ + "$FUNCNAME CACHE Windows7 diff" return fi @@ -746,3 +757,49 @@ file "$IMGFILE" | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " >/dev/n } + +#/** +# ogCheckSyncImage +#@brief Muestra el contenido de la imagen para comprobarla. +#@param 1 Repositorio [ REPO | CACHE ] +#@param 2 Nombre Imagen +#@param 3 Tipo Imagen [ img |diff ] +#@return +#@exception OG_ERR_FORMAT # 1 formato incorrecto. +#@exception OG_ERR_NOTFOUND # 2 Fichero o dispositivo no encontrado. +#*/ +ogCheckSyncImage (){ +local IMGEXT IMGDIR IMGFILE DIRMOUNT + +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME": "$MSG_HELP_ogCheckSyncImage" \ + "$FUNCNAME [ REPO|CACHE ] image_name [ extension ]" \ + "$FUNCNAME REPO Ubuntu12" \ + "$FUNCNAME CACHE Windows7 diff" + return +fi + +if [ $# -lt 2 ]; then + ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $FUNCNAME [ REPO|CACHE ] image_name [ extension ]" + return $? +fi + +[ "$3" == "" -o "$3" == "img" ] && IMGEXT="img" || IMGEXT="img.diff" +IMGDIR="$(ogGetParentPath "$1" "/$2")" +IMGFILE="${IMGDIR}/$(basename "/$2").$IMGEXT" + +ogIsSyncImage $1 "$2" "${IMGEXT#*\.}" || ogRaiseError $OG_ERR_DONTSYNC_IMAGE "$3 $4" || return $? + +DIRMOUNT="/tmp/ogCheckImage$$" +mkdir "$DIRMOUNT" +# FS de la imagen segun la version del kernel: < 3.7 ext4, si >= btrfs +if [ $(uname -r|cut -d. -f2) -lt 7 ]; then + mount -t ext4 -o loop "$IMGFILE" "$DIRMOUNT" 1>/dev/null +else + mount -o compress=lzo "$IMGFILE" "$DIRMOUNT" 1>/dev/null +fi +ls "$DIRMOUNT" +umount "$DIRMOUNT" + +rmdir "$DIRMOUNT" +} diff --git a/client/shared/etc/lang.es_ES.conf b/client/shared/etc/lang.es_ES.conf index 987c2c28..8f5d9868 100644 --- a/client/shared/etc/lang.es_ES.conf +++ b/client/shared/etc/lang.es_ES.conf @@ -86,6 +86,7 @@ MSG_HELP_ogAddRegistryValue="Añade un nuevo valor al registro de Windows." MSG_HELP_ogBoot="Arranca un sistema operativo instalado." MSG_HELP_ogCalculateChecksum="Calcula la suma de comprobación (checksum) de un fichero." MSG_HELP_ogCheckFs="Comprueba la consistencia de un sistema de archivos." +MSG_HELP_ogCheckSyncImage="Muestra el contenido de la imagen para comprobarla." MSG_HELP_ogCompareChecksumFiles="Compara si coinciden las sumas de comprobación almacenadas de 2 ficheros." MSG_HELP_ogCopyFile="Copia un fichero a otro almacenamiento." MSG_HELP_ogCreateCache="Reserva espacio para la partición de caché al final del disco 1." @@ -123,6 +124,7 @@ MSG_HELP_ogGetIpAddress="Devuelve la dirección IP del cliente." MSG_HELP_ogGetImageSize="Devuelve el tamaño de una imagen de sistema." MSG_HELP_ogGetLastSector="Devuelve el último sector usable del disco o de una partición." MSG_HELP_ogGetMacAddress="Devuelve la dirección Ethernet del cliente." +MSG_HELP_ogGetMountImageDir="Devuelve el directorio de montaje de una imagen." MSG_HELP_ogGetMountPoint="Devuelve el directorio donde está montado un sistema de archivos local." MSG_HELP_ogGetOsType="Devuelve el tipo de un sistema operativo instalado." MSG_HELP_ogGetOsVersion="Devuelve el tipo y la versión de un sistema operativo instalado." @@ -150,6 +152,7 @@ MSG_HELP_ogIsMounted="Comprueba si un sistema de archivos está montado." MSG_HELP_ogIsNewerFile="Comprueba si un fichero es más nuevo (se ha modificado después) que otro." MSG_HELP_ogIsPartitionLocked=$MSG_HELP_ogIsLocked MSG_HELP_ogIsValidType="Comprueba si el tipo de sistema de archivos es válido para un identificador de partición." +MSG_HELP_ogIsSyncImage="Comprueba si la imagen es sincronizable." MSG_HELP_ogIsWritable="Comprueba si un sistema de archivos está montado con permiso de escritura." MSG_HELP_ogLinuxBootParameters="Devuelve los parámetros de arranque de un sistema operativo Linux instalado." MSG_HELP_ogListHardwareInfo="Lista el inventario de dispositivos del cliente." @@ -193,6 +196,7 @@ MSG_HELP_ogUnmountCache="Desmonta el sistema de archivos de caché local." MSG_HELP_ogUnmountFs=$MSG_HELP_ogUnmount MSG_HELP_ogUnmountImage="Desmonta la imagen" MSG_HELP_ogUpdatePartitionTable="Actualiza informacion tabla particiones del disco" +MSG_HELP_ogWaitMountImage="Se espera un tiempo estimado a que se monte la imagen en el servidor." # scripts MSG_HELP_configureOs="Post-configura de arranque del sistema" diff --git a/client/shared/scripts/createBaseImage b/client/shared/scripts/createBaseImage index e45aacbc..09999e9b 100755 --- a/client/shared/scripts/createBaseImage +++ b/client/shared/scripts/createBaseImage @@ -159,7 +159,7 @@ echo " $MSG_HELP_ogSyncCreate." | tee -a $OGLOGSESSION $OGLOGFILE ogSyncCreate $1 $2 $3 "$4" $IMGEXT # Reducimos la imagen: solo para kernel <= 3.7, imagenes con FS ext4. -echo "[90] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT" | tee -a $OGLOGSESSION $OGLOGFILE +echo "[80] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT" | tee -a $OGLOGSESSION $OGLOGFILE ogReduceImage $3 "$4" $IMGEXT # Desmontamos la Imagen @@ -170,7 +170,11 @@ TIMEAUX5=$[SECONDS-TIMEAUX3] echo " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX3/60]m $[TIMEAUX3%60]s" | tee -a $OGLOGSESSION $OGLOGFILE # Comprobamos que la imagen esta bien detectacdo que es un sistema de ficheros. -ogIsSyncImage $3 "$4" "img" || ogRaiseError $OG_ERR_IMAGE "$3 $4" +echo "[95] $MSG_HELP_ogCheckSyncImage" | tee -a $OGLOGSESSION $OGLOGFILE +ogCheckSyncImage $3 "$4" "img" | tee -a $OGLOGSESSION $OGLOGFILE +RETVAL=${PIPESTATUS[0]} +[ "$RETVAL" == "0" ] || ogRaiseError $OG_ERR_IMAGE "$3 $4 img" + TIMEAUX7=$[SECONDS-TIME2] echo " $MSG_SCRIPTS_TIME_PARTIAL : $[TIMEAUX7/60]m $[TIMEAUX7%60]s" | tee -a $OGLOGSESSION $OGLOGFILE diff --git a/client/shared/scripts/createDiffImage b/client/shared/scripts/createDiffImage index a7ee9200..16b266f1 100755 --- a/client/shared/scripts/createDiffImage +++ b/client/shared/scripts/createDiffImage @@ -199,7 +199,7 @@ echo "[80] $MSG_HELP_ogSyncCreate" | tee -a $OGLOGSESSION $OGLOGFILE ogSyncCreate $1 $2 $3 "$5" $DIFFTYPE # Reducimos la imagen diferencial -> solo para kernel <= 3.7, imagenes con FS ext4 -echo "[90] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT" | tee -a $OGLOGSESSION $OGLOGFILE +echo "[80] $MSG_HELP_ogReduceImage: $3 /$4.$IMGEXT" | tee -a $OGLOGSESSION $OGLOGFILE ogReduceImage $3 "$5" $DIFFTYPE # Desmontamos las imagenes @@ -219,7 +219,10 @@ ogUnlockImage "$3" "/$5.$DIFFEXT" ogUnlock $1 $2 # Comprobamos que la imagen esta bien -ogIsSyncImage $3 "$5" diff || ogRaiseError $OG_ERR_IMAGE "$3 $5" +echo "[95] $MSG_HELP_ogCheckSyncImage" | tee -a $OGLOGSESSION $OGLOGFILE +ogCheckSyncImage $3 "$5" diff | tee -a $OGLOGSESSION $OGLOGFILE +RETVAL=${PIPESTATUS[0]} +[ "$RETVAL" == "0" ] || ogRaiseError $OG_ERR_IMAGE "$3 $5 diff" #resumen de la operacion IMGSIZE=$(ls -l --block-size=1024 "${DIFFFILE}"| cut -f5 -d" ") |