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) |
---|
9 | // *********************************************************************************************************** |
---|
10 | |
---|
11 | function codeCloneRemotePartition(form){ |
---|
12 | switch (form.idmetodo.value) |
---|
13 | { |
---|
14 | case "MULTICAST": |
---|
15 | protocol="MULTICAST " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " "; |
---|
16 | break; |
---|
17 | case "UNICAST": |
---|
18 | protocol="UNICAST " + form.ucastport.value + ":" + form.ucastclient.value + " "; |
---|
19 | break; |
---|
20 | } |
---|
21 | //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; |
---|
22 | command="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value; |
---|
23 | form.codigo.value="\ |
---|
24 | echo \"[0] $MSG_SCRIPTS_TASK_START " + command + " \" | tee -a $OGLOGFILE $OGLOGSESSION \n " + |
---|
25 | command + " | tee -a $OGLOGCOMMAND \n "; |
---|
26 | //cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value + " | tee -a $OGLOGCOMMAND \n"; |
---|
27 | //form.codigo.value="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value; |
---|
28 | } |
---|
29 | |
---|
30 | function codeDeployImage(form){ |
---|
31 | switch (form.idmetodo.value) |
---|
32 | { |
---|
33 | case "MULTICAST": |
---|
34 | protocol="MULTICAST " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " "; |
---|
35 | break; |
---|
36 | case "TORRENT": |
---|
37 | protocol=" TORRENT " + form.modp2p.value + ":" + form.timep2p.value; |
---|
38 | break; |
---|
39 | case "UNICAST": |
---|
40 | protocol=" UNICAST"; |
---|
41 | break; |
---|
42 | } |
---|
43 | //form.codigo.value="deployImage REPO /"; |
---|
44 | if (form.modo[0].checked) |
---|
45 | { |
---|
46 | command="deployImage REPO /" + form.idimagen.value + " 1 " + form.idparticion.value + " " + protocol ; |
---|
47 | form.codigo.value="\ |
---|
48 | echo [0] $MSG_SCRIPTS_TASK_START " + command +" | tee -a $OGLOGSESSION \n \ " + |
---|
49 | command + " | tee -a $OGLOGCOMMAND"; |
---|
50 | //form.codigo.value="deployImage REPO /" + form.idimagen.value + " 1 " + form.idparticion.value + " " + protocol ; |
---|
51 | } |
---|
52 | else |
---|
53 | { |
---|
54 | command="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
55 | form.codigo.value="\ |
---|
56 | echo [0] $MSG_SCRIPTS_TASK_START " + command +" | tee -a $OGLOGSESSION \n \ " + |
---|
57 | command + " | tee -a $OGLOGCOMMAND"; |
---|
58 | //form.codigo.value="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
59 | } |
---|
60 | |
---|
61 | } |
---|
62 | |
---|
63 | function codeParticionado (form) { |
---|
64 | var partCode=""; |
---|
65 | var logicalCode=""; |
---|
66 | var cacheCode; |
---|
67 | var cacheSize; |
---|
68 | var extended=false; |
---|
69 | |
---|
70 | for (var nPart=1; nPart<4; nPart++) { |
---|
71 | var partCheck=eval("form.check"+nPart); |
---|
72 | if (partCheck.checked) { |
---|
73 | var partType=eval("form.part"+nPart); |
---|
74 | if (partType.value == "CUSTOM" ) { |
---|
75 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
76 | partCode += " " + partTypeCustom.value; |
---|
77 | if (partTypeCustom.value == "EXTENDED") { |
---|
78 | extended=true; |
---|
79 | } |
---|
80 | } else { |
---|
81 | partCode += " " + partType.value; |
---|
82 | if (partType.value == "EXTENDED") { |
---|
83 | extended=true; |
---|
84 | } |
---|
85 | } |
---|
86 | var partSize=eval("form.size"+nPart); |
---|
87 | if (partSize.value == "CUSTOM" ) { |
---|
88 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
89 | partCode += ":" + partSizeCustom.value; |
---|
90 | } else { |
---|
91 | partCode += ":" + partSize.value; |
---|
92 | } |
---|
93 | } else { |
---|
94 | partCode += " EMPTY:0"; |
---|
95 | } |
---|
96 | } |
---|
97 | if (form.check4.checked) { |
---|
98 | if (form.size4.value == "0") { |
---|
99 | //cacheCode = " ogUnmountCache \n ogUnmountAll 1 \n sizecache=`ogGetPartitionSize 1 4` \n ogDeletePartitionTable 1 \n ogUpdatePartitionTable 1 \n initCache $sizecache "; |
---|
100 | cacheCode="\ |
---|
101 | echo \"[20] $MSG_HELP_ogGetPartitionSize CACHE\" | tee -a $OGLOGSESSION \n \ |
---|
102 | sizecache=`ogGetPartitionSize 1 4` \n \ |
---|
103 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
104 | ogDeletePartitionTable 1 \n \ |
---|
105 | ogUpdatePartitionTable 1 | tee -a $OGLOGCOMMAND \n \ |
---|
106 | echo \"[50] $MSG_HELP_ogCreateCache \" | tee -a $OGLOGSESSION \n \ |
---|
107 | initCache $sizecache &>/dev/null | tee -a $OGLOGCOMMAND \n "; |
---|
108 | } else { |
---|
109 | if (form.size4.value == "CUSTOM") { |
---|
110 | cacheSize = form.size4custom.value; |
---|
111 | } else { |
---|
112 | cacheSize = form.size4.value; |
---|
113 | } |
---|
114 | //cacheCode = " ogUnmountCache \n ogUnmountAll 1 \n ogDeletePartitionTable 1 \n ogUpdatePartitionTable 1 \n initCache " + cacheSize; |
---|
115 | cacheCode="\ |
---|
116 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
117 | ogDeletePartitionTable 1 \n \ |
---|
118 | ogUpdatePartitionTable 1 \n \ |
---|
119 | echo \"[50] $MSG_HELP_ogCreateCache \" | tee -a $OGLOGSESSION \n \ |
---|
120 | initCache " + cacheSize + " &>/dev/null | tee -a $OGLOGCOMMAND"; |
---|
121 | } |
---|
122 | } else { |
---|
123 | //cacheCode = " ogUnmountCache \n ogUnmountAll 1 \n ogDeletePartitionTable 1 \n ogUpdatePartitionTable 1 "; |
---|
124 | cacheCode="\ |
---|
125 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
126 | ogDeletePartitionTable 1 \n \ |
---|
127 | ogUpdatePartitionTable 1 \n"; |
---|
128 | partCode += " EMPTY:0"; |
---|
129 | } |
---|
130 | if (extended) { |
---|
131 | var lastLogical=5; |
---|
132 | for (var nPart=9; nPart>5; nPart--) { |
---|
133 | if (eval ("form.check"+nPart+".checked")) { |
---|
134 | lastLogical = nPart; |
---|
135 | break; |
---|
136 | } |
---|
137 | } |
---|
138 | for (var nPart=5; nPart<=lastLogical; nPart++) { |
---|
139 | var partCheck=eval("form.check"+nPart); |
---|
140 | if (partCheck.checked) { |
---|
141 | var partType=eval("form.part"+nPart); |
---|
142 | if (partType.value == "CUSTOM" ) { |
---|
143 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
144 | logicalCode += " " + partTypeCustom.value; |
---|
145 | } else { |
---|
146 | logicalCode += " " + partType.value; |
---|
147 | } |
---|
148 | var partSize=eval("form.size"+nPart); |
---|
149 | if (partSize.value == "CUSTOM" ) { |
---|
150 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
151 | logicalCode += ":" + partSizeCustom.value; |
---|
152 | } else { |
---|
153 | logicalCode += ":" + partSize.value; |
---|
154 | } |
---|
155 | } else { |
---|
156 | logicalCode += " EMPTY:0"; |
---|
157 | } |
---|
158 | } |
---|
159 | partCode += logicalCode; |
---|
160 | } |
---|
161 | |
---|
162 | // form.codigo.value="\ |
---|
163 | //" + cacheCode + " \n \ |
---|
164 | //ogListPartitions 1 \n \ |
---|
165 | //ogCreatePartitions 1 " + partCode + " \n \ |
---|
166 | //ogSetPartitionActive 1 1 \n \ |
---|
167 | //ogUpdatePartitionTable 1 \n \ |
---|
168 | //ogListPartitions 1 \n"; |
---|
169 | form.codigo.value="\ |
---|
170 | echo \"[0] $MSG_HELP_ogCreatePartitions \" | tee -a $OGLOGSESSION $OGLOGFILE \n \ |
---|
171 | echo \"[10] $MSG_HELP_ogUnmountAll 1\" | tee -a $OGLOGSESSION \n \ |
---|
172 | ogUnmountCache \n \ |
---|
173 | ogUnmountAll 1 \n \ |
---|
174 | " + cacheCode + " \n \ |
---|
175 | echo \"[60] $MSG_HELP_ogListPartitions 1\" | tee -a $OGLOGSESSION \n \ |
---|
176 | ogListPartitions 1 | tee -a $OGLOGCOMMAND $OGLOGSESSION \n \ |
---|
177 | echo \"[70] $MSG_HELP_ogCreatePartitions " + partCode + " \" | tee -a $OGLOGSESSION \n \ |
---|
178 | ogCreatePartitions 1 " + partCode + " | tee -a $OGLOGCOMMAND \n \ |
---|
179 | echo \"[80] $MSG_HELP_ogSetPartitionActive 1 1\" | tee -a $OGLOGSESSION \n \ |
---|
180 | ogSetPartitionActive 1 1 \n \ |
---|
181 | echo \"[100] $MSG_HELP_ogListPartitions 1\" | tee -a $OGLOGSESSION $OGLOGFILE \n \ |
---|
182 | ogUpdatePartitionTable 1 \n \ |
---|
183 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
184 | ogListPartitions 1 | tee -a $OGLOGCOMMAND $OGLOGSESSION $OGLOGFILE \n"; |
---|
185 | |
---|
186 | } |
---|
187 | |
---|
188 | |
---|
189 | // Código de pulsación de selección de partición. |
---|
190 | function clickPartitionCheckbox(form, npart) { |
---|
191 | var partCheck=eval("form.check"+npart); |
---|
192 | var partType=eval("form.part"+npart); |
---|
193 | var partSize=eval("form.size"+npart); |
---|
194 | var partTypeCustom=eval("form.part"+npart+"custom"); |
---|
195 | var partSizeCustom=eval("form.size"+npart+"custom"); |
---|
196 | var freeDisk=document.getElementById("freedisk"); |
---|
197 | var logical=document.getElementById("logicas"); |
---|
198 | if (partCheck.checked) { |
---|
199 | partType.disabled=false; |
---|
200 | partSize.disabled=false; |
---|
201 | if (partType.options[partType.selectedIndex].value == "CUSTOM") { |
---|
202 | partTypeCustom.disabled=false; |
---|
203 | } |
---|
204 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
205 | partSizeCustom.disabled=false; |
---|
206 | } else { |
---|
207 | partSizeCustom.disabled=true; |
---|
208 | } |
---|
209 | } else { |
---|
210 | partType.disabled=true; |
---|
211 | partSize.disabled=true; |
---|
212 | partTypeCustom.disabled=true; |
---|
213 | partSizeCustom.disabled=true; |
---|
214 | } |
---|
215 | if (npart <= 4) { |
---|
216 | checkExtendedPartition(form); |
---|
217 | calculateFreeDisk(form); |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | |
---|
222 | // Código para calcular el espacio libre del disco. |
---|
223 | function calculateFreeDisk(form) { |
---|
224 | var freeDisk=document.getElementById("freedisk"); |
---|
225 | freeDisk.value=form.minsize.value; |
---|
226 | for (npart=1; npart<=4; npart++) { |
---|
227 | var partCheck=eval("form.check"+npart); |
---|
228 | var partSize=eval("form.size"+npart); |
---|
229 | var partSizeCustom=eval("form.size"+npart+"custom"); |
---|
230 | if (partCheck.checked) { |
---|
231 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
232 | freeDisk.value -= parseInt(partSizeCustom.value); |
---|
233 | } else { |
---|
234 | freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value); |
---|
235 | } |
---|
236 | } |
---|
237 | } |
---|
238 | if (parseInt(freeDisk.value) < 0) { |
---|
239 | freeDisk.style.fontWeight = "bold"; |
---|
240 | freeDisk.style.fontStyle = "italic"; |
---|
241 | } else { |
---|
242 | freeDisk.style.fontWeight = "normal"; |
---|
243 | freeDisk.style.fontStyle = "normal"; |
---|
244 | } |
---|
245 | if (form.size4.value == 0) { |
---|
246 | freeDisk.value += " (- cache)"; // Aviso de caché sin modificar. |
---|
247 | } |
---|
248 | } |
---|
249 | |
---|
250 | // Código para comprobar si hay partición extendida activa para mostrar las lógicas. |
---|
251 | function checkExtendedPartition(form) { |
---|
252 | var logical=document.getElementById("logicas"); |
---|
253 | var visible=false; |
---|
254 | for (npart=1; npart<4; npart++) { |
---|
255 | var partCheck=eval("form.check"+npart); |
---|
256 | var partType=eval("form.part"+npart); |
---|
257 | var partTypeCustom=eval("form.part"+npart+"custom"); |
---|
258 | if (partCheck.checked) { |
---|
259 | partType.style.fontWeight = "normal"; |
---|
260 | partTypeCustom.style.fontWeight = "normal"; |
---|
261 | if (partType.value == "EXTENDED") { |
---|
262 | visible=true; |
---|
263 | partType.style.fontWeight = "bold"; |
---|
264 | } |
---|
265 | if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") { |
---|
266 | visible=true; |
---|
267 | partTypeCustom.style.fontWeight = "bold"; |
---|
268 | } |
---|
269 | } |
---|
270 | } |
---|
271 | if (visible) { |
---|
272 | logical.style.visibility="visible"; |
---|
273 | } else { |
---|
274 | logical.style.visibility="hidden"; |
---|
275 | } |
---|
276 | } |
---|
277 | |
---|