31 if [
"$*" ==
"help" ]; then
32 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
33 "$FUNCNAME REPO ubuntu.img ==> ef899299caf8b517ce36f1157a93d8bf" 37 # Comprobar que existe el fichero y devolver sus datos. 39 [ -n
"$FILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
40 tail -c1M
"$FILE" | md5sum -b 2>&1 | cut -f1 -d
" " 56 local ARGS SOURCE TARGET
57 if [
"$*" ==
"help" ]; then
58 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
59 "if $FUNCNAME REPO ubuntu.img CACHE ubuntu.img; then ...; fi" 68 [1-9]*) # ndisco npartición.
71 *) # Otros: repo, cache, cdrom (no se permiten caminos relativos).
77 # Comparar los ficheros de checksum.
78 test
"$(cat "$SOURCE.sum
" 2>/dev/null)" ==
"$(cat "$TARGET.sum
" 2>/dev/null)" 98 if [
"$*" ==
"help" ]; then
99 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
100 "$FUNCNAME REPO ubuntu.img ==> ef899299caf8b517ce36f1157a93d8bf" 104 # Comprobar que existe el fichero y devolver sus datos. 106 [ -n
"$FILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
108 md5sum
"$FILE" -b 2>&1 | cut -f1 -d
" " 109 # tail -c1M
"$FILE" | md5sum -b 2>&1 | cut -f1 -d
" " 131 local ARGS SOURCE TARGET
132 if [
"$*" ==
"help" ]; then
133 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_source [ str_repo | int_ndisk int_npartition ] path_target" \
134 "$FUNCNAME REPO newfile.txt 1 2 /tmp/newfile.txt" 141 SOURCE=
"$(ogGetPath "$1
")" 143 [1-9]*) # ndisco npartición.
144 SOURCE=
"$(ogGetPath "$1
" "$2
" "$3
")" 146 *) # Otros: repo, cache, cdrom (no se permiten caminos relativos).
147 SOURCE=
"$(ogGetPath "$1
" "$2
")" 150 # Comprobar fichero origen y directorio destino. 151 [ -n
"$SOURCE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"${ARGS% $*}" ||
return $?
152 TARGET=
"$(ogGetPath "$
@")" 153 [ -n
"$TARGET" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
154 # Copiar fichero (para evitar problemas de comunicaciones las copias se hacen con rsync en vez de cp). 155 rsync --progress --inplace -avh
"$SOURCE" "$TARGET" 171 if [
"$*" ==
"help" ]; then
172 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_file" \
173 "$FUNCNAME 1 2 /tmp/newfile.txt" 177 # Comprobar que existe el fichero y borrarlo. 178 FILE=
"$(ogGetPath "$
@")" 179 [ -n
"$FILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
180 rm -f
"$FILE" ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
196 if [
"$*" ==
"help" ]; then
197 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_dir" \
198 "$FUNCNAME 1 2 /tmp/newdir" 202 # Comprobar que existe el directorio y borrarlo con su contenido. 203 DIR=
"$(ogGetPath "$
@")" 204 [ -n
"$DIR" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
205 rm -fr
"$DIR" ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
240 local MNTDIR FILE PREVFILE FILEPATH CURRENTDIR
242 # Si se solicita, mostrar ayuda. 243 if [
"$*" ==
"help" ]; then
244 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
245 "$FUNCNAME \"/mnt/sda1/windows/system32\" ==> /mnt/sda1/WINDOWS/System32" \
246 "$FUNCNAME REPO /etc/fstab ==> /opt/opengnsys/images/etc/fstab" \
247 "$FUNCNAME 1 1 \"/windows/system32\" ==> /mnt/sda1/WINDOWS/System32" 251 # Procesar camino según el número de parámetros. 258 MNTDIR=
"$(ogMountCache)" ||
return $?
259 FILE=
"$MNTDIR/$OGIMG/$2" ;;
261 MNTDIR=
"$(ogMountCdrom)" ||
return $?
266 3) MNTDIR=
"$(ogMount $1 $2)" ||
return $?
272 # Eliminar caracteres \c / duplicados y finales. 274 FILE=
"$(echo $FILE|sed -e 's/\(\/\)*\1/\//g; s/\/$//')" 275 # Comprobar si existe el fichero para reducir tiempos. 276 if [ -e
"$FILE" ]; then
279 # Buscar el nombre correcto en cada subdirectorio del camino. 282 while [
"$FILE" !=
"$PREVFILE" ];
do 283 FILEPATH=
"$(ls -d "${FILEPATH%/}/${FILE%% (Comentario Doxygen)
289 [ -n
"$FILEPATH" ] && echo
"$FILEPATH" 303 function ogGetParentPath ()
306 if [
"$*" ==
"help" ]; then
307 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
308 "$FUNCNAME \"/mnt/sda1/windows/system32\" ==> /mnt/sda1/WINDOWS" \
309 "$FUNCNAME REPO /etc/fstab ==> /opt/opengnsys/images/etc" \
310 "$FUNCNAME 1 1 \"/windows/system32\" ==> /mnt/sda1/WINDOWS" 315 1) PARENT=
"$(dirname "$1
")" ;;
316 2) PARENT=
"$1 $(dirname "/$2
")" ;;
317 3) PARENT=
"$1 $2 $(dirname "/$3
")" ;;
338 function ogIsNewerFile ()
341 local ARGS SOURCE TARGET
342 # Si se solicita, mostrar ayuda. 343 if [
"$*" ==
"help" ]; then
344 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_source [ str_repo | int_ndisk int_npartition ] path_target" \
345 "if $FUNCNAME REPO ubuntu.img CACHE ubuntu.img; then ... fi" 352 SOURCE=
"$(ogGetPath "$1
")" 354 [1-9]*) # ndisco npartición.
355 SOURCE=
"$(ogGetPath "$1
" "$2
" "$3
")" 357 *) # Otros: repo, cache, cdrom (no se permiten caminos relativos).
358 SOURCE=
"$(ogGetPath "$1
" "$2
")" 361 # Comprobar que existen los ficheros origen y destino. 362 [ -n
"$SOURCE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"${ARGS% $*}" ||
return 1
364 [ -n
"$TARGET" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return 1
365 # Devolver si el primer fichero se ha modificado después que el segundo.
366 test
"$SOURCE" -nt
"$TARGET" 379 function ogMakeChecksumFile ()
383 if [
"$*" ==
"help" ]; then
384 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
385 "$FUNCNAME REPO ubuntu.img" 389 # Comprobar que existe el fichero y guardar su checksum. 390 FILE=
"$(ogGetPath "$
@")" 391 [ -n
"$FILE" ] ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
409 function ogMakeDir ()
412 if [
"$*" ==
"help" ]; then
413 ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_dir" \
414 "$FUNCNAME 1 2 /tmp/newdir" 418 PARENT=
"$(ogGetParentPath "$
@")" ||
return $?
419 DIR=
"$(basename "${!#}
")" 420 mkdir -p
"$PARENT/$DIR" ||
ogRaiseError $OG_ERR_NOTFOUND
"$*" ||
return $?
function ogCopyFile()
Metafunción para copiar un fichero de sistema OpenGnSys a un directorio. #.
function ogDeleteTree()
Metafunción que borra todo un subárbol de directorios de un dispositivo. #.
function ogRaiseError()
Devuelve el mensaje y el código de error correspondiente. #.
function ogHelp()
Muestra mensaje de ayuda para una función determinda. #.
function ogGetPath()
Inicia el proceso de arranque de un sistema de archivos. #.
function ogCalculateChecksum()
Devuelve la suma de comprobación (checksum) de un fichero. #.
function ogDeleteFile()
Metafunción que borra un fichero de un dispositivo. #.
function ogCompareChecksumFiles()
Metafunción que compara las sumas de comprobación almacenadas de 2 ficheros. #.
function ogCalculateFullChecksum()
Devuelve la suma COMPLETA de comprobación (checksum) de un fichero. #.
function rsync()
Función para utilizar la versión de rsync situada en $OPENGNSYS/bin en vez de la del sistema operativ...