[3ec149c] | 1 | #!/bin/bash |
---|
| 2 | |
---|
[f6c1d2b] | 3 | #___________________________________________________ |
---|
[3ec149c] | 4 | # |
---|
| 5 | # PARAMETROS RECIBIDOS DESDE EL CLIENTE: |
---|
[f6c1d2b] | 6 | # $1 Número de disco |
---|
| 7 | # $2 Número de particion |
---|
| 8 | # $3 Nombre canónico de la imagen (sin extensión) |
---|
| 9 | # $4 Dirección del repositorio (REPO, por defecto) |
---|
| 10 | #___________________________________________________ |
---|
[914d834] | 11 | |
---|
[ad1f809] | 12 | |
---|
| 13 | #$OG_ERR_NOTEXEC Si no es llamada por OG client |
---|
| 14 | #$OG_ERR_LOCKED=4 Si la particion está bloqueada. |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #Codigos de error del scripts createImage |
---|
| 18 | #@exception OG_ERR_FORMAT # 1 formato incorrecto. |
---|
| 19 | #@exception OG_ERR_PARTITION # 3 Error en partición de disco o en su sistema de archivos |
---|
| 20 | #@exception OG_ERR_IMAGE # 5 Error en funcion ogCreateImage o ogRestoreImage. |
---|
| 21 | #@exception OG_ERR_NOTWRITE # 14 error de escritura |
---|
| 22 | #@exception OG_ERR_NOTCACHE # 15 si cache no existe 15 |
---|
| 23 | #@exception OG_ERR_CACHESIZE # 16 si espacio de la cache local o remota no tiene espacio 16 |
---|
| 24 | #@exception OG_ERR_REDUCEFS # 17 error al reducir sistema de archivos. |
---|
| 25 | #@exception OG_ERR_EXTENDFS # 18 Errror al expandir el sistema de archivos. |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | #Códigos de error de la funcion ogCreateImage |
---|
| 29 | |
---|
| 30 | |
---|
[f311787] | 31 | |
---|
[e272d9e] | 32 | TIME1=$SECONDS |
---|
[ad1f809] | 33 | |
---|
[e272d9e] | 34 | #Load engine configurator from engine.cfg file. |
---|
| 35 | #Carga el configurador del engine desde el fichero engine.cfg |
---|
| 36 | [ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg |
---|
[914d834] | 37 | |
---|
[e272d9e] | 38 | # Clear temporary file used as log track by httpdlog |
---|
| 39 | # Limpia los ficheros temporales usados como log de seguimiento para httpdlog |
---|
| 40 | echo " " > $OGLOGSESSION; echo " " > $OGLOGCOMMAND; echo " " > ${OGLOGCOMMAND}.tmp |
---|
[f311787] | 41 | |
---|
[e272d9e] | 42 | # Registro de inicio de ejecución |
---|
[0483b14] | 43 | ogEcho log session "$MSG_INTERFACE_START $0 $*" |
---|
[f311787] | 44 | |
---|
[d7fe54a] | 45 | # Solo ejecutable por OpenGnsys Client. |
---|
[f6c1d2b] | 46 | PATH=$PATH:$(dirname $0) |
---|
| 47 | PROG=$(basename $0) |
---|
| 48 | CALLER=$(ogGetCaller) |
---|
[c90cda4] | 49 | #if [ "$CALLER" != "ogAdmClient" ]; then |
---|
| 50 | # ogRaiseError $OG_ERR_NOTEXEC "$CALLER -> $PROG" |
---|
| 51 | # exit $? |
---|
| 52 | #fi |
---|
[914d834] | 53 | |
---|
[f6c1d2b] | 54 | # Valor por defecto para el repositorio. |
---|
[16ac86e] | 55 | REPO=${4:-"REPO"} |
---|
| 56 | [ "$REPO" == "$(ogGetIpAddress)" ] && REPO="CACHE" |
---|
[4ceafc1] | 57 | # Si es una ip y es distinta a la del recurso samba cambiamos de REPO. |
---|
| 58 | ogCheckIpAddress $REPO |
---|
| 59 | if [ $? == 0 -o $REPO == "REPO" ] ; then |
---|
[79a4175] | 60 | # Unidad organizativa |
---|
| 61 | [ "$ogunit" != "" ] && OGUNIT="$ogunit" |
---|
[4ceafc1] | 62 | # Si falla el cambio -> salimos con error repositorio no valido |
---|
[79a4175] | 63 | ogChangeRepo $REPO $OGUNIT || exit $(ogRaiseError $OG_ERR_NOTFOUND '$REPO'; echo $?) |
---|
[4ceafc1] | 64 | REPO="REPO" |
---|
| 65 | fi |
---|
[ad1f809] | 66 | |
---|
| 67 | # Si el destino es REPO y el cliente no está en modo "admin"; activar repositorio para escritura, |
---|
| 68 | if [ "$REPO" == "REPO" -a "$boot" != "admin" ] |
---|
| 69 | then |
---|
| 70 | CambiarAcceso admin &>> $OGLOGFILE |
---|
| 71 | RETVAL=$? |
---|
| 72 | [ $RETVAL -gt 0 ] && exit $RETVAL |
---|
| 73 | fi |
---|
| 74 | |
---|
[4ceafc1] | 75 | ogEcho createImage "$1" "$2" "$4" /"$3" |
---|
[a6d2a27] | 76 | # Si existe, ejecuta script personalizado "createImageCustom"; si no, llama al genérico "createImage". |
---|
| 77 | if which createImageCustom &>/dev/null; then |
---|
[4ceafc1] | 78 | createImageCustom "$1" "$2" "$4" /"$3" &>> $OGLOGCOMMAND |
---|
[d9d1720] | 79 | else |
---|
[4ceafc1] | 80 | createImage "$1" "$2" "$4" /"$3" &>> $OGLOGCOMMAND |
---|
[d9d1720] | 81 | fi |
---|
[f6c1d2b] | 82 | RETVAL=$? |
---|
[ad1f809] | 83 | |
---|
[a6d2a27] | 84 | # Cambiar acceso a modo usuario, si es necesario. |
---|
[ad1f809] | 85 | [ "$REPO" == "REPO" -a "$boot" != "admin" ] && CambiarAcceso user |
---|
| 86 | |
---|
[e272d9e] | 87 | # Registro de fin de ejecución |
---|
[0483b14] | 88 | ogEcho log session "$MSG_INTERFACE_END $RETVAL" |
---|
[ad1f809] | 89 | |
---|
[f6c1d2b] | 90 | exit $RETVAL |
---|
[d9d1720] | 91 | |
---|