Magellan Linux

Diff of /alx-src/branches/alx-web-070/reboot.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

alx-src/branches/alx-web-050/reboot.php revision 1608 by niro, Thu Dec 2 22:13:04 2010 UTC alx-src/branches/alx-web-070/reboot.php revision 7737 by niro, Tue Nov 3 10:52:54 2015 UTC
# Line 1  Line 1 
1  <?  <?
2  /* das script benötigt folgende tabellen in der datenbank:  include('include/config.inc.php');
3   * ssh_auth_clients spalten -> serial [int 11], public_key [text]  include('include/basesql.php');
4   * ssh_auth_server spalten -> id [int 11], public_key [text]  include('include/socket_send.php');
  *  
  * du musst auf jeden fall den ping befehl anpassen und der pfad zum hostfile auf dem  
  * apache2 lautet '/home/httpd/.ssh/known_host', evtl müsste das verzeichnis .ssh erstellt werden  
  *  
  * that's it, works4me (TM)  
  */  
  include('include/dbconn.php');  
5    
6   echo '<body onload="window.setTimeout(\'window.close()\', 1750)">';  echo '<body onload="window.setTimeout(\'window.close()\', 1750)">';
7   echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>';  echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>';
8    
9   $pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$client.'');  # reboot des clients
10   while ($row = mysql_fetch_row ($pubkey)) {  $retval = ping_host($ip, $mcore_port, $ping_timeout);
11    if($retval==0)
12    {
13     echo '<img src="pics/online.gif" align=top> '.strtoupper($op.'ing client #'.$client.' ('.$ip.')...<br>');
14     if($op=="apply") mcore_socket_send($dbhost, $mcore_port, "push-config ".$client);
15     else mcore_socket_send($dbhost, $mcore_port, "control system.".$op." ".$client);
16    }
17    else echo '<img src="pics/offline.gif" align=top> '.strtoupper('Client not online, try again later...<br>');
18    
19   # schreiben der .ssh/known_hosts file mit dem public rsa key des client,  echo '</td></tr></table>';
  # um die "yes" abfrage zu vermeiden  
  $hostfile = fopen ($home."/.ssh/known_hosts","w");  
  fwrite($hostfile,$ip." ".$row[0],strlen($row[0])+strlen($ip)+1);  
  fclose($hostfile);  
   
  # reboot des clients  
  passthru($pingcmd.' '.$ip.' &> /dev/null && exit 0 || exit 1',$retval);  
  if($retval==0) {  
  echo '<img src="pics/online.gif" align=top> '.strtoupper($op.'ing client #'.$client.' ('.$ip.')...<br>');  
  system($sshcmd.' '.$ip.' /sbin/'.$op);  
  }  
  else echo '<img src="pics/offline.gif" align=top> '.strtoupper('Client not online, try again later...<br>');  
  }  
  echo '</td></tr></table>';  
20  ?>  ?>

Legend:
Removed from v.1608  
changed lines
  Added in v.7737