source: admin/Interface/Configurar @ 5d05b06

Last change on this file since 5d05b06 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
Line 
1#!/bin/bash
2
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
13ogEcho log session "$MSG_INTERFACE_START $0 $*"
14
15# Solo ejecutable por OpenGnsys Client.
16PATH=$PATH:$(dirname $0)
17PROG=$(basename $0)
18
19#____________________________________________________________________
20#
21# El parámetro $2 es el que aporta toda la información y el $1 se queda obsoleto
22# Formato de entrada:
23#               dis=Número de disco
24#               *=caracter de separación
25#               che=Vale 0 o 1
26#               *=caracter de separación
27#               $tch=tamaño cache
28#               != caracter de separación
29#
30#   Y un numero indeterminado de cadenas del tipo siguuenteseparadas por el caracter '$':
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
33#____________________________________________________________________
34
35tabletype=$1
36
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%'
39param="$(echo $2 | sed 's/[     ]//g')"
40
41# Activa navegador para ver progreso
42coproc /opt/opengnsys/bin/browser -qws http://localhost/cgi-bin/httpd-log.sh
43
44# Leer los dos bloques de parámetros, separados por '!'.
45declare -a TBPRM
46
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
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.
82           ogCheckStringInGroup $cpt "EMPTY EXTENDED LINUX-LVM LVM ZPOOL"
83           [ $? -ne 0 ] && TBF[par]="$sfi"
84        fi
85        # Obtener la partición mayor.
86        [ $par -gt $maxp ] && maxp=$par
87done
88#____________________________________________________
89#
90# Proceso
91#____________________________________________________
92
93# Tamaño actual de la cache
94CACHESIZE=$(ogGetCacheSize)
95
96# Desmonta todas las particiones y la caché
97
98ogEcho session log "[10] $MSG_HELP_ogUnmountAll"
99ogUnmountAll $dis &>/dev/null
100ogUnmountCache
101
102# Elimina la tabla de particiones
103ogDeletePartitionTable $dis
104ogExecAndLog COMMAND ogUpdatePartitionTable $dis
105
106# Crea tabla de particiones MSDOS (NOTA: adaptar para tablas GPT).
107ogCreatePartitionTable "$dis" "$tabletype"
108
109# Inicia la cache.
110if echo "$sparam" |grep "CACHE" >/dev/null; then
111        ogEcho session log "[30] $MSG_HELP_ogCreateCache"
112        ogEcho session log "   initCache  $dis $tch"
113        ogExecAndLog COMMAND  initCache $dis $tch
114fi
115
116# Definir particionado.
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
125
126#  Formatear particiones
127ogEcho session log "[70] $MSG_HELP_ogFormat"
128
129for ((par=1; par<=$maxp; par++)); do
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"
150
151#___________________________________________________________________
152#
153# Retorno
154#___________________________________________________________________
155
156kill $COPROC_PID
157exit 0
158
Note: See TracBrowser for help on using the repository browser.