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

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

Versión 1.0.4a, #556: Corregir errata en gestor de Netboot Avanzado

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

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