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

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 c1cd54c was b2bd768, checked in by ramon <ramongomez@…>, 13 years ago

Versión 1.0.4, #525: Integrar ticket:525 en rama de desarrollo.

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

  • Property mode set to 100644
File size: 4.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,$idioma);
38}
39echo " </body>";
40echo " </html> ";
41
42function ogBootServer($cmd,$optboot,$hostname,$idioma)
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$cmd->texto="SELECT ordenadores.ip AS ip, ordenadores.mac AS mac,
54                        ordenadores.netiface AS netiface, aulas.netmask AS netmask,
55                        aulas.router AS router, repositorios.ip AS iprepo,
56                        aulas.nombreaula AS grupo,
57                        menus.resolucion AS vga,
58                        perfileshard.winboot AS winboot
59                        FROM ordenadores
60                        JOIN aulas ON ordenadores.idaula=aulas.idaula
61                        JOIN repositorios ON ordenadores.idrepositorio=repositorios.idrepositorio
62                        LEFT JOIN menus ON ordenadores.idmenu=menus.idmenu
63                        LEFT JOIN perfileshard ON ordenadores.idperfilhard=perfileshard.idperfilhard
64                        WHERE ordenadores.nombreordenador='". $hostname ."'";
65
66
67$rs=new Recordset;
68$rs->Comando=&$cmd;
69if (!$rs->Abrir()) echo "error";
70$rs->Primero();
71        $mac=$rs->campos["mac"];
72        $netiface=$rs->campos["netiface"];
73        $ip=$rs->campos["ip"];
74        $router=$rs->campos["router"];
75        $netmask=$rs->campos["netmask"];
76        $repo=$rs->campos["iprepo"];                   
77        $group=cleanString($rs->campos["grupo"]);
78        if($rs->campos["vga"]== null || $rs->campos["vga"]== 0)
79                $vga="788";
80        else
81                $vga=$rs->campos["vga"];
82        $winboot=$rs->campos["winboot"];
83
84$rs->Cerrar();
85
86$cmd->texto="SELECT ipserveradm FROM entornos";
87$rs=new Recordset;
88$rs->Comando=&$cmd;
89if (!$rs->Abrir()) echo "error";
90
91$rs->Primero();
92        $server=$rs->campos["ipserveradm"];
93$rs->Cerrar();
94
95
96switch ($idioma) {
97    case eng:
98        $idioma=en_GB;
99        break;
100    case esp:
101        $idioma=es_ES;
102        break;
103    case cat:
104        $idioma=ca_ES;
105        break;
106}
107
108
109$infohost=" vga=$vga".
110          " LANG=$idioma".
111          " ip=$ip:$server:$router:$netmask:$hostname:$netiface:none" .
112          " group=$group" .
113          " ogrepo=$repo" .
114          " oglive=$repo" .
115          " oglog=$server" .
116          " ogshare=$server";
117if (! empty ($winboot)) {
118          $infohost.=" winboot=$winboot";
119}
120
121###################obtenemos las variables de red del aula.
122
123#02.1 obtenemos nombre fichero mac
124$pxedir="/opt/opengnsys/tftpboot/menu.lst";
125$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);
126$macfile="$pxedir/01-" . str_replace(":","-",strtoupper($mac));
127
128#controlar optboot
129
130exec("sed -e 's/vga=...//g' -e 's/INFOHOST/$infohost/g' $pxedir/templates/$optboot > $macfile");
131exec("chown www-data:www-data $macfile");
132exec("chmod 777 $macfile");
133
134}
135
136
137function netmask2cidr($netmask) {
138          $cidr = 0;
139          foreach (explode('.', $netmask) as $number) {
140              for (;$number> 0; $number = ($number <<1) % 256) {
141                  $cidr++;
142               }
143           }
144           return $cidr;
145 }
146
147// Sustituye espacio por "_" y quita acentos y tildes.
148function cleanString ($cadena) {
149        $patron = array ('/ /','/á/','/é/','/í/','/ó/','/ú/','/ñ/','/Á/','/É/','/Í/','/Ó/','/Ú/','/Ñ/');
150        $reemplazo = array ('_','a','e','i','o','u','n','A','E','I','O','U','N');
151        return  preg_replace($patron,$reemplazo,$cadena);
152}
153
154?>
Note: See TracBrowser for help on using the repository browser.