| 1 | #!/bin/bash |
|---|
| 2 | #/** |
|---|
| 3 | #@file File.lib |
|---|
| 4 | #@brief Librería o clase File |
|---|
| 5 | #@class File |
|---|
| 6 | #@brief Funciones para gestión de archivos y directorios. |
|---|
| 7 | #@version 1.0.4 |
|---|
| 8 | #@warning License: GNU GPLv3+ |
|---|
| 9 | #*/ |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | #/** |
|---|
| 13 | # ogCalculateChecksum [ str_repo | int_ndisk int_npart ] path_filepath |
|---|
| 14 | #@brief Devuelve la suma de comprobación (checksum) de un fichero. |
|---|
| 15 | #@param path_filepath camino del fichero (independiente de mayúsculas) |
|---|
| 16 | #@param str_repo repositorio de ficheros |
|---|
| 17 | #@param int_ndisk nº de orden del disco |
|---|
| 18 | #@param int_npartition nº de orden de la partición |
|---|
| 19 | #@return hex_checksum Checksum del fichero |
|---|
| 20 | #@version 0.9.2 - Primera versión para OpenGnSys. |
|---|
| 21 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 22 | #@date 2010-07-24 |
|---|
| 23 | #@version 1.0.4 - Calcula solo el checksum del último MB del fichero. |
|---|
| 24 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 25 | #@date 2012-03-16 |
|---|
| 26 | #*/ ## |
|---|
| 27 | function ogCalculateChecksum () |
|---|
| 28 | { |
|---|
| 29 | # Variables locales. |
|---|
| 30 | local FILE |
|---|
| 31 | if [ "$*" == "help" ]; then |
|---|
| 32 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \ |
|---|
| 33 | "$FUNCNAME REPO ubuntu.img ==> ef899299caf8b517ce36f1157a93d8bf" |
|---|
| 34 | return |
|---|
| 35 | fi |
|---|
| 36 | |
|---|
| 37 | # Comprobar que existe el fichero y devolver sus datos. |
|---|
| 38 | FILE=$(ogGetPath "$@") |
|---|
| 39 | [ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? |
|---|
| 40 | tail -c1M "$FILE" | md5sum -b 2>&1 | cut -f1 -d" " |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | #/** |
|---|
| 45 | # ogCompareChecksumFiles [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target |
|---|
| 46 | #@brief Metafunción que compara las sumas de comprobación almacenadas de 2 ficheros. |
|---|
| 47 | #@return bool_compare Valor de comparación. |
|---|
| 48 | #@warning No es necesario especificar la extensión ".sum". |
|---|
| 49 | #@version 0.9.2 - Primera versión para OpenGnSys. |
|---|
| 50 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 51 | #@date 2010-07-24 |
|---|
| 52 | #*/ ## |
|---|
| 53 | function ogCompareChecksumFiles () |
|---|
| 54 | { |
|---|
| 55 | # Variables locales. |
|---|
| 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" |
|---|
| 60 | return |
|---|
| 61 | fi |
|---|
| 62 | |
|---|
| 63 | ARGS="$@" |
|---|
| 64 | case "$1" in |
|---|
| 65 | /*) # Camino completo. */ (Comentrio Doxygen) |
|---|
| 66 | SOURCE=$(ogGetPath "$1") |
|---|
| 67 | shift ;; |
|---|
| 68 | [1-9]*) # ndisco npartición. |
|---|
| 69 | SOURCE=$(ogGetPath "$1" "$2" "$3") |
|---|
| 70 | shift 3 ;; |
|---|
| 71 | *) # Otros: repo, cache, cdrom (no se permiten caminos relativos). |
|---|
| 72 | SOURCE=$(ogGetPath "$1" "$2") |
|---|
| 73 | shift 2 ;; |
|---|
| 74 | esac |
|---|
| 75 | TARGET=$(ogGetPath "$@") |
|---|
| 76 | |
|---|
| 77 | # Comparar los ficheros de checksum. |
|---|
| 78 | test "$(cat "$SOURCE.sum" 2>/dev/null)" == "$(cat "$TARGET.sum" 2>/dev/null)" |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | #/** |
|---|
| 83 | # ogCopyFile [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target |
|---|
| 84 | #@brief Metafunción para copiar un fichero de sistema OpenGnSys a un directorio. |
|---|
| 85 | #@see ogGetPath |
|---|
| 86 | #@return Progreso de la copia. |
|---|
| 87 | #@warning Deben existir tanto el fichero origen como el directorio destino. |
|---|
| 88 | #@version 0.9 - Pruebas con OpenGnSys. |
|---|
| 89 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 90 | #@date 2009-10-20 |
|---|
| 91 | #@version 1.0.4 - Copiar usando rsync. |
|---|
| 92 | #@author Universidad de Huelva |
|---|
| 93 | #@date 2012-07-06 |
|---|
| 94 | #*/ ## |
|---|
| 95 | function ogCopyFile () |
|---|
| 96 | { |
|---|
| 97 | # Variables locales. |
|---|
| 98 | local ARGS SOURCE TARGET |
|---|
| 99 | if [ "$*" == "help" ]; then |
|---|
| 100 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_source [ str_repo | int_ndisk int_npartition ] path_target" \ |
|---|
| 101 | "$FUNCNAME REPO newfile.txt 1 2 /tmp/newfile.txt" |
|---|
| 102 | return |
|---|
| 103 | fi |
|---|
| 104 | |
|---|
| 105 | ARGS="$@" |
|---|
| 106 | case "$1" in |
|---|
| 107 | /*) # Camino completo. */ (Comentrio Doxygen) |
|---|
| 108 | SOURCE="$(ogGetPath "$1")" |
|---|
| 109 | shift ;; |
|---|
| 110 | [1-9]*) # ndisco npartición. |
|---|
| 111 | SOURCE="$(ogGetPath "$1" "$2" "$3")" |
|---|
| 112 | shift 3 ;; |
|---|
| 113 | *) # Otros: repo, cache, cdrom (no se permiten caminos relativos). |
|---|
| 114 | SOURCE="$(ogGetPath "$1" "$2")" |
|---|
| 115 | shift 2 ;; |
|---|
| 116 | esac |
|---|
| 117 | # Comprobar fichero origen y directorio destino. |
|---|
| 118 | [ -n "$SOURCE" ] || ogRaiseError $OG_ERR_NOTFOUND "${ARGS% $*}" || return $? |
|---|
| 119 | TARGET="$(ogGetPath "$@")" |
|---|
| 120 | [ -n "$TARGET" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? |
|---|
| 121 | # Copiar fichero (para evitar problemas de comunicaciones las copias se hacen con rsync en vez de cp). |
|---|
| 122 | rsync --progress -avh "$SOURCE" "$TARGET" |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | #/** |
|---|
| 127 | # ogDeleteFile [ str_repo | int_ndisk int_npartition ] path_filepath |
|---|
| 128 | #@brief Metafunción que borra un fichero de un dispositivo. |
|---|
| 129 | #@see ogGetPath |
|---|
| 130 | #@version 0.9 - Pruebas con OpenGnSys. |
|---|
| 131 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 132 | #@date 2009-09-29 |
|---|
| 133 | #*/ ## |
|---|
| 134 | function ogDeleteFile () |
|---|
| 135 | { |
|---|
| 136 | # Variables locales. |
|---|
| 137 | local FILE |
|---|
| 138 | if [ "$*" == "help" ]; then |
|---|
| 139 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_file" \ |
|---|
| 140 | "$FUNCNAME 1 2 /tmp/newfile.txt" |
|---|
| 141 | return |
|---|
| 142 | fi |
|---|
| 143 | |
|---|
| 144 | # Comprobar que existe el fichero y borrarlo. |
|---|
| 145 | FILE="$(ogGetPath "$@")" |
|---|
| 146 | [ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? |
|---|
| 147 | rm -f "$FILE" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | #/** |
|---|
| 152 | # ogDeleteTree [ str_repo | int_ndisk int_npartition ] path_dirpath |
|---|
| 153 | #@brief Metafunción que borra todo un subárbol de directorios de un dispositivo. |
|---|
| 154 | #@see ogGetPath |
|---|
| 155 | #@version 0.9 - Pruebas con OpenGnSys. |
|---|
| 156 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 157 | #@date 2009-09-29 |
|---|
| 158 | #*/ ## |
|---|
| 159 | function ogDeleteTree () |
|---|
| 160 | { |
|---|
| 161 | # Variables locales. |
|---|
| 162 | local DIR |
|---|
| 163 | if [ "$*" == "help" ]; then |
|---|
| 164 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_dir" \ |
|---|
| 165 | "$FUNCNAME 1 2 /tmp/newdir" |
|---|
| 166 | return |
|---|
| 167 | fi |
|---|
| 168 | |
|---|
| 169 | # Comprobar que existe el directorio y borrarlo con su contenido. |
|---|
| 170 | DIR="$(ogGetPath "$@")" |
|---|
| 171 | [ -n "$DIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? |
|---|
| 172 | rm -fr "$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | #/** |
|---|
| 177 | # ogGetPath [ str_repo | int_ndisk int_npartition ] path_filepath |
|---|
| 178 | #@brief Inicia el proceso de arranque de un sistema de archivos. |
|---|
| 179 | #@param path_filepath camino del fichero (independiente de mayúsculas) |
|---|
| 180 | #@param str_repo repositorio de ficheros |
|---|
| 181 | #@param int_ndisk nº de orden del disco |
|---|
| 182 | #@param int_npartition nº de orden de la partición |
|---|
| 183 | #@return path_file - camino completo real del fichero. |
|---|
| 184 | #@note repo = { REPO, CACHE, CDROM } |
|---|
| 185 | #@note Requisitos: \c grep \c sed |
|---|
| 186 | #@exception OG_ERR_FORMAT Formato incorrecto. |
|---|
| 187 | #@exception OG_ERR_NOTFOUND Fichero o dispositivo no encontrado. |
|---|
| 188 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
|---|
| 189 | #@warning En caso de error, sólo devuelve el código y no da mensajes. |
|---|
| 190 | #@todo Terminar de definir parámetros para acceso a repositorios. |
|---|
| 191 | #@version 0.1 - Integracion para Opengnsys - HIDRA: CaminoWindows.sh; EAC: GetPath(), FormatSintaxSpacePath(), FormatSintaxBackSlashPath (), en FileSystem.lib |
|---|
| 192 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 193 | #@Date 2008/10/10 |
|---|
| 194 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
|---|
| 195 | #@date 2008/10/27 |
|---|
| 196 | #@version 0.9 - Pruebas con OpenGnSys. |
|---|
| 197 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 198 | #@date 2009-09-15 |
|---|
| 199 | #*/ ## |
|---|
| 200 | function ogGetPath () |
|---|
| 201 | { |
|---|
| 202 | # Variables locales. |
|---|
| 203 | local MNTDIR FILE PREVFILE FILEPATH CURRENTDIR |
|---|
| 204 | |
|---|
| 205 | # Si se solicita, mostrar ayuda. |
|---|
| 206 | if [ "$*" == "help" ]; then |
|---|
| 207 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \ |
|---|
| 208 | "$FUNCNAME \"/mnt/sda1/windows/system32\" ==> /mnt/sda1/WINDOWS/System32" \ |
|---|
| 209 | "$FUNCNAME REPO /etc/fstab ==> /opt/opengnsys/images/etc/fstab" \ |
|---|
| 210 | "$FUNCNAME 1 1 \"/windows/system32\" ==> /mnt/sda1/WINDOWS/System32" |
|---|
| 211 | return |
|---|
| 212 | fi |
|---|
| 213 | |
|---|
| 214 | # Procesar camino según el número de parámetros. |
|---|
| 215 | case $# in |
|---|
| 216 | 1) FILE="$1" ;; |
|---|
| 217 | 2) case "${1^^}" in |
|---|
| 218 | REPO) |
|---|
| 219 | FILE="$OGIMG/$2" ;; |
|---|
| 220 | CACHE) |
|---|
| 221 | MNTDIR="$(ogMountCache)" || return $? |
|---|
| 222 | FILE="$MNTDIR/$OGIMG/$2" ;; |
|---|
| 223 | CDROM) |
|---|
| 224 | MNTDIR="$(ogMountCdrom)" || return $? |
|---|
| 225 | FILE="$MNTDIR/$2" ;; |
|---|
| 226 | *) ogRaiseError $OG_ERR_FORMAT |
|---|
| 227 | return $? ;; |
|---|
| 228 | esac ;; |
|---|
| 229 | 3) MNTDIR="$(ogMount $1 $2)" || return $? |
|---|
| 230 | FILE="$MNTDIR/$3" ;; |
|---|
| 231 | *) ogRaiseError $OG_ERR_FORMAT |
|---|
| 232 | return $? ;; |
|---|
| 233 | esac |
|---|
| 234 | |
|---|
| 235 | # Eliminar caracteres \c / iniciales, finales y duplicados. |
|---|
| 236 | CURRENTDIR="$PWD" |
|---|
| 237 | # /* (comentario Doxygen) |
|---|
| 238 | FILE="$(echo $FILE|sed -e 's/\(\/\)*\1/\//g' -e 's/^\///' -e 's/\/$//')" |
|---|
| 239 | PREVFILE="" |
|---|
| 240 | FILEPATH="/" |
|---|
| 241 | while [ "$FILE" != "$PREVFILE" ]; do |
|---|
| 242 | # Busca el nombre correcto en el directorio actual. |
|---|
| 243 | cd "$FILEPATH" 2>/dev/null || FILE="" |
|---|
| 244 | FILEPATH="${FILEPATH}/$(ls -A 2>/dev/null | grep -i -m1 "^${FILE%%/*}$")" || return $? |
|---|
| 245 | PREVFILE="$FILE" |
|---|
| 246 | FILE="${FILE#*/}" |
|---|
| 247 | done |
|---|
| 248 | # (comentario Doxygen) */ |
|---|
| 249 | # Muestra el camino Linux, quitando el / inicial duplicado. |
|---|
| 250 | [ "$FILEPATH" != "/" ] && echo ${FILEPATH#/} |
|---|
| 251 | cd $CURRENTDIR |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | #/** |
|---|
| 256 | # ogGetParentPath [ str_repo | int_ndisk int_npartition ] path_filepath |
|---|
| 257 | #@brief Metafunción que devuelve el camino del directorio padre. |
|---|
| 258 | #@see ogGetPath |
|---|
| 259 | #@version 0.9 - Pruebas con OpenGnSys. |
|---|
| 260 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 261 | #@date 2009-09-29 |
|---|
| 262 | #*/ ## |
|---|
| 263 | function ogGetParentPath () |
|---|
| 264 | { |
|---|
| 265 | local PARENT |
|---|
| 266 | if [ "$*" == "help" ]; then |
|---|
| 267 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \ |
|---|
| 268 | "$FUNCNAME \"/mnt/sda1/windows/system32\" ==> /mnt/sda1/WINDOWS" \ |
|---|
| 269 | "$FUNCNAME REPO /etc/fstab ==> /opt/opengnsys/images/etc" \ |
|---|
| 270 | "$FUNCNAME 1 1 \"/windows/system32\" ==> /mnt/sda1/WINDOWS" |
|---|
| 271 | return |
|---|
| 272 | fi |
|---|
| 273 | |
|---|
| 274 | case $# in |
|---|
| 275 | 1) PARENT="$(dirname "$1")" ;; |
|---|
| 276 | 2) PARENT="$1 $(dirname "/$2")" ;; |
|---|
| 277 | 3) PARENT="$1 $2 $(dirname "/$3")" ;; |
|---|
| 278 | *) ogRaiseError $OG_ERR_FORMAT |
|---|
| 279 | return $? ;; |
|---|
| 280 | esac |
|---|
| 281 | ogGetPath $PARENT |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | |
|---|
| 285 | #/** |
|---|
| 286 | # ogIsNewerFile [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target |
|---|
| 287 | #@brief Metafunción que indica se un fichero es más nuevo que otro. |
|---|
| 288 | #@see ogGetPath |
|---|
| 289 | #@return Código de salida: 0 - nuevo, 1 - antiguo o error |
|---|
| 290 | #@warning Deben existir tanto el fichero origen como el destino. |
|---|
| 291 | #@version 0.9.2 - Primera versión para OpenGnSys. |
|---|
| 292 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 293 | #@date 2010-07-24 |
|---|
| 294 | #@version 1.0.1 - Devolver falso en caso de error. |
|---|
| 295 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 296 | #@date 2011-05-18 |
|---|
| 297 | #*/ ## |
|---|
| 298 | function ogIsNewerFile () |
|---|
| 299 | { |
|---|
| 300 | # Variables locales. |
|---|
| 301 | local ARGS SOURCE TARGET |
|---|
| 302 | # Si se solicita, mostrar ayuda. |
|---|
| 303 | if [ "$*" == "help" ]; then |
|---|
| 304 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_source [ str_repo | int_ndisk int_npartition ] path_target" \ |
|---|
| 305 | "if $FUNCNAME REPO ubuntu.img CACHE ubuntu.img; then ... fi" |
|---|
| 306 | return |
|---|
| 307 | fi |
|---|
| 308 | |
|---|
| 309 | ARGS="$@" |
|---|
| 310 | case "$1" in |
|---|
| 311 | /*) # Camino completo. */ (Comentrio Doxygen) |
|---|
| 312 | SOURCE="$(ogGetPath "$1")" |
|---|
| 313 | shift ;; |
|---|
| 314 | [1-9]*) # ndisco npartición. |
|---|
| 315 | SOURCE="$(ogGetPath "$1" "$2" "$3")" |
|---|
| 316 | shift 3 ;; |
|---|
| 317 | *) # Otros: repo, cache, cdrom (no se permiten caminos relativos). |
|---|
| 318 | SOURCE="$(ogGetPath "$1" "$2")" |
|---|
| 319 | shift 2 ;; |
|---|
| 320 | esac |
|---|
| 321 | # Comprobar que existen los ficheros origen y destino. |
|---|
| 322 | [ -n "$SOURCE" ] || ogRaiseError $OG_ERR_NOTFOUND "${ARGS% $*}" || return 1 |
|---|
| 323 | TARGET=$(ogGetPath "$@") |
|---|
| 324 | [ -n "$TARGET" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return 1 |
|---|
| 325 | # Devolver si el primer fichero se ha modificado después que el segundo. |
|---|
| 326 | test "$SOURCE" -nt "$TARGET" |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | #/** |
|---|
| 331 | # ogMakeChecksumFile [ str_repo | int_ndisk int_npart ] path_filepath |
|---|
| 332 | #@brief Metafunción que guarda el valor de comprobación de un fichero. |
|---|
| 333 | #@see ogCalculateChecksum |
|---|
| 334 | #@warning Genera un fichero con extensión ".sum". |
|---|
| 335 | #@version 0.9.2 - Primera versión para OpenGnSys. |
|---|
| 336 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 337 | #@date 2010-07-24 |
|---|
| 338 | #*/ ## |
|---|
| 339 | function ogMakeChecksumFile () |
|---|
| 340 | { |
|---|
| 341 | # Variables locales. |
|---|
| 342 | local FILE |
|---|
| 343 | if [ "$*" == "help" ]; then |
|---|
| 344 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \ |
|---|
| 345 | "$FUNCNAME REPO ubuntu.img" |
|---|
| 346 | return |
|---|
| 347 | fi |
|---|
| 348 | |
|---|
| 349 | # Comprobar que existe el fichero y guardar su checksum. |
|---|
| 350 | FILE="$(ogGetPath "$@")" |
|---|
| 351 | [ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? |
|---|
| 352 | ogCalculateChecksum "$FILE" > "$FILE.sum" |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | |
|---|
| 356 | #/** |
|---|
| 357 | # ogMakeDir [ str_repo | int_ndisk int_npartition ] path_dirpath |
|---|
| 358 | #@brief Metafunción que crea un subdirectorio vacío en un dispositivo. |
|---|
| 359 | #@see ogGetParentPath |
|---|
| 360 | #@version 0.1 - Integracion para Opengnsys - HIDRA: CrearDirectorio.sh, EAC: MkdirPath() en FileSystem.lib |
|---|
| 361 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 362 | #@Date 2008/10/10 |
|---|
| 363 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
|---|
| 364 | #@date 2008/10/27 |
|---|
| 365 | #@version 0.9 - Pruebas con OpenGnSys. |
|---|
| 366 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
|---|
| 367 | #@date 2009-09-29 |
|---|
| 368 | #*/ ## |
|---|
| 369 | function ogMakeDir () |
|---|
| 370 | { |
|---|
| 371 | local PARENT DIR |
|---|
| 372 | if [ "$*" == "help" ]; then |
|---|
| 373 | ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_dir" \ |
|---|
| 374 | "$FUNCNAME 1 2 /tmp/newdir" |
|---|
| 375 | return |
|---|
| 376 | fi |
|---|
| 377 | |
|---|
| 378 | PARENT="$(ogGetParentPath "$@")" || return $? |
|---|
| 379 | DIR="$(basename "${!#}")" |
|---|
| 380 | mkdir -p "$PARENT/$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? |
|---|
| 381 | } |
|---|
| 382 | |
|---|