source: admin/WebConsole/gestores/gestor_pxe.php @ 4a03527

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 4a03527 was 09468cb, checked in by ramon <ramongomez@…>, 13 years ago

Versión 1.0.3, #483: Código correcto para idioma catalán.

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

  • Property mode set to 100644
File size: 5.6 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;
47$cmd->CreaParametro("@optboot",$optboot,0);
48$cmd->CreaParametro("@hostname",$hostname,0);
49$cmd->texto="update ordenadores set arranque=@optboot where nombreordenador=@hostname";
50$cmd->Ejecutar();
51
52$cmd->texto="SELECT ordenadores.ip AS ip, ordenadores.mac AS mac,
53                        ordenadores.netiface AS netiface, aulas.netmask AS netmask, aulas.router AS router,
54                        repositorios.ip AS iprepo FROM ordenadores
55                        join aulas on ordenadores.idaula=aulas.idaula
56                        join repositorios on ordenadores.idrepositorio=repositorios.idrepositorio
57                        where ordenadores.nombreordenador='". $hostname ."'";
58$rs=new Recordset;
59$rs->Comando=&$cmd;
60if (!$rs->Abrir()) echo "error";
61$rs->Primero();
62        $mac=$rs->campos["mac"];
63        $netiface=$rs->campos["netiface"];
64        $ip=$rs->campos["ip"];
65        $router=$rs->campos["router"];
66        $netmask=$rs->campos["netmask"];
67        $repo=$rs->campos["iprepo"];                   
68$rs->Cerrar();
69
70$cmd->texto="SELECT ipserveradm from entornos";
71$rs=new Recordset;
72$rs->Comando=&$cmd;
73if (!$rs->Abrir()) echo "error";
74
75$rs->Primero();
76        $server=$rs->campos["ipserveradm"];
77$rs->Cerrar();
78
79switch ($idioma) {
80    case eng:
81        $idioma=en_GB;
82        break;
83    case esp:
84        $idioma=es_ES;
85        break;
86    case cat:
87        $idioma=ca_ES;
88        break;
89}
90
91
92$infohost="LANG=" .$idioma . " ip="
93. $ip . ":"
94. $server .":"
95. $router . ":"
96. $netmask .":"
97. $hostname .":"
98. $netiface . ":none ogrepo="
99. $repo . " oglive="
100. $repo . " oglog="
101. $server . " ogshare="
102. $repo;
103
104###################obtenemos las variables de red del aula.
105
106        #02.1 obtenemos nombre fichero mac
107        $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);
108        $macfile="01-" . str_replace(":","-",strtolower($mac));
109        $nombre_archivo="/var/lib/tftpboot/pxelinux.cfg/" . $macfile;
110
111
112########## Escribimos el fichero mac
113if (!$gestion=fopen($nombre_archivo, 'w+'))
114{
115        echo "No se puede abrir el archivo ($nombre_archivo)";
116        return;
117}       
118# cuales son los parametros del menu
119fwrite($gestion, "DEFAULT syslinux/vesamenu.c32 \n");
120fwrite($gestion, "MENU TITLE Aplicacion OpenGnsys \n");
121
122$cmd->texto="SELECT itemboot.label, itemboot.kernel,
123                        itemboot.append, menuboot.timeout, menuboot.prompt,
124                         menuboot.description, menuboot_itemboot.default
125                        From itemboot,menuboot_itemboot,menuboot
126                        WHERE menuboot_itemboot.labelmenu=menuboot.label
127                        AND menuboot_itemboot.labelitem=itemboot.label
128                        AND menuboot.label='" . $optboot   . "'";
129 
130$rs->Comando=&$cmd;
131if (!$rs->Abrir()) echo "error";
132$rs->Primero();
133while (!$rs->EOF)
134{
135                fwrite($gestion, " \n");     
136                fwrite($gestion, "LABEL " .  $rs->campos['label'] . " \n");
137                fwrite($gestion, "MENU LABEL " . $rs->campos['label'] . " \n");
138                if ( $rs->campos["default"] == true)
139                {
140                        fwrite($gestion, "MENU DEFAULT \n");
141                }
142                fwrite($gestion, $rs->campos["kernel"] . " \n");
143                # set netmask cird para ogclient
144                $isnfsroot=substr_count($rs->campos["append"] , "boot=oginit");
145                if ($isnfsroot > 0)
146                {
147                        $netmask=$netmask;
148                }       
149                else
150                {
151                        $netmask=netmask2cidr($netmask);
152                }
153
154                $iseac=substr_count($rs->campos["append"] , "boot=oginit");
155                $isinitrd=substr_count($rs->campos["append"] , "initrd.gz");
156               
157                if ($iseac > 0)
158                {
159                        $append=$rs->campos["append"];
160                        fwrite($gestion, $append . " " . $infohost . " \n ");
161                }
162
163                elseif ($isinitrd > 0)
164                {
165                $append=$rs->campos["append"];
166                fwrite($gestion, $append . " ogrepo=" . $repo . " \n");
167                }
168                else
169                {
170                        fwrite($gestion, $rs->campos["append"] . " \n");
171                }
172
173                $prompt=$rs->campos["prompt"];
174                $timeout=$rs->campos["timeout"];
175
176                $rs->Siguiente();
177}
178$rs->Cerrar();
179
180                       
181
182        fwrite($gestion, " \n"); 
183        fwrite($gestion, "PROMPT " . $prompt ." \n");
184        fwrite($gestion, "TIMEOUT " . $timeout . " \n");
185        fwrite($gestion, " \n"); 
186        fclose($gestion);
187        exec("chown www-data:www-data /var/lib/tftpboot/pxelinux.cfg/". $macfile);
188        exec("chmod 777 /var/lib/tftpboot/pxelinux.cfg/". $macfile);
189       
190
191
192
193}
194
195function netmask2cidr($netmask) {
196          $cidr = 0;
197          foreach (explode('.', $netmask) as $number) {
198              for (;$number> 0; $number = ($number <<1) % 256) {
199                  $cidr++;
200               }
201           }
202           return $cidr;
203 }
204
205?>
Note: See TracBrowser for help on using the repository browser.