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
RevLine 
[8b2dce81]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) {
[09d966f]28        if (! empty ($sublista)) {
[18ba143]29                $elementos = explode("|",$sublista);
30                $hostname=$elementos[1];
31                $optboot=$elementos[0];
32                ogBootServer($cmd,$optboot,$hostname,$idioma);
33        }
[8b2dce81]34}
35echo " </body>";
36echo " </html> ";
37
[18ba143]38
[eaf2e6e]39function ogBootServer($cmd,$optboot,$hostname,$idioma)
[8b2dce81]40{       
41global $cmd;
42global $hostname;
43global $optboot;
[095d193]44global $retrun;
45$return="\n";
[8b2dce81]46$cmd->CreaParametro("@optboot",$optboot,0);
47$cmd->CreaParametro("@hostname",$hostname,0);
[18ba143]48$cmd->texto="UPDATE ordenadores SET arranque=@optboot WHERE nombreordenador=@hostname";
[8b2dce81]49$cmd->Ejecutar();
50$cmd->texto="SELECT ordenadores.ip AS ip, ordenadores.mac AS mac,
[b2bd768]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
[18ba143]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 ."'";
[5bac736]62
[8b2dce81]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"];                   
[fa4129c]73        $group=cleanString($rs->campos["grupo"]);
[b2bd768]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"];
[5bac736]79
[8b2dce81]80$rs->Cerrar();
81
[fa4129c]82$cmd->texto="SELECT ipserveradm FROM entornos";
[ea5fbb9]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
[eaf2e6e]91
92switch ($idioma) {
[18ba143]93    case "eng":
94        $idioma="en_GB";
[eaf2e6e]95        break;
[18ba143]96    case "esp":
97        $idioma="es_ES";
[eaf2e6e]98        break;
[18ba143]99    case "cat":
100        $idioma="ca_ES";
[eaf2e6e]101        break;
102}
103
104
[5bac736]105$infohost=" vga=$vga".
106          " LANG=$idioma".
107          " ip=$ip:$server:$router:$netmask:$hostname:$netiface:none" .
[fa4129c]108          " group=$group" .
109          " ogrepo=$repo" .
110          " oglive=$repo" .
111          " oglog=$server" .
[5bac736]112          " ogshare=$server";
[b2bd768]113if (! empty ($winboot)) {
114          $infohost.=" winboot=$winboot";
115}
[ea5fbb9]116
[8b2dce81]117###################obtenemos las variables de red del aula.
118
[5bac736]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));
[8b2dce81]123
[4a80437]124#controlar optboot
[8b2dce81]125
[5bac736]126exec("sed -e 's/vga=...//g' -e 's/INFOHOST/$infohost/g' $pxedir/templates/$optboot > $macfile");
127exec("chmod 777 $macfile");
[8b2dce81]128}
129
[5bac736]130
[8b2dce81]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;
[efe8ac7]139}
[8b2dce81]140
[fa4129c]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?>
[efe8ac7]149
Note: See TracBrowser for help on using the repository browser.