[eb3e2b8] | 1 | // *********************************************************************************************************** |
---|
| 2 | // Libreria de scripts de Javascript |
---|
| 3 | // Autor: |
---|
| 4 | // Fecha Creación: 2011 |
---|
| 5 | // Fecha Ãltima modificación: enero-2011 |
---|
| 6 | // Nombre del fichero: asistentes.js |
---|
| 7 | // Descripción : |
---|
| 8 | // Este fichero implementa las funciones javascript del fichero AsistentesEjecutarScripts.php (Comandos) |
---|
[0285a39] | 9 | // version 1.1: cliente con varios repositorios - Imagenes de todos los repositorios de la UO. |
---|
| 10 | // autor: Irina Gomez, Universidad de Sevilla |
---|
| 11 | // fecha 2015-06-17 |
---|
[502daab] | 12 | // version 1.1: showPartitionForm: Se incluye aviso para particiones GTP. |
---|
| 13 | // autor: Irina Gomez, ETSII Universidad de Sevilla |
---|
| 14 | // fecha: 2016-06-21 |
---|
[ab79b5e] | 15 | // version 1.1: codeDeployImage: Compone atributo para el comando restaurar imagen (ticket #757) |
---|
| 16 | // autor: Irina Gomez, ETSII Universidad de Sevilla |
---|
| 17 | // fecha: 2016-10-27 |
---|
[eb3e2b8] | 18 | // *********************************************************************************************************** |
---|
| 19 | |
---|
| 20 | function codeCloneRemotePartition(form){ |
---|
[a710997] | 21 | var command ; |
---|
[62ccd9b] | 22 | switch (form.idmetodo.value) |
---|
| 23 | { |
---|
| 24 | case "MULTICAST": |
---|
| 25 | protocol="MULTICAST " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " "; |
---|
| 26 | break; |
---|
| 27 | case "UNICAST": |
---|
| 28 | protocol="UNICAST " + form.ucastport.value + ":" + form.ucastclient.value + " "; |
---|
| 29 | break; |
---|
| 30 | } |
---|
| 31 | //form.codigo.value="cloneRemoteFromMaster " + form.ipMaster.value + " 1 " + form.PartOrigen.value + " " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " 1 " + form.PartOrigen.value + " " + form.tool.value + " " + form.compresor.value; |
---|
[f311787] | 32 | command="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value; |
---|
| 33 | form.codigo.value="\ |
---|
[a710997] | 34 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \ |
---|
[9a1df17] | 35 | ogExecAndLog command " + command + " \n "; |
---|
[eb3e2b8] | 36 | } |
---|
| 37 | |
---|
[1a2fa9d8] | 38 | // disableDirect(form): En Deploy de imagenes si se elige updateCache se impide elegir multicast-direct o unicast-direct |
---|
| 39 | function disableDirect(form){ |
---|
| 40 | // MULTICAST-DIRECT |
---|
| 41 | form.idmetodo.options[2].disabled=true; |
---|
| 42 | // UNICAST-DIRECT |
---|
| 43 | form.idmetodo.options[4].disabled=true; |
---|
| 44 | } |
---|
| 45 | // enableDirect(form): En Deploy de imagenes si se elige deployCache se permite elegir multicast-direct o unicast-direct |
---|
| 46 | function enableDirect(form){ |
---|
| 47 | // MULTICAST-DIRECT |
---|
| 48 | form.idmetodo.options[2].disabled=false; |
---|
| 49 | // UNICAST-DIRECT |
---|
| 50 | form.idmetodo.options[4].disabled=false; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | |
---|
[eb3e2b8] | 54 | function codeDeployImage(form){ |
---|
| 55 | switch (form.idmetodo.value) |
---|
| 56 | { |
---|
| 57 | case "MULTICAST": |
---|
| 58 | protocol="MULTICAST " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " "; |
---|
| 59 | break; |
---|
[1a2fa9d8] | 60 | case "MULTICAST-DIRECT": |
---|
| 61 | protocol="MULTICAST-DIRECT " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " "; |
---|
| 62 | break; |
---|
[eb3e2b8] | 63 | case "TORRENT": |
---|
[ab79b5e] | 64 | protocol="TORRENT " + form.modp2p.value + ":" + form.timep2p.value; |
---|
[eb3e2b8] | 65 | break; |
---|
[3b3043b] | 66 | case "UNICAST": |
---|
[ab79b5e] | 67 | protocol="UNICAST"; |
---|
[3b3043b] | 68 | break; |
---|
[1a2fa9d8] | 69 | case "UNICAST-DIRECT": |
---|
[ab79b5e] | 70 | protocol="UNICAST-DIRECT"; |
---|
[1a2fa9d8] | 71 | break; |
---|
[eb3e2b8] | 72 | } |
---|
[26c54b6] | 73 | |
---|
| 74 | // Datos imagen |
---|
| 75 | var imagen = form.idimagen.value.split("_"); |
---|
| 76 | |
---|
[eb3e2b8] | 77 | //form.codigo.value="deployImage REPO /"; |
---|
[3b3043b] | 78 | if (form.modo[0].checked) |
---|
| 79 | { |
---|
[b2651a6] | 80 | // UHU - Distinguimos entre disco y particion, el valor de idparticion sera disco;particion. eje. 1;1 |
---|
| 81 | var diskPart = form.idparticion.value.split(";"); |
---|
[349f70c] | 82 | var imagen = form.idimagen.value.split("_"); |
---|
[26c54b6] | 83 | command="deployImage " + imagen[0] + " /" + imagen[1] + " "+diskPart[0]+" " + diskPart[1] + " " + protocol ; |
---|
[f311787] | 84 | form.codigo.value="\ |
---|
[d1795da] | 85 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \ " + |
---|
[4fcbcc8] | 86 | command + " \n"; |
---|
[ab79b5e] | 87 | |
---|
| 88 | // Atributos para comando RestaurarImagen |
---|
| 89 | form.atrib_restore.value = "dsk=" + diskPart[0] + "@par="+ diskPart[1] +"@idi=" +imagen[2] + |
---|
| 90 | "@nci="+imagen[1] + "@ipr="+ imagen[0] +"@ifs=" +imagen[3] + |
---|
| 91 | "@ptc="+protocol +"@"; |
---|
[3b3043b] | 92 | } |
---|
| 93 | else |
---|
| 94 | { |
---|
[26c54b6] | 95 | command="updateCache REPO /" + imagen[1] + ".img" + " " + protocol ; |
---|
[f311787] | 96 | form.codigo.value="\ |
---|
[d1795da] | 97 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command +"\"\n \ " + |
---|
| 98 | command + " \n"; |
---|
[f311787] | 99 | //form.codigo.value="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
[3b3043b] | 100 | } |
---|
| 101 | |
---|
[eb3e2b8] | 102 | } |
---|
| 103 | |
---|
[a91defc] | 104 | // Activa el área de texto del código, permitiendo modificarlo. |
---|
| 105 | function modificarCodigo() { |
---|
| 106 | document.getElementById("codigo").disabled = false; |
---|
| 107 | } |
---|
| 108 | |
---|
[f5d9d43] | 109 | function codeParticionado(form){ |
---|
[2e69949] | 110 | var errorMsg = "¡El espacio libre en disco no puede ser menor que 0!"; |
---|
[f5d9d43] | 111 | var n_disk = form.n_disk.value; |
---|
| 112 | var tipo_part_table = form.tipo_part_table.value; |
---|
| 113 | // Comprobamos si la opcion elejida es GPT o MSDOS para llamar a una funcion u otra |
---|
| 114 | if(tipo_part_table == "GPT"){ |
---|
[2e69949] | 115 | // Comprobamos que el espacio libre en el disco no sea negativo, si lo es, dar aviso |
---|
| 116 | if(parseInt(document.getElementById("freediskGPT").value) < 0){ |
---|
| 117 | alert(errorMsg); |
---|
| 118 | } |
---|
| 119 | else{ |
---|
| 120 | codeParticionadoGPT(form); |
---|
| 121 | } |
---|
[f5d9d43] | 122 | } |
---|
| 123 | else{ |
---|
[2e69949] | 124 | // Comprobamos que el espacio libre en el disco no sea negativo, si lo es, dar aviso |
---|
| 125 | if(parseInt(document.getElementById("freedisk").value) < 0){ |
---|
| 126 | alert(errorMsg); |
---|
| 127 | } |
---|
| 128 | else{ |
---|
| 129 | codeParticionadoMSDOS(form); |
---|
| 130 | } |
---|
[f5d9d43] | 131 | } |
---|
[2e69949] | 132 | |
---|
[f5d9d43] | 133 | } |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | function codeParticionadoMSDOS (form) { |
---|
[66d40b0] | 137 | var partCode=""; |
---|
| 138 | var logicalCode=""; |
---|
[a32f9ad] | 139 | var sizecacheCode=""; |
---|
[66d40b0] | 140 | var cacheCode; |
---|
| 141 | var cacheSize; |
---|
| 142 | var extended=false; |
---|
[f5d9d43] | 143 | var n_disk = form.n_disk.value; |
---|
| 144 | var tipo_part_table = form.tipo_part_table.value; |
---|
[b2651a6] | 145 | var maxParts = 4; |
---|
| 146 | |
---|
| 147 | // Comprobamos si esta seleccionada la cuarta particion y no es CACHE |
---|
| 148 | if(form.check4.checked && form.part4.value != "CACHE") |
---|
| 149 | maxParts = 5; |
---|
[f5d9d43] | 150 | |
---|
[b2651a6] | 151 | for (var nPart=1; nPart<maxParts; nPart++) { |
---|
[66d40b0] | 152 | var partCheck=eval("form.check"+nPart); |
---|
| 153 | if (partCheck.checked) { |
---|
| 154 | var partType=eval("form.part"+nPart); |
---|
| 155 | if (partType.value == "CUSTOM" ) { |
---|
| 156 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
| 157 | partCode += " " + partTypeCustom.value; |
---|
| 158 | if (partTypeCustom.value == "EXTENDED") { |
---|
| 159 | extended=true; |
---|
| 160 | } |
---|
| 161 | } else { |
---|
| 162 | partCode += " " + partType.value; |
---|
| 163 | if (partType.value == "EXTENDED") { |
---|
| 164 | extended=true; |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | var partSize=eval("form.size"+nPart); |
---|
| 168 | if (partSize.value == "CUSTOM" ) { |
---|
| 169 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
| 170 | partCode += ":" + partSizeCustom.value; |
---|
| 171 | } else { |
---|
| 172 | partCode += ":" + partSize.value; |
---|
| 173 | } |
---|
| 174 | } else { |
---|
| 175 | partCode += " EMPTY:0"; |
---|
| 176 | } |
---|
[1ec9b7a] | 177 | } |
---|
[b2651a6] | 178 | |
---|
| 179 | var cacheCode=""; |
---|
| 180 | |
---|
| 181 | // Si se selecciono la particion 4 y es CACHE |
---|
| 182 | if(form.part4.value == "CACHE"){ |
---|
| 183 | if (form.check4.checked) { |
---|
| 184 | if (form.size4.value == "0") { |
---|
[a32f9ad] | 185 | sizecacheCode="\ |
---|
[d1795da] | 186 | ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \ |
---|
[a32f9ad] | 187 | sizecache=`ogGetCacheSize` \n "; |
---|
| 188 | cacheCode="\ |
---|
[d1795da] | 189 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
[a00cca1] | 190 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
[d1795da] | 191 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
[9a1df17] | 192 | ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \ |
---|
[d1795da] | 193 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
[a32f9ad] | 194 | initCache "+n_disk+" $sizecache NOMOUNT &>/dev/null \n "; |
---|
[09da038] | 195 | } else { |
---|
[b2651a6] | 196 | if (form.size4.value == "CUSTOM") { |
---|
| 197 | cacheSize = form.size4custom.value; |
---|
| 198 | } else { |
---|
| 199 | cacheSize = form.size4.value; |
---|
| 200 | } |
---|
| 201 | cacheCode="\ |
---|
[d1795da] | 202 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
[a00cca1] | 203 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
[d1795da] | 204 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
[523c8ac] | 205 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
[d1795da] | 206 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
[a32f9ad] | 207 | initCache " + n_disk + " " + cacheSize + " NOMOUNT &>/dev/null"; |
---|
[b2651a6] | 208 | } |
---|
| 209 | } else { |
---|
| 210 | cacheCode="\ |
---|
[d1795da] | 211 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
[a00cca1] | 212 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
[523c8ac] | 213 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
| 214 | ogUpdatePartitionTable "+n_disk+" \n"; |
---|
| 215 | partCode += " EMPTY:0"; |
---|
[b2651a6] | 216 | } |
---|
[09da038] | 217 | } |
---|
[b2651a6] | 218 | |
---|
[66d40b0] | 219 | if (extended) { |
---|
| 220 | var lastLogical=5; |
---|
| 221 | for (var nPart=9; nPart>5; nPart--) { |
---|
| 222 | if (eval ("form.check"+nPart+".checked")) { |
---|
| 223 | lastLogical = nPart; |
---|
| 224 | break; |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | for (var nPart=5; nPart<=lastLogical; nPart++) { |
---|
| 228 | var partCheck=eval("form.check"+nPart); |
---|
| 229 | if (partCheck.checked) { |
---|
| 230 | var partType=eval("form.part"+nPart); |
---|
| 231 | if (partType.value == "CUSTOM" ) { |
---|
| 232 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
| 233 | logicalCode += " " + partTypeCustom.value; |
---|
| 234 | } else { |
---|
| 235 | logicalCode += " " + partType.value; |
---|
| 236 | } |
---|
| 237 | var partSize=eval("form.size"+nPart); |
---|
| 238 | if (partSize.value == "CUSTOM" ) { |
---|
| 239 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
| 240 | logicalCode += ":" + partSizeCustom.value; |
---|
| 241 | } else { |
---|
| 242 | logicalCode += ":" + partSize.value; |
---|
| 243 | } |
---|
| 244 | } else { |
---|
| 245 | logicalCode += " EMPTY:0"; |
---|
| 246 | } |
---|
| 247 | } |
---|
| 248 | partCode += logicalCode; |
---|
| 249 | } |
---|
[eb3e2b8] | 250 | |
---|
[523c8ac] | 251 | form.codigo.value="\ |
---|
[a32f9ad] | 252 | " + sizecacheCode + " \n \ |
---|
[d1795da] | 253 | ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \ |
---|
[a00cca1] | 254 | ogUnmountAll "+n_disk+" 2>/dev/null \n \ |
---|
[1a2fa9d8] | 255 | ogUnmountCache \n \ |
---|
[66d40b0] | 256 | " + cacheCode + " \n \ |
---|
[d1795da] | 257 | ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
[9a1df17] | 258 | ogExecAndLog command session ogListPartitions "+n_disk+" \n \ |
---|
[d1795da] | 259 | ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \ |
---|
[552a6ae] | 260 | if ogExecAndLog command session ogCreatePartitions "+n_disk+" " + partCode + "; then \n \ |
---|
| 261 | ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \ |
---|
| 262 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
| 263 | ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
| 264 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
| 265 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
| 266 | ogExecAndLog command session log ogListPartitions "+n_disk+" \n \ |
---|
| 267 | else \n \ |
---|
[a00cca1] | 268 | ogEcho session log \"[100] ERROR: $MSG_HELP_ogCreatePartitions\" \n \ |
---|
[552a6ae] | 269 | sleep 5 \n \ |
---|
| 270 | fi"; |
---|
[eb3e2b8] | 271 | } |
---|
[a71cfe29] | 272 | |
---|
[523c8ac] | 273 | |
---|
[f5d9d43] | 274 | function codeParticionadoGPT (form) { |
---|
| 275 | var partCode=""; |
---|
| 276 | var logicalCode=""; |
---|
[a32f9ad] | 277 | var sizecacheCode=""; |
---|
[b2651a6] | 278 | var cacheCode=""; |
---|
[f5d9d43] | 279 | var cacheSize; |
---|
| 280 | var extended=false; |
---|
| 281 | var n_disk = form.n_disk.value; |
---|
| 282 | var tipo_part_table = form.tipo_part_table.value; |
---|
| 283 | numParts=document.getElementById("numGPTpartitions").value; |
---|
| 284 | |
---|
| 285 | for (var nPart=1; nPart <= numParts; nPart++) { |
---|
| 286 | var partCheck=eval("form.checkGPT"+nPart); |
---|
| 287 | if (partCheck.checked) { |
---|
[523c8ac] | 288 | // Distinguimos entre cache y el resto de particiones |
---|
[b2651a6] | 289 | // Solo tratamos la particion 4 como cache, si se selecciono este tipo |
---|
| 290 | if(nPart == 4 && form.partGPT4.value == "CACHE") { |
---|
[523c8ac] | 291 | if (form.sizeGPT4.value == "0") { |
---|
[a32f9ad] | 292 | sizecacheCode="\ |
---|
[d1795da] | 293 | ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \ |
---|
[a32f9ad] | 294 | sizecache=`ogGetCacheSize` \n "; |
---|
| 295 | cacheCode="\ |
---|
[d1795da] | 296 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
[523c8ac] | 297 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
[9a1df17] | 298 | ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \ |
---|
[d1795da] | 299 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
[a32f9ad] | 300 | initCache "+ n_disk +" $sizecache NOMOUNT &>/dev/null \n "; |
---|
[523c8ac] | 301 | } else { |
---|
| 302 | if (form.sizeGPT4.value == "CUSTOM") { |
---|
| 303 | cacheSize = form.sizeGPT4custom.value; |
---|
| 304 | } else { |
---|
| 305 | cacheSize = form.sizeGPT4.value; |
---|
[f5d9d43] | 306 | } |
---|
[523c8ac] | 307 | cacheCode="\ |
---|
[d1795da] | 308 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
| 309 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
[523c8ac] | 310 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
[d1795da] | 311 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
[a32f9ad] | 312 | initCache " + n_disk +" "+ cacheSize + " NOMOUNT &>/dev/null"; |
---|
[523c8ac] | 313 | } |
---|
| 314 | } else{ |
---|
| 315 | var partType=eval("form.partGPT"+nPart); |
---|
| 316 | if (partType.value == "CUSTOM" ) { |
---|
| 317 | var partTypeCustom=eval("form.partGPT"+nPart+"custom"); |
---|
| 318 | partCode += " " + partTypeCustom.value; |
---|
| 319 | } else { |
---|
| 320 | partCode += " " + partType.value; |
---|
| 321 | } |
---|
| 322 | var partSize=eval("form.sizeGPT"+nPart); |
---|
| 323 | if (partSize.value == "CUSTOM" ) { |
---|
| 324 | var partSizeCustom=eval("form.sizeGPT"+nPart+"custom"); |
---|
| 325 | partCode += ":" + partSizeCustom.value; |
---|
| 326 | } else { |
---|
| 327 | partCode += ":" + partSize.value; |
---|
| 328 | } |
---|
| 329 | } |
---|
| 330 | } else { |
---|
| 331 | if(nPart == 4){ |
---|
| 332 | cacheCode="\ |
---|
[d1795da] | 333 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
[523c8ac] | 334 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
| 335 | ogUpdatePartitionTable "+n_disk+" \n"; |
---|
| 336 | partCode += " EMPTY:0"; |
---|
| 337 | } else{ |
---|
| 338 | partCode += " EMPTY:0"; |
---|
| 339 | } |
---|
[f5d9d43] | 340 | } |
---|
| 341 | } |
---|
[523c8ac] | 342 | form.codigo.value="\ |
---|
[a32f9ad] | 343 | " + sizecacheCode + " \n \ |
---|
[f5d9d43] | 344 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
[d1795da] | 345 | ogEcho log session \"[0] $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \ |
---|
| 346 | ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \ |
---|
[f5d9d43] | 347 | ogUnmountAll "+n_disk+" \n \ |
---|
[1a2fa9d8] | 348 | ogUnmountCache \n \ |
---|
[f5d9d43] | 349 | " + cacheCode + " \n \ |
---|
[d1795da] | 350 | ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
[9a1df17] | 351 | ogExecAndLog command session ogListPartitions "+n_disk+" \n \ |
---|
[d1795da] | 352 | ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \ |
---|
[9a1df17] | 353 | ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \ |
---|
[d1795da] | 354 | ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \ |
---|
[f5d9d43] | 355 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
[d1795da] | 356 | ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
[f5d9d43] | 357 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
| 358 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
[8a59a5f] | 359 | ogExecAndLog command session log ogListPartitions "+n_disk+" \n"; |
---|
[f5d9d43] | 360 | } |
---|
| 361 | |
---|
| 362 | |
---|
[523c8ac] | 363 | function showPartitionForm (tipo_table_part) { |
---|
[f5d9d43] | 364 | document.getElementById("form"+tipo_table_part).style.display="inline"; |
---|
| 365 | if(tipo_table_part == "MSDOS"){ |
---|
| 366 | // De los dos tipos, se oculta el otro |
---|
| 367 | document.getElementById("formGPT").style.display="none"; |
---|
[502daab] | 368 | document.getElementById("warngpt").style.display="none"; |
---|
[523c8ac] | 369 | } else{ |
---|
[f5d9d43] | 370 | document.getElementById("formMSDOS").style.display="none"; |
---|
[502daab] | 371 | // Para GPT obliga que primera partición sea EFI |
---|
| 372 | document.getElementById("checkGPT1").checked=true; |
---|
| 373 | document.getElementById("checkGPT1").disabled=true; |
---|
| 374 | document.getElementById("partGPT1").value="CUSTOM"; |
---|
| 375 | document.getElementById("partGPT1custom").value="EFI"; |
---|
| 376 | document.getElementById("sizeGPT1").value="CUSTOM"; |
---|
| 377 | document.getElementById("sizeGPT1").disabled=false; |
---|
| 378 | document.getElementById("sizeGPT1custom").value="512000"; |
---|
| 379 | document.getElementById("sizeGPT1custom").disabled=false; |
---|
| 380 | document.getElementById("warngpt").style.display="table-row"; |
---|
[f5d9d43] | 381 | } |
---|
| 382 | } |
---|
| 383 | |
---|
[a71cfe29] | 384 | |
---|
| 385 | // Código de pulsación de selección de partición. |
---|
[523c8ac] | 386 | function clickPartitionCheckbox (form, npart, isGPT) { |
---|
[f5d9d43] | 387 | // Si el parametro no esta definido, se toma como false |
---|
| 388 | isGPT = (isGPT)?isGPT:"false"; |
---|
| 389 | if(isGPT == true){ |
---|
| 390 | prefix="GPT"; |
---|
[523c8ac] | 391 | } else { |
---|
[f5d9d43] | 392 | prefix=""; |
---|
| 393 | } |
---|
| 394 | var partCheck=eval("form.check"+prefix+npart); |
---|
| 395 | var partType=eval("form.part"+prefix+npart); |
---|
| 396 | var partSize=eval("form.size"+prefix+npart); |
---|
| 397 | var partTypeCustom=eval("form.part"+prefix+npart+"custom"); |
---|
| 398 | var partSizeCustom=eval("form.size"+prefix+npart+"custom"); |
---|
| 399 | var freeDisk=document.getElementById("freedisk"+prefix); |
---|
| 400 | //var logical=document.getElementById("logicas"+prefix); |
---|
[a71cfe29] | 401 | if (partCheck.checked) { |
---|
| 402 | partType.disabled=false; |
---|
| 403 | partSize.disabled=false; |
---|
[f5d9d43] | 404 | if(npart != 4){ |
---|
| 405 | if (partType.options[partType.selectedIndex].value == "CUSTOM") { |
---|
| 406 | partTypeCustom.disabled=false; |
---|
| 407 | } |
---|
[a71cfe29] | 408 | } |
---|
| 409 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
| 410 | partSizeCustom.disabled=false; |
---|
| 411 | } else { |
---|
| 412 | partSizeCustom.disabled=true; |
---|
| 413 | } |
---|
| 414 | } else { |
---|
| 415 | partType.disabled=true; |
---|
| 416 | partSize.disabled=true; |
---|
[b2651a6] | 417 | // El campo TypeCustom no existe para la particion 4 |
---|
| 418 | if(npart != 4) |
---|
| 419 | partTypeCustom.disabled=true; |
---|
[a71cfe29] | 420 | partSizeCustom.disabled=true; |
---|
| 421 | } |
---|
[66d40b0] | 422 | if (npart <= 4) { |
---|
[f5d9d43] | 423 | // Si el formulario es GPT no hay extendidas |
---|
| 424 | if(isGPT != true){ |
---|
| 425 | checkExtendedPartition(form); |
---|
| 426 | } |
---|
[66d40b0] | 427 | calculateFreeDisk(form); |
---|
| 428 | } |
---|
[a71cfe29] | 429 | } |
---|
| 430 | |
---|
[92cf666] | 431 | /** |
---|
| 432 | * Dado un numero de disco, recorre todos los input hidden con nombre disksize_"disco" |
---|
| 433 | * y devuelve el de menor valor |
---|
| 434 | */ |
---|
| 435 | function getMinDiskSize(disk){ |
---|
| 436 | var diskSizeArray = document.getElementsByName("disksize_"+disk); |
---|
| 437 | var minSize = diskSizeArray[0].value; |
---|
| 438 | for(var i= 1; i < diskSizeArray.length; i++){ |
---|
| 439 | if(diskSizeArray[i].value < minSize) |
---|
| 440 | minSize = diskSizeArray[i].value; |
---|
| 441 | } |
---|
[fe06132] | 442 | // Restar sectores iniciales del disco al tamaño total (1 MB). |
---|
| 443 | return (minSize > 1024 ? minSize - 1024 : minSize) |
---|
[92cf666] | 444 | } |
---|
[a71cfe29] | 445 | |
---|
| 446 | // Código para calcular el espacio libre del disco. |
---|
[66d40b0] | 447 | function calculateFreeDisk(form) { |
---|
[f5d9d43] | 448 | // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente |
---|
| 449 | if(document.getElementById("tipo_part_table").value == "GPT"){ |
---|
| 450 | calculateFreeGPTDisk(form); |
---|
| 451 | } |
---|
[2e69949] | 452 | // Capturamos el disco seleccionado |
---|
| 453 | var disk = document.getElementById("n_disk").value; |
---|
[92cf666] | 454 | // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor |
---|
| 455 | var diskSize = getMinDiskSize(disk); |
---|
| 456 | |
---|
[2e69949] | 457 | |
---|
[a71cfe29] | 458 | var freeDisk=document.getElementById("freedisk"); |
---|
[2e69949] | 459 | freeDisk.value=diskSize; |
---|
[12603f8] | 460 | for (var npart=1; npart<=4; npart++) { |
---|
[a71cfe29] | 461 | var partCheck=eval("form.check"+npart); |
---|
| 462 | var partSize=eval("form.size"+npart); |
---|
| 463 | var partSizeCustom=eval("form.size"+npart+"custom"); |
---|
| 464 | if (partCheck.checked) { |
---|
| 465 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
| 466 | freeDisk.value -= parseInt(partSizeCustom.value); |
---|
| 467 | } else { |
---|
| 468 | freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value); |
---|
| 469 | } |
---|
| 470 | } |
---|
| 471 | } |
---|
| 472 | if (parseInt(freeDisk.value) < 0) { |
---|
| 473 | freeDisk.style.fontWeight = "bold"; |
---|
| 474 | freeDisk.style.fontStyle = "italic"; |
---|
| 475 | } else { |
---|
| 476 | freeDisk.style.fontWeight = "normal"; |
---|
| 477 | freeDisk.style.fontStyle = "normal"; |
---|
| 478 | } |
---|
| 479 | if (form.size4.value == 0) { |
---|
| 480 | freeDisk.value += " (- cache)"; // Aviso de caché sin modificar. |
---|
| 481 | } |
---|
| 482 | } |
---|
| 483 | |
---|
[f5d9d43] | 484 | // Código para calcular el espacio libre del disco. en el formulario GPT |
---|
| 485 | function calculateFreeGPTDisk(form) { |
---|
| 486 | // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente |
---|
[2e69949] | 487 | if(document.getElementById("tipo_part_table").value == "MSDOS"){ |
---|
| 488 | calculateFreeDisk(form); |
---|
| 489 | } |
---|
| 490 | // Capturamos el disco seleccionado |
---|
| 491 | var disk = document.getElementById("n_disk").value; |
---|
| 492 | // Buscamos el input hidden para el disco seleccionado |
---|
[92cf666] | 493 | var diskSize = getMinDiskSize(disk); |
---|
[2e69949] | 494 | document.getElementById('freediskGPT').value=diskSize; |
---|
| 495 | |
---|
[f5d9d43] | 496 | var freeDisk=document.getElementById("freediskGPT"); |
---|
| 497 | // Capturamos el numero de particiones que hay hechas |
---|
| 498 | numParts=document.getElementById("numGPTpartitions").value; |
---|
[2e69949] | 499 | for (npart=1; npart<=numParts; npart++) { |
---|
| 500 | var partCheck=eval("form.checkGPT"+npart); |
---|
| 501 | var partSize=eval("form.sizeGPT"+npart); |
---|
| 502 | var partSizeCustom=eval("form.sizeGPT"+npart+"custom"); |
---|
| 503 | if (partCheck.checked) { |
---|
| 504 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
| 505 | freeDisk.value -= parseInt(partSizeCustom.value); |
---|
| 506 | } else { |
---|
| 507 | freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value); |
---|
| 508 | } |
---|
| 509 | } |
---|
| 510 | } |
---|
| 511 | if (parseInt(freeDisk.value) < 0) { |
---|
| 512 | freeDisk.style.fontWeight = "bold"; |
---|
| 513 | freeDisk.style.fontStyle = "italic"; |
---|
| 514 | } else { |
---|
| 515 | freeDisk.style.fontWeight = "normal"; |
---|
| 516 | freeDisk.style.fontStyle = "normal"; |
---|
| 517 | } |
---|
| 518 | if (form.size4.value == 0) { |
---|
| 519 | freeDisk.value += " (- cache)"; // Aviso de caché sin modificar. |
---|
| 520 | } |
---|
[f5d9d43] | 521 | } |
---|
| 522 | |
---|
| 523 | // Agrega una nueva fila a la tabla de particiones con una nueva particion |
---|
| 524 | function addGPTPartition(){ |
---|
| 525 | var partitionTypes = ""; |
---|
[9f31169] | 526 | partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>'; |
---|
| 527 | partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>'; |
---|
| 528 | partitionTypes+='<OPTION value="LINUX"> Linux </OTION>'; |
---|
| 529 | partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>'; |
---|
| 530 | partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>'; |
---|
| 531 | partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>'; |
---|
| 532 | partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>'; |
---|
| 533 | partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>'; |
---|
| 534 | partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>'; |
---|
| 535 | partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>'; |
---|
| 536 | partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>'; |
---|
[fea9dfb] | 537 | partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>'; |
---|
[9f31169] | 538 | partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>'; |
---|
| 539 | partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>'; |
---|
| 540 | partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>'; |
---|
| 541 | partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>'; |
---|
| 542 | partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>'; |
---|
| 543 | partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>'; |
---|
| 544 | partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>'; |
---|
| 545 | partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>'; |
---|
| 546 | partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>'; |
---|
| 547 | partitionTypes+='<OPTION value="EFI"> EFI </OPTION>'; |
---|
| 548 | partitionTypes+='<OPTION value="MBR"> MBR </OPTION>'; |
---|
| 549 | partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>'; |
---|
[f5d9d43] | 550 | |
---|
| 551 | |
---|
| 552 | table = document.getElementById("particionesGPT"); |
---|
| 553 | // Capturamos el numero de particiones, antes incrementamos |
---|
| 554 | document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1 |
---|
| 555 | numPart=document.getElementById("numGPTpartitions").value; |
---|
| 556 | partitionRow = table.insertRow(-1); |
---|
| 557 | partitionRow.id = "trPartition"+numPart; |
---|
| 558 | partitionRow.innerHTML="<td> \ |
---|
| 559 | <input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partición "+numPart+"</td> \ |
---|
| 560 | <td>\ |
---|
| 561 | <select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \ |
---|
| 562 | if (this.options[this.selectedIndex].value == \'CUSTOM\') { \ |
---|
| 563 | this.form.partGPT"+numPart+"custom.disabled=false; \ |
---|
| 564 | } else { \ |
---|
| 565 | this.form.partGPT"+numPart+"custom.disabled=true; \ |
---|
| 566 | }'><option value='CUSTOM'> Personalizar </option> \ |
---|
| 567 | </select> \ |
---|
| 568 | <br> \ |
---|
| 569 | <select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \ |
---|
| 570 | </td> \ |
---|
| 571 | <td> \ |
---|
| 572 | <select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \ |
---|
| 573 | if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \ |
---|
| 574 | this.form.sizeGPT"+numPart+"custom.disabled=false; \ |
---|
| 575 | } else { \ |
---|
| 576 | this.form.sizeGPT"+numPart+"custom.disabled=true; \ |
---|
| 577 | } \ |
---|
| 578 | ' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \ |
---|
| 579 | </select> \ |
---|
| 580 | <br /> \ |
---|
| 581 | <input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \ |
---|
| 582 | </td>" |
---|
| 583 | |
---|
| 584 | } |
---|
| 585 | |
---|
| 586 | // Agrega una nueva fila a la tabla de particiones con una nueva particion |
---|
| 587 | function deleteGPTPartition(){ |
---|
| 588 | table = document.getElementById("particionesGPT"); |
---|
| 589 | // Capturamos el numero de particiones |
---|
| 590 | numPart=document.getElementById("numGPTpartitions").value; |
---|
[c7b62bd] | 591 | // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador |
---|
[f5d9d43] | 592 | if(numPart > 4){ |
---|
| 593 | partitionRow = document.getElementById("trPartition"+numPart); |
---|
| 594 | table.deleteRow(partitionRow.rowIndex); |
---|
[c7b62bd] | 595 | // Decrementamos el numero de particiones |
---|
| 596 | document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1; |
---|
[f5d9d43] | 597 | } |
---|
| 598 | } |
---|
| 599 | |
---|
[66d40b0] | 600 | // Código para comprobar si hay partición extendida activa para mostrar las lógicas. |
---|
| 601 | function checkExtendedPartition(form) { |
---|
| 602 | var logical=document.getElementById("logicas"); |
---|
| 603 | var visible=false; |
---|
[b2651a6] | 604 | for (npart=1; npart<=4; npart++) { |
---|
[66d40b0] | 605 | var partCheck=eval("form.check"+npart); |
---|
| 606 | var partType=eval("form.part"+npart); |
---|
| 607 | var partTypeCustom=eval("form.part"+npart+"custom"); |
---|
| 608 | if (partCheck.checked) { |
---|
| 609 | partType.style.fontWeight = "normal"; |
---|
[b2651a6] | 610 | |
---|
[66d40b0] | 611 | if (partType.value == "EXTENDED") { |
---|
| 612 | visible=true; |
---|
| 613 | partType.style.fontWeight = "bold"; |
---|
| 614 | } |
---|
[b2651a6] | 615 | // La particion 4 no tiene partTypeCustom |
---|
| 616 | if(npart != 4){ |
---|
| 617 | partTypeCustom.style.fontWeight = "normal"; |
---|
| 618 | if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") { |
---|
| 619 | visible=true; |
---|
| 620 | partTypeCustom.style.fontWeight = "bold"; |
---|
| 621 | } |
---|
[66d40b0] | 622 | } |
---|
| 623 | } |
---|
| 624 | } |
---|
| 625 | if (visible) { |
---|
| 626 | logical.style.visibility="visible"; |
---|
| 627 | } else { |
---|
| 628 | logical.style.visibility="hidden"; |
---|
| 629 | } |
---|
| 630 | } |
---|
| 631 | |
---|