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

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since cd95622 was ea5fbb9, checked in by adv <adv@…>, 14 years ago

version 1.0.2 #423 netboot servicios distribuidos

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2112 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 3.7 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$rs->Cerrar();
71
72$cmd->texto="SELECT ipserveradm from entornos";
73$rs=new Recordset;
74$rs->Comando=&$cmd;
75if (!$rs->Abrir()) echo "error";
76
77$rs->Primero();
78        $server=$rs->campos["ipserveradm"];
79$rs->Cerrar();
80
81$infohost="'ip="
82. $ip . ":"
83. $server .":"
84. $router . ":"
85. $netmask .":"
86. $hostname .":"
87. $netiface . ":none   repo="
88. $repo ."'";
89
90
91
92
93
94###################obtenemos las variables de red del aula.
95
96        #02.1 obtenemos nombre fichero mac
97        $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);
98        $macfile="01-" . str_replace(":","-",strtoupper($mac));
99        $nombre_archivo="/var/lib/tftpboot/menu.lst/" . $macfile;
100
101#controlar optboot
102
103        #exec("cp /var/lib/tftpboot/menu.lst/templates/". $optboot . " /var/lib/tftpboot/menu.lst/". $macfile);
104        exec("sed s/INFOHOST/".$infohost."/g /var/lib/tftpboot/menu.lst/templates/" . $optboot . " > /var/lib/tftpboot/menu.lst/" . $macfile);
105        exec("chown www-data:www-data /var/lib/tftpboot/menu.lst/". $macfile);
106        exec("chmod 777 /var/lib/tftpboot/menu.lst/". $macfile);
107       
108
109
110
111}
112
113function netmask2cidr($netmask) {
114          $cidr = 0;
115          foreach (explode('.', $netmask) as $number) {
116              for (;$number> 0; $number = ($number <<1) % 256) {
117                  $cidr++;
118               }
119           }
120           return $cidr;
121 }
122
123?>
Note: See TracBrowser for help on using the repository browser.