source: admin/Interface/Configurar @ a3e5d74

Last change on this file since a3e5d74 was 5d05b06, checked in by OpenGnSys Support Team <soporte-og@…>, 4 years ago

#1008 Add support to work with GPT tables

WebConsole? needs to rely on /shell/run to work with GPT tables. Because
"Partition and Format"/"Particionar y Formatear" form always supposes
that the partition table is MBR/MSDOS.

"Setup"/"Configurar" script from "Cloning Engine" also supposes that the
partition table is MBR/MSDOS. But it uses "Boot.lib" library, that can
create MBR and GTP partitions.

This commit:

  • Adds WebConsole? support to work with GPT tables.
    • Adds input field where the user can select between MSDOS and GPT table types.
  • Adds "Setup" support to work with GPT tables.
    • Adds script parameter that expects a string with "MSDOS" or "GPT".
  • Property mode set to 100755
File size: 5.2 KB
RevLine 
[3ec149c]1#!/bin/bash
2
[e034672]3
4#Load engine configurator from engine.cfg file.
5#Carga el configurador del engine desde el fichero engine.cfg
6[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
7       
8# Clear temporary file used as log track by httpdlog
9# Limpia los ficheros temporales usados como log de seguimieincludento para httpdlog
10echo " " > $OGLOGSESSION; echo " " > $OGLOGCOMMAND; echo " " > ${OGLOGCOMMAND}.tmp
11       
12# Registro de inicio de ejecución
[0483b14]13ogEcho log session "$MSG_INTERFACE_START $0 $*"
[314dafb]14
[d7fe54a]15# Solo ejecutable por OpenGnsys Client.
[e034672]16PATH=$PATH:$(dirname $0)
17PROG=$(basename $0)
18
19#____________________________________________________________________
[3ec149c]20#
[e034672]21# El parámetro $2 es el que aporta toda la información y el $1 se queda obsoleto
[3ec149c]22# Formato de entrada:
[e034672]23#               dis=Número de disco
[314dafb]24#               *=caracter de separación
[e034672]25#               che=Vale 0 o 1
[314dafb]26#               *=caracter de separación
[e034672]27#               $tch=tamaño cache
[314dafb]28#               != caracter de separación
[e034672]29#
30#   Y un numero indeterminado de cadenas del tipo siguuenteseparadas por el caracter '$':
[314dafb]31#               par=Número de particion*cod=Código de partición*sfi=Sistema de ficheros*tam=Tamaño de la partición*ope=Operación
32#               @= caracter de separación
[e034672]33#____________________________________________________________________
[3ec149c]34
[5d05b06]35tabletype=$1
36
[314dafb]37# Captura de parámetros (se ignora el 1er parámetro y se eliminan espacios y tabuladores).
38#param='dis=1*che=0*tch=70000000!par=1*cpt=NTFS*sfi=NTFS*tam=11000000*ope=0%'
[5d05b06]39param="$(echo $2 | sed 's/[     ]//g')"
[3997593]40
41# Activa navegador para ver progreso
[e034672]42coproc /opt/opengnsys/bin/browser -qws http://localhost/cgi-bin/httpd-log.sh
[3997593]43
[314dafb]44# Leer los dos bloques de parámetros, separados por '!'.
[e034672]45declare -a TBPRM
[3997593]46
[314dafb]47IFS='!' read -a TBPRM <<<"$param"
48pparam="${TBPRM[0]}"    # Parámetros generales del disco.
49sparam="${TBPRM[1]}"    # Parámetros de particionado y formateo.
50
51
52# Toma valores de disco y caché, separados por "*".
53# Los valores están en las variables $dis: disco, $che: existe cache (1, 0), $tch: Tamaño de la cache.
54unset TBPRM
55IFS='*' read -a TBPRM <<<"$pparam"
56[[ ${TBPRM} =~ = ]] && eval ${TBPRM[@]}         # Comprobar asignación antes de exportar valores.
57
58# Error si no se define el parámetro de disco (dis).
59[ -z "$dis" ] && exit $OG_ERR_FORMAT
60
61# Toma valores de distribución de particiones, separados por "%".
62declare -a CFG          # Valores de configuración.
63declare -a TBP          # Tabla de particionado.
64declare -a TBF          # Tabla de formateo.
65
66unset TBPRM
67IFS='%' read -a TBPRM <<<"$sparam"
68
69maxp=0
70for ((i=0; i<${#TBPRM[@]}; i++)); do
[1a2fa9d8]71        # Leer datos de la partición, separados por "*".
72        unset par
73        IFS='*' read -a CFG <<<"${TBPRM[i]}" 2>/dev/null
74        [[ ${CFG} =~ = ]] && eval ${CFG[@]}     # Comprobar asignación antes de exportar valores.
75        # Componer datos de particionado.
76        if [ "$cpt" != "CACHE" ]; then
77                        TBP[par]="$cpt:$tam"
78        fi
79        # Si se activa operación de formatear, componer datos de formateo.
80        if [ "$ope" == 1 ]; then
81           # Comprobamos que la particion y el s.f sean validos.
[a616248]82           ogCheckStringInGroup $cpt "EMPTY EXTENDED LINUX-LVM LVM ZPOOL"
[1a2fa9d8]83           [ $? -ne 0 ] && TBF[par]="$sfi"
84        fi
85        # Obtener la partición mayor.
86        [ $par -gt $maxp ] && maxp=$par
[314dafb]87done
[e034672]88#____________________________________________________
89#
90# Proceso
91#____________________________________________________
92
[1a2fa9d8]93# Tamaño actual de la cache
94CACHESIZE=$(ogGetCacheSize)
[3997593]95
96# Desmonta todas las particiones y la caché
[1a2fa9d8]97
98ogEcho session log "[10] $MSG_HELP_ogUnmountAll"
[314dafb]99ogUnmountAll $dis &>/dev/null
[1a2fa9d8]100ogUnmountCache
[e034672]101
102# Elimina la tabla de particiones
[1a2fa9d8]103ogDeletePartitionTable $dis
104ogExecAndLog COMMAND ogUpdatePartitionTable $dis
[e034672]105
[314dafb]106# Crea tabla de particiones MSDOS (NOTA: adaptar para tablas GPT).
[5d05b06]107ogCreatePartitionTable "$dis" "$tabletype"
[e034672]108
[1a2fa9d8]109# Inicia la cache.
110if echo "$sparam" |grep "CACHE" >/dev/null; then
111        ogEcho session log "[30] $MSG_HELP_ogCreateCache"
[4c4ea595]112        ogEcho session log "   initCache  $dis $tch"
113        ogExecAndLog COMMAND  initCache $dis $tch
[e04f987]114fi
115
116# Definir particionado.
[1a2fa9d8]117ogEcho session log "[50] $MSG_HELP_ogCreatePartitions"
118ogEcho session log "   ogCreatePartitions $dis ${TBP[@]}"
119ogExecAndLog COMMAND ogCreatePartitions $dis ${TBP[@]}
120if [ $? -ne 0 ]; then
121        kill $COPROC_PID
122        exit $(ogRaiseError session log $OG_ERR_GENERIC "ogCreatePartitions $dis ${TBP[@]}")
123fi
124ogExecAndLog COMMAND ogUpdatePartitionTable $dis
[314dafb]125
[1a2fa9d8]126#  Formatear particiones
127ogEcho session log "[70] $MSG_HELP_ogFormat"
[314dafb]128
129for ((par=1; par<=$maxp; par++)); do
[1a2fa9d8]130        case "${TBF[par]}" in
131                CACHE)  # Si el tamaño es distinto ya se ha formateado.
132                        if [ "$CACHESIZE" == $tch ]; then
133                           ogEcho session log "   ogFormatCache"
134                           ogExecAndLog COMMAND ogFormatCache
135                        fi
136                ;;
137                "") ;;
138                *) ogEcho session log "   ogFormatFs $dis $par ${TBF[par]}"
139                   ogExecAndLog COMMAND ogFormatFs $dis $par ${TBF[par]}
140                   if [ $? -ne 0 ]; then
141                        kill $COPROC_PID
142                        exit $(ogRaiseError session log $OG_ERR_GENERIC "ogFormatFs  $dis $par ${TBF[par]}");
143                   fi
144                ;;
145        esac
146done
147RETVAL=$?
148# Registro de fin de ejecución
149ogEcho log session "$MSG_INTERFACE_END $RETVAL"
[e034672]150
[3997593]151#___________________________________________________________________
152#
153# Retorno
154#___________________________________________________________________
155
[314dafb]156kill $COPROC_PID
157exit 0
[3997593]158
Note: See TracBrowser for help on using the repository browser.