source: admin/WebConsole/gestores/gestor_pxe_grub4dos.php @ cceeb84

Last change on this file since cceeb84 was ecd8d9a, checked in by ramon <ramongomez@…>, 14 years ago

Integrar OpenGnSys 1.0.1 en rama principal (modifica #413).

git-svn-id: https://opengnsys.es/svn/trunk@2065 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 3.5 KB
Line 
1<?php
2include_once("../includes/ctrlacc.php");
3include_once("../clases/AdoPhp.php");
4include_once("../clases/XmlPhp.php");
5include_once("../clases/MenuContextual.php");
6include_once("../clases/SockHidra.php");
7include_once("../includes/constantes.php");
8include_once("../includes/comunes.php");
9include_once("../includes/CreaComando.php");
10include_once("../idiomas/php/".$idioma."/aulas_".$idioma.".php");
11
12$cmd=CreaComando($cadenaconexion);
13if (!$cmd)
14        Header('Location: '.$pagerror.'?herror=2'); // Error de conexión con servidor B.D.
15//________________________________________________________________________________________________________
16
17
18echo "<html>";
19echo "<head>";
20echo "<meta http-equiv='Refresh' content='1;URL=../principal/boot.php?idambito=". $_GET['idaula'] ."&nombreambito=" . $_GET['nombreambito'] . "&litambito=" . $_GET['litambito'] . "'>";
21echo "<title> gestion de equipos </title>";
22echo "<base target='principal'>";
23echo "</head>";
24echo "<body>";
25
26
27
28#echo('litambito con valor:     '. $_GET['litambito']);
29#echo ('idambito con valor:      ' . $_GET['idaula']);
30#echo ('nombreambito con valor:      ' . $_GET['nombreambito']);
31
32$lista = explode(";",$_POST['listOfItems']);
33foreach ($lista as $sublista) {
34        $elementos = explode("|",$sublista);
35        $hostname=$elementos[1];
36        $optboot=$elementos[0];
37        ogBootServer($cmd,$optboot,$hostname);
38}
39echo " </body>";
40echo " </html> ";
41
42function ogBootServer($cmd,$optboot,$hostname)
43{       
44global $cmd;
45global $hostname;
46global $optboot;
47global $retrun;
48$return="\n";
49$cmd->CreaParametro("@optboot",$optboot,0);
50$cmd->CreaParametro("@hostname",$hostname,0);
51$cmd->texto="update ordenadores set arranque=@optboot where nombreordenador=@hostname";
52$cmd->Ejecutar();
53
54$cmd->texto="SELECT ordenadores.ip AS ip, ordenadores.mac AS mac,
55                        ordenadores.netiface AS netiface, aulas.netmask AS netmask, aulas.router AS router,
56                        repositorios.ip AS iprepo FROM ordenadores
57                        join aulas on ordenadores.idaula=aulas.idaula
58                        join repositorios on ordenadores.idrepositorio=repositorios.idrepositorio
59                        where ordenadores.nombreordenador='". $hostname ."'";
60$rs=new Recordset;
61$rs->Comando=&$cmd;
62if (!$rs->Abrir()) echo "error";
63$rs->Primero();
64        $mac=$rs->campos["mac"];
65        $netiface=$rs->campos["netiface"];
66        $ip=$rs->campos["ip"];
67        $router=$rs->campos["router"];
68        $netmask=$rs->campos["netmask"];
69        $repo=$rs->campos["iprepo"];                   
70        $infohost="ip="
71                        . $ip . ":"
72                        . $repo .":"
73                        . $router . ":"
74                        . $netmask .":"
75                        . $hostname .":"
76                        . $netiface . ":none";  # repo="
77                        #. $repo;
78$rs->Cerrar();
79
80###################obtenemos las variables de red del aula.
81
82        #02.1 obtenemos nombre fichero mac
83        $mac=  substr($mac,0,2) . ":" . substr($mac,2,2) . ":" . substr($mac,4,2) . ":" . substr($mac,6,2) . ":" . substr($mac,8,2) . ":" . substr($mac,10,2);
84        $macfile="01-" . str_replace(":","-",strtoupper($mac));
85        $nombre_archivo="/var/lib/tftpboot/menu.lst/" . $macfile;
86
87#controlar optboot
88
89        #exec("cp /var/lib/tftpboot/menu.lst/templates/". $optboot . " /var/lib/tftpboot/menu.lst/". $macfile);
90        exec("sed s/INFOHOST/".$infohost."/g /var/lib/tftpboot/menu.lst/templates/" . $optboot . " > /var/lib/tftpboot/menu.lst/" . $macfile);
91        exec("chown www-data:www-data /var/lib/tftpboot/menu.lst/". $macfile);
92        exec("chmod 777 /var/lib/tftpboot/menu.lst/". $macfile);
93       
94
95
96
97}
98
99function netmask2cidr($netmask) {
100          $cidr = 0;
101          foreach (explode('.', $netmask) as $number) {
102              for (;$number> 0; $number = ($number <<1) % 256) {
103                  $cidr++;
104               }
105           }
106           return $cidr;
107 }
108
109?>
Note: See TracBrowser for help on using the repository browser.