source: admin/Interface/Configurar

qndtest
Last change on this file was b391e9a, checked in by Irina Gómez <irinagomez@…>, 2 years ago

#1066 #1072 The partitioning command or wizard deletes the partition table only when the partition table type is different from the one defined in the parameter.

  • Property mode set to 100755
File size: 5.3 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
35# Captura de parámetros (se ignora el 1er parámetro y se eliminan espacios y tabuladores).
36#param='dis=1*che=0*tch=70000000!par=1*cpt=NTFS*sfi=NTFS*tam=11000000*ope=0%'
37shift
38param="$(echo $* | sed 's/[     ]//g')"
39
40# Activa navegador para ver progreso
41coproc /opt/opengnsys/bin/browser -qws http://localhost/cgi-bin/httpd-log.sh
42
43# Leer los dos bloques de parámetros, separados por '!'.
44declare -a TBPRM
45
46IFS='!' read -a TBPRM <<<"$param"
47pparam="${TBPRM[0]}"    # Parámetros generales del disco.
48sparam="${TBPRM[1]}"    # Parámetros de particionado y formateo.
49
50
51# Toma valores de disco y caché, separados por "*".
52# Los valores están en las variables $dis: disco, $che: existe cache (1, 0), $tch: Tamaño de la cache.
53unset TBPRM
54IFS='*' read -a TBPRM <<<"$pparam"
55[[ ${TBPRM} =~ = ]] && eval ${TBPRM[@]}         # Comprobar asignación antes de exportar valores.
56
57# Error si no se define el parámetro de disco (dis).
58[ -z "$dis" ] && exit $OG_ERR_FORMAT
59
60# Toma valores de distribución de particiones, separados por "%".
61declare -a CFG          # Valores de configuración.
62declare -a TBP          # Tabla de particionado.
63declare -a TBF          # Tabla de formateo.
64
65unset TBPRM
66IFS='%' read -a TBPRM <<<"$sparam"
67
68maxp=0
69for ((i=0; i<${#TBPRM[@]}; i++)); do
70        # Leer datos de la partición, separados por "*".
71        unset par
72        IFS='*' read -a CFG <<<"${TBPRM[i]}" 2>/dev/null
73        [[ ${CFG} =~ = ]] && eval ${CFG[@]}     # Comprobar asignación antes de exportar valores.
74        # Componer datos de particionado.
75        if [ "$cpt" != "CACHE" ]; then
76                        TBP[par]="$cpt:$tam"
77        fi 
78        # Si se activa operación de formatear, componer datos de formateo.
79        if [ "$ope" == 1 ]; then
80           # Comprobamos que la particion y el s.f sean validos.
81           ogCheckStringInGroup $cpt "EMPTY EXTENDED LINUX-LVM LVM ZPOOL"
82           [ $? -ne 0 ] && TBF[par]="$sfi"
83        fi
84        # Obtener la partición mayor.
85        [ $par -gt $maxp ] && maxp=$par
86done
87#____________________________________________________
88#
89# Proceso
90#____________________________________________________
91
92# Tamaño actual de la cache
93CACHESIZE=$(ogGetCacheSize)
94
95# Desmonta todas las particiones y la caché
96
97ogEcho session log "[10] $MSG_HELP_ogUnmountAll"
98ogUnmountAll $dis &>/dev/null
99ogUnmountCache
100
101# Elimina la tabla de particiones
102if [ `ogGetPartitionTableType 1` != 'MSDOS' ]; then
103        ogDeletePartitionTable $dis
104        ogExecAndLog COMMAND ogUpdatePartitionTable $dis
105
106        # Crea tabla de particiones MSDOS (NOTA: adaptar para tablas GPT).
107        ogCreatePartitionTable $dis MSDOS
108fi
109
110# Inicia la cache.
111if echo "$sparam" |grep "CACHE" >/dev/null; then
112        ogEcho session log "[30] $MSG_HELP_ogCreateCache"
113        ogEcho session log "   initCache $tch"
114        ogExecAndLog COMMAND  initCache $tch
115fi
116
117# Definir particionado.
118ogEcho session log "[50] $MSG_HELP_ogCreatePartitions"
119ogEcho session log "   ogCreatePartitions $dis ${TBP[@]}"
120ogExecAndLog COMMAND ogCreatePartitions $dis ${TBP[@]}
121if [ $? -ne 0 ]; then
122        kill $COPROC_PID
123        exit $(ogRaiseError session log $OG_ERR_GENERIC "ogCreatePartitions $dis ${TBP[@]}")
124fi
125ogExecAndLog COMMAND ogUpdatePartitionTable $dis
126
127#  Formatear particiones
128ogEcho session log "[70] $MSG_HELP_ogFormat"
129
130for ((par=1; par<=$maxp; par++)); do
131        case "${TBF[par]}" in
132                CACHE)  # Si el tamaño es distinto ya se ha formateado.
133                        if [ "$CACHESIZE" == $tch ]; then
134                           ogEcho session log "   ogFormatCache"
135                           ogExecAndLog COMMAND ogFormatCache
136                        fi
137                ;;
138                "") ;;
139                *) ogEcho session log "   ogFormatFs $dis $par ${TBF[par]}"
140                   ogExecAndLog COMMAND ogFormatFs $dis $par ${TBF[par]}
141                   if [ $? -ne 0 ]; then
142                        kill $COPROC_PID
143                        exit $(ogRaiseError session log $OG_ERR_GENERIC "ogFormatFs  $dis $par ${TBF[par]}");
144                   fi
145                ;;
146        esac
147done
148RETVAL=$?
149# Registro de fin de ejecución
150ogEcho log session "$MSG_INTERFACE_END $RETVAL"
151
152#___________________________________________________________________
153#
154# Retorno
155#___________________________________________________________________
156
157kill $COPROC_PID
158exit 0
159
Note: See TracBrowser for help on using the repository browser.