[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){ |
---|
| 110 | var n_disk = form.n_disk.value; |
---|
| 111 | var tipo_part_table = form.tipo_part_table.value; |
---|
| 112 | // Comprobamos si la opcion elejida es GPT o MSDOS para llamar a una funcion u otra |
---|
| 113 | if(tipo_part_table == "GPT"){ |
---|
[dd14ed2] | 114 | var freediskGPT = parseInt(document.getElementById("freediskGPT").value); |
---|
[2e69949] | 115 | // Comprobamos que el espacio libre en el disco no sea negativo, si lo es, dar aviso |
---|
[dd14ed2] | 116 | if(freediskGPT < 0){ |
---|
| 117 | alert(TbMsg['NODISKSIZE']); |
---|
| 118 | } |
---|
| 119 | else if (!validaCache(freediskGPT)) { |
---|
| 120 | alert(TbMsg['NOCACHESIZE']); |
---|
[2e69949] | 121 | } |
---|
| 122 | else{ |
---|
| 123 | codeParticionadoGPT(form); |
---|
| 124 | } |
---|
[f5d9d43] | 125 | } |
---|
| 126 | else{ |
---|
[dd14ed2] | 127 | var freedisk = parseInt(document.getElementById("freedisk").value); |
---|
[2e69949] | 128 | // Comprobamos que el espacio libre en el disco no sea negativo, si lo es, dar aviso |
---|
[dd14ed2] | 129 | if(freedisk < 0){ |
---|
| 130 | alert(TbMsg['NODISKSIZE']); |
---|
| 131 | } |
---|
| 132 | else if (!validaCache(freedisk)) { |
---|
| 133 | alert(TbMsg['NOCACHESIZE']); |
---|
[2e69949] | 134 | } |
---|
| 135 | else{ |
---|
| 136 | codeParticionadoMSDOS(form); |
---|
| 137 | } |
---|
[f5d9d43] | 138 | } |
---|
[dd14ed2] | 139 | |
---|
[f5d9d43] | 140 | } |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | function codeParticionadoMSDOS (form) { |
---|
[66d40b0] | 144 | var partCode=""; |
---|
| 145 | var logicalCode=""; |
---|
[a32f9ad] | 146 | var sizecacheCode=""; |
---|
[7082c6f] | 147 | var cacheCode=""; |
---|
[66d40b0] | 148 | var cacheSize; |
---|
| 149 | var extended=false; |
---|
[f5d9d43] | 150 | var n_disk = form.n_disk.value; |
---|
| 151 | var tipo_part_table = form.tipo_part_table.value; |
---|
[b2651a6] | 152 | var maxParts = 4; |
---|
[90ac583] | 153 | var swapPart = new Array(); |
---|
| 154 | var swapCode = ""; |
---|
[b2651a6] | 155 | |
---|
| 156 | // Comprobamos si esta seleccionada la cuarta particion y no es CACHE |
---|
| 157 | if(form.check4.checked && form.part4.value != "CACHE") |
---|
| 158 | maxParts = 5; |
---|
[f5d9d43] | 159 | |
---|
[b2651a6] | 160 | for (var nPart=1; nPart<maxParts; nPart++) { |
---|
[66d40b0] | 161 | var partCheck=eval("form.check"+nPart); |
---|
| 162 | if (partCheck.checked) { |
---|
| 163 | var partType=eval("form.part"+nPart); |
---|
| 164 | if (partType.value == "CUSTOM" ) { |
---|
| 165 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
| 166 | partCode += " " + partTypeCustom.value; |
---|
[90ac583] | 167 | switch(partTypeCustom.value) { |
---|
| 168 | case "EXTENDED": |
---|
[66d40b0] | 169 | extended=true; |
---|
[90ac583] | 170 | break; |
---|
| 171 | case "LINUX-SWAP": |
---|
| 172 | swapPart.push(nPart); |
---|
| 173 | break; |
---|
[66d40b0] | 174 | } |
---|
[90ac583] | 175 | |
---|
[66d40b0] | 176 | } else { |
---|
| 177 | partCode += " " + partType.value; |
---|
[90ac583] | 178 | switch(partType.value) { |
---|
| 179 | case "EXTENDED": |
---|
[66d40b0] | 180 | extended=true; |
---|
[90ac583] | 181 | break; |
---|
| 182 | case "LINUX-SWAP": |
---|
| 183 | swapPart.push(nPart); |
---|
| 184 | break; |
---|
[66d40b0] | 185 | } |
---|
| 186 | } |
---|
| 187 | var partSize=eval("form.size"+nPart); |
---|
| 188 | if (partSize.value == "CUSTOM" ) { |
---|
| 189 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
| 190 | partCode += ":" + partSizeCustom.value; |
---|
| 191 | } else { |
---|
| 192 | partCode += ":" + partSize.value; |
---|
| 193 | } |
---|
| 194 | } else { |
---|
| 195 | partCode += " EMPTY:0"; |
---|
| 196 | } |
---|
[1ec9b7a] | 197 | } |
---|
[b2651a6] | 198 | var cacheCode=""; |
---|
| 199 | |
---|
| 200 | // Si se selecciono la particion 4 y es CACHE |
---|
| 201 | if(form.part4.value == "CACHE"){ |
---|
| 202 | if (form.check4.checked) { |
---|
| 203 | if (form.size4.value == "0") { |
---|
[a32f9ad] | 204 | sizecacheCode="\ |
---|
[d1795da] | 205 | ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \ |
---|
[7082c6f] | 206 | sizecache=`ogGetCacheSize` "; |
---|
[a32f9ad] | 207 | cacheCode="\ |
---|
| 208 | initCache "+n_disk+" $sizecache NOMOUNT &>/dev/null \n "; |
---|
[09da038] | 209 | } else { |
---|
[b2651a6] | 210 | if (form.size4.value == "CUSTOM") { |
---|
| 211 | cacheSize = form.size4custom.value; |
---|
| 212 | } else { |
---|
| 213 | cacheSize = form.size4.value; |
---|
| 214 | } |
---|
| 215 | cacheCode="\ |
---|
[7082c6f] | 216 | initCache " + n_disk + " " + cacheSize + " NOMOUNT &>/dev/null \n "; |
---|
[b2651a6] | 217 | } |
---|
[7082c6f] | 218 | cacheCode += "ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\" \n "; |
---|
| 219 | cacheCode += "ogExecAndLog command session ogListPartitions "+n_disk+" \n "; |
---|
[b2651a6] | 220 | } else { |
---|
[523c8ac] | 221 | partCode += " EMPTY:0"; |
---|
[b2651a6] | 222 | } |
---|
[09da038] | 223 | } |
---|
[b2651a6] | 224 | |
---|
[66d40b0] | 225 | if (extended) { |
---|
| 226 | var lastLogical=5; |
---|
| 227 | for (var nPart=9; nPart>5; nPart--) { |
---|
| 228 | if (eval ("form.check"+nPart+".checked")) { |
---|
| 229 | lastLogical = nPart; |
---|
| 230 | break; |
---|
| 231 | } |
---|
| 232 | } |
---|
| 233 | for (var nPart=5; nPart<=lastLogical; nPart++) { |
---|
| 234 | var partCheck=eval("form.check"+nPart); |
---|
| 235 | if (partCheck.checked) { |
---|
| 236 | var partType=eval("form.part"+nPart); |
---|
| 237 | if (partType.value == "CUSTOM" ) { |
---|
| 238 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
| 239 | logicalCode += " " + partTypeCustom.value; |
---|
[90ac583] | 240 | // Partición swap |
---|
| 241 | if (partTypeCustom.value == "LINUX-SWAP") |
---|
| 242 | swapPart.push(nPart); |
---|
[66d40b0] | 243 | } else { |
---|
| 244 | logicalCode += " " + partType.value; |
---|
[90ac583] | 245 | // Partición swap |
---|
| 246 | if (partType.value == "LINUX-SWAP") |
---|
| 247 | swapPart.push(nPart); |
---|
[66d40b0] | 248 | } |
---|
| 249 | var partSize=eval("form.size"+nPart); |
---|
| 250 | if (partSize.value == "CUSTOM" ) { |
---|
| 251 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
| 252 | logicalCode += ":" + partSizeCustom.value; |
---|
| 253 | } else { |
---|
| 254 | logicalCode += ":" + partSize.value; |
---|
| 255 | } |
---|
| 256 | } else { |
---|
| 257 | logicalCode += " EMPTY:0"; |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | partCode += logicalCode; |
---|
| 261 | } |
---|
[eb3e2b8] | 262 | |
---|
[90ac583] | 263 | // Formateo de la partición swap |
---|
| 264 | if (swapPart.length > 0) { |
---|
| 265 | for (var i=0; i < swapPart.length; i++) { |
---|
[7082c6f] | 266 | swapCode += " ogEcho session log \"[95] $MSG_HELP_ogFormat "+n_disk+" "+swapPart[i]+" LINUX-SWAP \"\n " ; |
---|
| 267 | swapCode += " ogExecAndLog command ogFormat "+n_disk+" "+swapPart[i]+" LINUX-SWAP \n "; |
---|
[90ac583] | 268 | } |
---|
| 269 | |
---|
| 270 | } |
---|
| 271 | |
---|
[523c8ac] | 272 | form.codigo.value="\ |
---|
[a32f9ad] | 273 | " + sizecacheCode + " \n \ |
---|
[d1795da] | 274 | ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \ |
---|
[a00cca1] | 275 | ogUnmountAll "+n_disk+" 2>/dev/null \n \ |
---|
[1a2fa9d8] | 276 | ogUnmountCache \n \ |
---|
[7082c6f] | 277 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
| 278 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
| 279 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
| 280 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
| 281 | " + cacheCode + "\ |
---|
[d1795da] | 282 | ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \ |
---|
[7082c6f] | 283 | if ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + "; then \n \ |
---|
[552a6ae] | 284 | ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \ |
---|
| 285 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
[7082c6f] | 286 | ogEcho log session \"[90] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
[552a6ae] | 287 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
| 288 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
[7082c6f] | 289 | ogExecAndLog command session log ogListPartitions "+n_disk+" \n\ |
---|
[90ac583] | 290 | "+ swapCode +"\ |
---|
[552a6ae] | 291 | else \n \ |
---|
[a00cca1] | 292 | ogEcho session log \"[100] ERROR: $MSG_HELP_ogCreatePartitions\" \n \ |
---|
[552a6ae] | 293 | sleep 5 \n \ |
---|
| 294 | fi"; |
---|
[eb3e2b8] | 295 | } |
---|
[a71cfe29] | 296 | |
---|
[523c8ac] | 297 | |
---|
[f5d9d43] | 298 | function codeParticionadoGPT (form) { |
---|
| 299 | var partCode=""; |
---|
| 300 | var logicalCode=""; |
---|
[a32f9ad] | 301 | var sizecacheCode=""; |
---|
[b2651a6] | 302 | var cacheCode=""; |
---|
[f5d9d43] | 303 | var cacheSize; |
---|
| 304 | var extended=false; |
---|
| 305 | var n_disk = form.n_disk.value; |
---|
| 306 | var tipo_part_table = form.tipo_part_table.value; |
---|
[90ac583] | 307 | var swapPart = new Array(); |
---|
| 308 | var swapCode = ""; |
---|
| 309 | |
---|
[f5d9d43] | 310 | numParts=document.getElementById("numGPTpartitions").value; |
---|
| 311 | |
---|
| 312 | for (var nPart=1; nPart <= numParts; nPart++) { |
---|
| 313 | var partCheck=eval("form.checkGPT"+nPart); |
---|
| 314 | if (partCheck.checked) { |
---|
[523c8ac] | 315 | // Distinguimos entre cache y el resto de particiones |
---|
[b2651a6] | 316 | // Solo tratamos la particion 4 como cache, si se selecciono este tipo |
---|
| 317 | if(nPart == 4 && form.partGPT4.value == "CACHE") { |
---|
[523c8ac] | 318 | if (form.sizeGPT4.value == "0") { |
---|
[a32f9ad] | 319 | sizecacheCode="\ |
---|
[d1795da] | 320 | ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \ |
---|
[7082c6f] | 321 | sizecache=`ogGetCacheSize` "; |
---|
[a32f9ad] | 322 | cacheCode="\ |
---|
[d1795da] | 323 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
[a32f9ad] | 324 | initCache "+ n_disk +" $sizecache NOMOUNT &>/dev/null \n "; |
---|
[523c8ac] | 325 | } else { |
---|
| 326 | if (form.sizeGPT4.value == "CUSTOM") { |
---|
| 327 | cacheSize = form.sizeGPT4custom.value; |
---|
| 328 | } else { |
---|
| 329 | cacheSize = form.sizeGPT4.value; |
---|
[f5d9d43] | 330 | } |
---|
[523c8ac] | 331 | cacheCode="\ |
---|
[d1795da] | 332 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
[7082c6f] | 333 | initCache " + n_disk +" "+ cacheSize + " NOMOUNT &>/dev/null \n "; |
---|
[523c8ac] | 334 | } |
---|
[7082c6f] | 335 | cacheCode += "ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n "; |
---|
| 336 | cacheCode += "ogExecAndLog command session ogListPartitions "+n_disk+" \n "; |
---|
[523c8ac] | 337 | } else{ |
---|
| 338 | var partType=eval("form.partGPT"+nPart); |
---|
| 339 | if (partType.value == "CUSTOM" ) { |
---|
| 340 | var partTypeCustom=eval("form.partGPT"+nPart+"custom"); |
---|
| 341 | partCode += " " + partTypeCustom.value; |
---|
[90ac583] | 342 | // Partición swap |
---|
| 343 | if (partTypeCustom.value == "LINUX-SWAP") |
---|
| 344 | swapPart.push(nPart); |
---|
[523c8ac] | 345 | } else { |
---|
| 346 | partCode += " " + partType.value; |
---|
[90ac583] | 347 | // Partición swap |
---|
| 348 | if (partType.value == "LINUX-SWAP") |
---|
| 349 | swapPart.push(nPart); |
---|
[523c8ac] | 350 | } |
---|
| 351 | var partSize=eval("form.sizeGPT"+nPart); |
---|
| 352 | if (partSize.value == "CUSTOM" ) { |
---|
| 353 | var partSizeCustom=eval("form.sizeGPT"+nPart+"custom"); |
---|
| 354 | partCode += ":" + partSizeCustom.value; |
---|
| 355 | } else { |
---|
| 356 | partCode += ":" + partSize.value; |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | } else { |
---|
[7082c6f] | 360 | partCode += " EMPTY:0"; |
---|
[f5d9d43] | 361 | } |
---|
| 362 | } |
---|
[90ac583] | 363 | // Formateo de la partición swap |
---|
| 364 | if (swapPart.length > 0) { |
---|
| 365 | for (var i=0; i < swapPart.length; i++) { |
---|
[7082c6f] | 366 | swapCode += " ogEcho session log \"[95] $MSG_HELP_ogFormat "+n_disk+" "+swapPart[i]+" LINUX-SWAP \" \n" ; |
---|
| 367 | swapCode += " ogExecAndLog command ogFormat "+n_disk+" "+swapPart[i]+" LINUX-SWAP \n"; |
---|
[90ac583] | 368 | } |
---|
| 369 | } |
---|
| 370 | |
---|
[523c8ac] | 371 | form.codigo.value="\ |
---|
[a32f9ad] | 372 | " + sizecacheCode + " \n \ |
---|
[f5d9d43] | 373 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
[d1795da] | 374 | ogEcho log session \"[0] $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \ |
---|
| 375 | ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \ |
---|
[7082c6f] | 376 | ogUnmountAll "+n_disk+" \n \ |
---|
[1a2fa9d8] | 377 | ogUnmountCache \n \ |
---|
[7082c6f] | 378 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
| 379 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
| 380 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
| 381 | " + cacheCode + "\ |
---|
[d1795da] | 382 | ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \ |
---|
[9a1df17] | 383 | ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \ |
---|
[d1795da] | 384 | ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \ |
---|
[f5d9d43] | 385 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
[7082c6f] | 386 | ogEcho log session \"[90] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
[f5d9d43] | 387 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
| 388 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
[90ac583] | 389 | ogExecAndLog command session log ogListPartitions "+n_disk+" \n"; |
---|
| 390 | |
---|
| 391 | // Formateo de la swap |
---|
| 392 | form.codigo.value += swapCode; |
---|
[f5d9d43] | 393 | } |
---|
| 394 | |
---|
| 395 | |
---|
[523c8ac] | 396 | function showPartitionForm (tipo_table_part) { |
---|
[f5d9d43] | 397 | document.getElementById("form"+tipo_table_part).style.display="inline"; |
---|
| 398 | if(tipo_table_part == "MSDOS"){ |
---|
| 399 | // De los dos tipos, se oculta el otro |
---|
| 400 | document.getElementById("formGPT").style.display="none"; |
---|
[502daab] | 401 | document.getElementById("warngpt").style.display="none"; |
---|
[523c8ac] | 402 | } else{ |
---|
[f5d9d43] | 403 | document.getElementById("formMSDOS").style.display="none"; |
---|
[502daab] | 404 | // Para GPT obliga que primera partición sea EFI |
---|
| 405 | document.getElementById("checkGPT1").checked=true; |
---|
| 406 | document.getElementById("checkGPT1").disabled=true; |
---|
| 407 | document.getElementById("partGPT1").value="CUSTOM"; |
---|
| 408 | document.getElementById("partGPT1custom").value="EFI"; |
---|
| 409 | document.getElementById("sizeGPT1").value="CUSTOM"; |
---|
| 410 | document.getElementById("sizeGPT1").disabled=false; |
---|
| 411 | document.getElementById("sizeGPT1custom").value="512000"; |
---|
| 412 | document.getElementById("sizeGPT1custom").disabled=false; |
---|
| 413 | document.getElementById("warngpt").style.display="table-row"; |
---|
[f5d9d43] | 414 | } |
---|
| 415 | } |
---|
| 416 | |
---|
[a71cfe29] | 417 | |
---|
| 418 | // Código de pulsación de selección de partición. |
---|
[523c8ac] | 419 | function clickPartitionCheckbox (form, npart, isGPT) { |
---|
[f5d9d43] | 420 | // Si el parametro no esta definido, se toma como false |
---|
| 421 | isGPT = (isGPT)?isGPT:"false"; |
---|
| 422 | if(isGPT == true){ |
---|
| 423 | prefix="GPT"; |
---|
[523c8ac] | 424 | } else { |
---|
[f5d9d43] | 425 | prefix=""; |
---|
| 426 | } |
---|
| 427 | var partCheck=eval("form.check"+prefix+npart); |
---|
| 428 | var partType=eval("form.part"+prefix+npart); |
---|
| 429 | var partSize=eval("form.size"+prefix+npart); |
---|
| 430 | var partTypeCustom=eval("form.part"+prefix+npart+"custom"); |
---|
| 431 | var partSizeCustom=eval("form.size"+prefix+npart+"custom"); |
---|
| 432 | var freeDisk=document.getElementById("freedisk"+prefix); |
---|
| 433 | //var logical=document.getElementById("logicas"+prefix); |
---|
[a71cfe29] | 434 | if (partCheck.checked) { |
---|
| 435 | partType.disabled=false; |
---|
| 436 | partSize.disabled=false; |
---|
[f5d9d43] | 437 | if(npart != 4){ |
---|
| 438 | if (partType.options[partType.selectedIndex].value == "CUSTOM") { |
---|
| 439 | partTypeCustom.disabled=false; |
---|
| 440 | } |
---|
[a71cfe29] | 441 | } |
---|
| 442 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
| 443 | partSizeCustom.disabled=false; |
---|
| 444 | } else { |
---|
| 445 | partSizeCustom.disabled=true; |
---|
| 446 | } |
---|
| 447 | } else { |
---|
| 448 | partType.disabled=true; |
---|
| 449 | partSize.disabled=true; |
---|
[b2651a6] | 450 | // El campo TypeCustom no existe para la particion 4 |
---|
| 451 | if(npart != 4) |
---|
| 452 | partTypeCustom.disabled=true; |
---|
[a71cfe29] | 453 | partSizeCustom.disabled=true; |
---|
| 454 | } |
---|
[66d40b0] | 455 | if (npart <= 4) { |
---|
[f5d9d43] | 456 | // Si el formulario es GPT no hay extendidas |
---|
| 457 | if(isGPT != true){ |
---|
| 458 | checkExtendedPartition(form); |
---|
| 459 | } |
---|
[66d40b0] | 460 | calculateFreeDisk(form); |
---|
| 461 | } |
---|
[a71cfe29] | 462 | } |
---|
| 463 | |
---|
[92cf666] | 464 | /** |
---|
| 465 | * Dado un numero de disco, recorre todos los input hidden con nombre disksize_"disco" |
---|
| 466 | * y devuelve el de menor valor |
---|
| 467 | */ |
---|
| 468 | function getMinDiskSize(disk){ |
---|
| 469 | var diskSizeArray = document.getElementsByName("disksize_"+disk); |
---|
| 470 | var minSize = diskSizeArray[0].value; |
---|
| 471 | for(var i= 1; i < diskSizeArray.length; i++){ |
---|
| 472 | if(diskSizeArray[i].value < minSize) |
---|
| 473 | minSize = diskSizeArray[i].value; |
---|
| 474 | } |
---|
[fe06132] | 475 | // Restar sectores iniciales del disco al tamaño total (1 MB). |
---|
| 476 | return (minSize > 1024 ? minSize - 1024 : minSize) |
---|
[92cf666] | 477 | } |
---|
[a71cfe29] | 478 | |
---|
[dd14ed2] | 479 | // Calcula el tamaño de la mayor cache y lo guarda en un campo oculto |
---|
| 480 | function getMaxCacheSize() { |
---|
| 481 | var cacheSizeArray = document.getElementsByName("cachesize"); |
---|
| 482 | var maxSize = cacheSizeArray[0].value; |
---|
| 483 | for(var i= 1; i < cacheSizeArray.length; i++){ |
---|
| 484 | if(maxSize < cacheSizeArray[i].value) |
---|
| 485 | maxSize = cacheSizeArray[i].value; |
---|
| 486 | } |
---|
| 487 | document.getElementById("maxcachesize").value = maxSize; |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | |
---|
| 491 | // Comprueba que la cache quepa en el espacio libre del disco |
---|
| 492 | function validaCache (freedisk) { |
---|
| 493 | var form = document.fdatos; |
---|
| 494 | var maxcachesize = parseInt(document.getElementById("maxcachesize").value); |
---|
[74c410a] | 495 | if(form.part4.value === "CACHE" && form.check4.checked && form.size4.value == 0 ){ |
---|
| 496 | return ((freedisk - maxcachesize) > 0); |
---|
[dd14ed2] | 497 | } |
---|
| 498 | return true; |
---|
| 499 | } |
---|
| 500 | |
---|
[a71cfe29] | 501 | // Código para calcular el espacio libre del disco. |
---|
[66d40b0] | 502 | function calculateFreeDisk(form) { |
---|
[f5d9d43] | 503 | // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente |
---|
| 504 | if(document.getElementById("tipo_part_table").value == "GPT"){ |
---|
| 505 | calculateFreeGPTDisk(form); |
---|
| 506 | } |
---|
[2e69949] | 507 | // Capturamos el disco seleccionado |
---|
| 508 | var disk = document.getElementById("n_disk").value; |
---|
[92cf666] | 509 | // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor |
---|
| 510 | var diskSize = getMinDiskSize(disk); |
---|
| 511 | |
---|
[2e69949] | 512 | |
---|
[a71cfe29] | 513 | var freeDisk=document.getElementById("freedisk"); |
---|
[2e69949] | 514 | freeDisk.value=diskSize; |
---|
[12603f8] | 515 | for (var npart=1; npart<=4; npart++) { |
---|
[a71cfe29] | 516 | var partCheck=eval("form.check"+npart); |
---|
| 517 | var partSize=eval("form.size"+npart); |
---|
| 518 | var partSizeCustom=eval("form.size"+npart+"custom"); |
---|
| 519 | if (partCheck.checked) { |
---|
| 520 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
| 521 | freeDisk.value -= parseInt(partSizeCustom.value); |
---|
| 522 | } else { |
---|
| 523 | freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value); |
---|
| 524 | } |
---|
| 525 | } |
---|
| 526 | } |
---|
| 527 | if (parseInt(freeDisk.value) < 0) { |
---|
| 528 | freeDisk.style.fontWeight = "bold"; |
---|
| 529 | freeDisk.style.fontStyle = "italic"; |
---|
| 530 | } else { |
---|
| 531 | freeDisk.style.fontWeight = "normal"; |
---|
| 532 | freeDisk.style.fontStyle = "normal"; |
---|
| 533 | } |
---|
| 534 | if (form.size4.value == 0) { |
---|
| 535 | freeDisk.value += " (- cache)"; // Aviso de caché sin modificar. |
---|
| 536 | } |
---|
| 537 | } |
---|
| 538 | |
---|
[f5d9d43] | 539 | // Código para calcular el espacio libre del disco. en el formulario GPT |
---|
| 540 | function calculateFreeGPTDisk(form) { |
---|
| 541 | // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente |
---|
[0975195] | 542 | if(document.getElementById("tipo_part_table").value == "MSDOS"){ |
---|
| 543 | calculateFreeDisk(form); |
---|
| 544 | } |
---|
| 545 | // Capturamos el disco seleccionado |
---|
[2e69949] | 546 | var disk = document.getElementById("n_disk").value; |
---|
| 547 | // Buscamos el input hidden para el disco seleccionado |
---|
[0975195] | 548 | document.getElementById('freediskGPT').value=getMinDiskSize(disk); |
---|
[2e69949] | 549 | |
---|
[f5d9d43] | 550 | var freeDisk=document.getElementById("freediskGPT"); |
---|
| 551 | // Capturamos el numero de particiones que hay hechas |
---|
| 552 | numParts=document.getElementById("numGPTpartitions").value; |
---|
[0975195] | 553 | for (npart=1; npart<=numParts; npart++) { |
---|
[2e69949] | 554 | var partCheck=eval("form.checkGPT"+npart); |
---|
| 555 | var partSize=eval("form.sizeGPT"+npart); |
---|
| 556 | var partSizeCustom=eval("form.sizeGPT"+npart+"custom"); |
---|
| 557 | if (partCheck.checked) { |
---|
| 558 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
[8ddf21a] | 559 | freeDisk.value -= parseInt(partSizeCustom.value); |
---|
[2e69949] | 560 | } else { |
---|
| 561 | freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value); |
---|
| 562 | } |
---|
| 563 | } |
---|
| 564 | } |
---|
| 565 | if (parseInt(freeDisk.value) < 0) { |
---|
| 566 | freeDisk.style.fontWeight = "bold"; |
---|
| 567 | freeDisk.style.fontStyle = "italic"; |
---|
| 568 | } else { |
---|
| 569 | freeDisk.style.fontWeight = "normal"; |
---|
| 570 | freeDisk.style.fontStyle = "normal"; |
---|
| 571 | } |
---|
| 572 | if (form.size4.value == 0) { |
---|
| 573 | freeDisk.value += " (- cache)"; // Aviso de caché sin modificar. |
---|
| 574 | } |
---|
[f5d9d43] | 575 | } |
---|
| 576 | |
---|
| 577 | // Agrega una nueva fila a la tabla de particiones con una nueva particion |
---|
| 578 | function addGPTPartition(){ |
---|
| 579 | var partitionTypes = ""; |
---|
[9f31169] | 580 | partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>'; |
---|
| 581 | partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>'; |
---|
| 582 | partitionTypes+='<OPTION value="LINUX"> Linux </OTION>'; |
---|
| 583 | partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>'; |
---|
| 584 | partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>'; |
---|
| 585 | partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>'; |
---|
| 586 | partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>'; |
---|
| 587 | partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>'; |
---|
| 588 | partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>'; |
---|
| 589 | partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>'; |
---|
| 590 | partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>'; |
---|
[fea9dfb] | 591 | partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>'; |
---|
[9f31169] | 592 | partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>'; |
---|
| 593 | partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>'; |
---|
| 594 | partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>'; |
---|
| 595 | partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>'; |
---|
| 596 | partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>'; |
---|
| 597 | partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>'; |
---|
| 598 | partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>'; |
---|
| 599 | partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>'; |
---|
| 600 | partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>'; |
---|
| 601 | partitionTypes+='<OPTION value="EFI"> EFI </OPTION>'; |
---|
| 602 | partitionTypes+='<OPTION value="MBR"> MBR </OPTION>'; |
---|
| 603 | partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>'; |
---|
[f5d9d43] | 604 | |
---|
| 605 | |
---|
| 606 | table = document.getElementById("particionesGPT"); |
---|
| 607 | // Capturamos el numero de particiones, antes incrementamos |
---|
[3806a31] | 608 | document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1; |
---|
[f5d9d43] | 609 | numPart=document.getElementById("numGPTpartitions").value; |
---|
| 610 | partitionRow = table.insertRow(-1); |
---|
| 611 | partitionRow.id = "trPartition"+numPart; |
---|
| 612 | partitionRow.innerHTML="<td> \ |
---|
| 613 | <input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partición "+numPart+"</td> \ |
---|
| 614 | <td>\ |
---|
| 615 | <select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \ |
---|
| 616 | if (this.options[this.selectedIndex].value == \'CUSTOM\') { \ |
---|
| 617 | this.form.partGPT"+numPart+"custom.disabled=false; \ |
---|
| 618 | } else { \ |
---|
| 619 | this.form.partGPT"+numPart+"custom.disabled=true; \ |
---|
| 620 | }'><option value='CUSTOM'> Personalizar </option> \ |
---|
| 621 | </select> \ |
---|
| 622 | <br> \ |
---|
| 623 | <select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \ |
---|
| 624 | </td> \ |
---|
| 625 | <td> \ |
---|
| 626 | <select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \ |
---|
| 627 | if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \ |
---|
| 628 | this.form.sizeGPT"+numPart+"custom.disabled=false; \ |
---|
| 629 | } else { \ |
---|
| 630 | this.form.sizeGPT"+numPart+"custom.disabled=true; \ |
---|
| 631 | } \ |
---|
| 632 | ' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \ |
---|
| 633 | </select> \ |
---|
| 634 | <br /> \ |
---|
| 635 | <input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \ |
---|
| 636 | </td>" |
---|
| 637 | |
---|
| 638 | } |
---|
| 639 | |
---|
| 640 | // Agrega una nueva fila a la tabla de particiones con una nueva particion |
---|
| 641 | function deleteGPTPartition(){ |
---|
| 642 | table = document.getElementById("particionesGPT"); |
---|
| 643 | // Capturamos el numero de particiones |
---|
| 644 | numPart=document.getElementById("numGPTpartitions").value; |
---|
[c7b62bd] | 645 | // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador |
---|
[f5d9d43] | 646 | if(numPart > 4){ |
---|
| 647 | partitionRow = document.getElementById("trPartition"+numPart); |
---|
| 648 | table.deleteRow(partitionRow.rowIndex); |
---|
[c7b62bd] | 649 | // Decrementamos el numero de particiones |
---|
| 650 | document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1; |
---|
[f5d9d43] | 651 | } |
---|
| 652 | } |
---|
| 653 | |
---|
[66d40b0] | 654 | // Código para comprobar si hay partición extendida activa para mostrar las lógicas. |
---|
| 655 | function checkExtendedPartition(form) { |
---|
| 656 | var logical=document.getElementById("logicas"); |
---|
| 657 | var visible=false; |
---|
[b2651a6] | 658 | for (npart=1; npart<=4; npart++) { |
---|
[66d40b0] | 659 | var partCheck=eval("form.check"+npart); |
---|
| 660 | var partType=eval("form.part"+npart); |
---|
| 661 | var partTypeCustom=eval("form.part"+npart+"custom"); |
---|
| 662 | if (partCheck.checked) { |
---|
| 663 | partType.style.fontWeight = "normal"; |
---|
[b2651a6] | 664 | |
---|
[66d40b0] | 665 | if (partType.value == "EXTENDED") { |
---|
| 666 | visible=true; |
---|
| 667 | partType.style.fontWeight = "bold"; |
---|
| 668 | } |
---|
[b2651a6] | 669 | // La particion 4 no tiene partTypeCustom |
---|
| 670 | if(npart != 4){ |
---|
| 671 | partTypeCustom.style.fontWeight = "normal"; |
---|
| 672 | if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") { |
---|
| 673 | visible=true; |
---|
| 674 | partTypeCustom.style.fontWeight = "bold"; |
---|
| 675 | } |
---|
[66d40b0] | 676 | } |
---|
| 677 | } |
---|
| 678 | } |
---|
| 679 | if (visible) { |
---|
| 680 | logical.style.visibility="visible"; |
---|
| 681 | } else { |
---|
| 682 | logical.style.visibility="hidden"; |
---|
| 683 | } |
---|
| 684 | } |
---|