Magellan Linux

Contents of /alx-src/trunk/alx-web/reboot.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 355 - (show annotations) (download)
Mon Oct 10 19:42:06 2005 UTC (18 years, 6 months ago) by niro
File size: 1722 byte(s)
cvs import: alx-web for alxconfig-ng
 - code clean up and
 - reorganized the whole structure

1 <?
2 /* das script benötigt folgende tabellen in der datenbank:
3 * ssh_auth_clients spalten -> serial [int 11], public_key [text]
4 * ssh_auth_server spalten -> id [int 11], public_key [text]
5 *
6 * du musst auf jeden fall den ping befehl anpassen und der pfad zum hostfile auf dem
7 * apache2 lautet '/home/httpd/.ssh/known_host', evtl müsste das verzeichnis .ssh erstellt werden
8 *
9 * that's it, works4me (TM)
10 */
11
12 // $client = '16';
13 // $ip = '128.20.40.61';
14 // $op = 'reboot';
15
16 echo '<body onload="window.setTimeout(\'window.close()\', 1750)">';
17 echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>';
18 include('include/dbconn.php');
19
20 $pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$client.'');
21 while ($row = mysql_fetch_row ($pubkey)) {
22 // echo 'Client Public RSA-Key:<br>';
23 // echo $row[0].'<br>';
24
25 # schreiben der .ssh/known_hosts file mit dem public rsa key des client,
26 # um die "yes" abfrage zu vermeiden
27 $hostfile = fopen ("/home/www-data/.ssh/known_hosts","w");
28 fwrite($hostfile,$ip." ".$row[0],strlen($row[0])+strlen($ip)+1);
29 fclose($hostfile);
30
31 # reboot des clients
32 // passthru('/bin/ping -I eth0 -c 1 -W 1 -q '.$ip.' &> /dev/null && exit 0 || exit 1',$retval);
33 passthru('/usr/sbin/fping -c 1 -t 50 -q '.$ip.' &> /dev/null && exit 0 || exit 1',$retval);
34 if($retval==0) {
35 echo '<img src="pics/online.gif" align=top> '.strtoupper($op.'ing client #'.$client.' ('.$ip.')...<br>');
36 system('/usr/bin/ssh -l root '.$ip.' /sbin/'.$op);
37 }
38 else echo '<img src="pics/offline.gif" align=top> '.strtoupper('Client not online, try again later...<br>');
39 }
40 echo '</td></tr></table>';
41 ?>

Properties

Name Value
svn:executable *