Magellan Linux

Diff of /alx-src/trunk/alx-web/mageupgrade.php

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

revision 355 by niro, Mon Oct 10 19:42:06 2005 UTC revision 424 by niro, Wed Jun 4 21:54:04 2008 UTC
# Line 1  Line 1 
1  <?  <?
2  # echo '<body onload="window.setTimeout(\'window.close()\', 1750)">';   include('include/config.inc.php');
3   echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>';   include('include/dbconn.php');
4   include('include/dbconn.php');   include('include/basesql.php');
5    
6  # $client = '1';   echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>';
7  # $ip = '192.168.0.159';  ?>
8  # $op = 'calcdsfs';   <style type="text/css">
9     div.left { margin-left:20%; }
10   $home = '/home/www-data';   </style>
11  # $update_alx_cmd = 'NOCOLORS=true  <?
12  # /usr/sbin/update-alx   function editvar($var, $value, $file)
13  # --user tjoke   {
14  # --pass strunz   global $ip;
15  # --server-share //192.168.0.2/magetmp   global $sshcmd;
16  # --min-space 50000  
17  # --mirrors http://192.168.0.2/magellan-050   // sed cmd: ssh -l root 10.11.12.13 'sed -i -e "s|^(VAR=).*|\"VALUE\"| FILE'
18  # --rsync rsync://192.168.0.2/mage-cvs-alx   $str = $sshcmd.' -l root '.$ip.' \'sed -i -e "s|^\\('.$var.'=\\).*|\\1\\"'.$value.'\\"|" '.$file.'\'';
19  # --profile alx-050';   system($str);
20  # --proxy   }
21  # --ftp-proxy  
22  # --http-proxy   $pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$client.'');
23  # --no-proxy';   while ($row = mysql_fetch_row ($pubkey))
24     {
25     # schreiben der .ssh/known_hosts file mit dem public rsa key des client,
26  ?>   # um die "yes" abfrage zu vermeiden
27   <style type="text/css">   $hostfile = fopen ($home."/.ssh/known_hosts","w");
28   div.left { margin-left:20%; }   fwrite($hostfile,$ip." ".$row[0],strlen($row[0])+strlen($ip)+1);
29   </style>   fclose($hostfile);
30  <?  
31     # reboot des clients
32   $pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$client.'');   passthru($pingcmd.' '.$ip.' &> /dev/null && exit 0 || exit 1',$retval);
33   while ($row = mysql_fetch_row ($pubkey))   if($retval==0)
34   {   {
35   # schreiben der .ssh/known_hosts file mit dem public rsa key des client,   if($op=="calc")
36   # um die "yes" abfrage zu vermeiden   {
37   $hostfile = fopen ($home."/.ssh/known_hosts","w");   echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...<br>');
38   fwrite($hostfile,$ip." ".$row[0],strlen($row[0])+strlen($ip)+1);   exec($sshcmd.' -l root '.$ip.' /sbin/mageupgrade --calc-bash',$out,$err);
39   fclose($hostfile);   echo '<pre>';
40     echo '<table border="0">';
41   # reboot des clients   if (array_key_exists("0", $out))
42   passthru('/usr/sbin/fping -c 1 -t 50 -q '.$ip.' &> /dev/null && exit 0 || exit 1',$retval);   {
43   if($retval==0)   foreach( $out as $i)
44   {   {
45   if($op=="calc")   $item=explode(",",$i);
46   {   $pcat=$item[0];
47   echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...<br>');   $pname=$item[1];
48   exec('/usr/bin/ssh -l root '.$ip.' /sbin/mageupgrade --calc-bash',$out,$err);   $opver=$item[2];
49   echo '<pre>';   $npver=$item[3];
50   echo '<table border="0">';  
51   if (array_key_exists("0", $out))   echo '<tr><td>';
52   {   echo '<font color=green>'.$pcat.'/'.$pname.'</font>';
53   foreach( $out as $i)   echo '<td>';
54   {   echo '<font color=blue> [ '.$opver.' -> '.$npver.' ] </font>';
55   $item=explode(",",$i);   echo '</td>';
56   $pcat=$item[0];   echo '</td></tr>';
57   $pname=$item[1];   }
58   $opver=$item[2];   }
59   $npver=$item[3];   else echo 'No updates for client '.$client.' available.';
60     echo '</table>';
61   echo '<tr><td>';   echo '</pre>';
62   echo '<font color=green>'.$pcat.'/'.$pname.'</font>';   }
63   echo '<td>';   elseif($op=="update")
64   echo '<font color=blue> [ '.$opver.' -> '.$npver.' ] </font>';   {
65   echo '</td>';   echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...<br>');
66   echo '</td></tr>';   echo '<br>';
67   }   echo '<pre><div align=left class=left>';
68   }   // hotfix copy a fixed mage.rc
69   else echo 'No updates for client '.$client.' available.';   system('scp /var/www/localhost/htdocs/alx/he/mage.rc root@'.$ip.':/etc/mage.rc');
70   echo '</table>';   editvar("VERBOSE","off","/etc/mage.rc");
71   echo '</pre>';  
72   }   // update rsync server location
73   elseif($op=="update")   $rsync = sqlfirst('select client_locations.rsync from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'rsync');
74   {   echo $rsync;
75   echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...<br>');   editvar("RSYNC",$rsync,"/etc/mage.rc");
76   echo '<br>';  
77   echo '<pre><div align=left class=left>';   system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage update"');
78   system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /sbin/mage update"');   echo '</div></pre>';
79   echo '</div></pre>';   echo '<script language="JavaScript">alert(\'Database-update successfully completed on client #'.$client.' .\')</script>';
80   }   }
81   elseif($op=="upgrade")   elseif($op=="upgrade")
82   {   {
83   echo '<img src="pics/online.gif" align=top> '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')...<br>');   echo '<img src="pics/online.gif" align=top> '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')...<br>');
84   echo '<br>';   echo '<br>';
85   echo '<pre><div align=left class=left>';   echo '<pre><div align=left class=left>';
86   echo 'forcing verbose=off <br>';   echo 'forcing verbose=off <br>';
87   system('/usr/bin/ssh -l root '.$ip.' \'sed -i -e "s:^\\(VERBOSE=\\).*:\\1\\"off\\":" /etc/mage.rc\'');   editvar("VERBOSE","off","/etc/mage.rc");
88   # check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first  
89   exec('/usr/bin/ssh -l root '.$ip.' "[ -x /usr/sbin/update-alx ] && exit 0 || exit 1"',$outarr,$err);   // update repository server locations
90   if($err!=0)   $repo = sqlfirst('SELECT repository FROM client_locations WHERE location="HAT"', 'repository');
91   {   editvar("MIRRORS",$repo,"/etc/mage.rc");
92   echo '"/usr/sbin/update-alx" missing on client "'.$client.'". Updating mage-alx and alxconfig-ng-alx first ...<br>';  
93   system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /sbin/mage install mage-alx"');   # check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first
94   #system('/usr/bin/scp /var/www/localhost/htdocs/alx/he/update-alx root@'.$ip.':/usr/sbin');   exec($sshcmd.' -l root '.$ip.' "[ -x /usr/sbin/update-alx ] && exit 0 || exit 1"',$outarr,$err);
95   system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /sbin/mage install alxconfig-ng-alx"');   if($err!=0)
96   }   {
97   #system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /usr/sbin/update-alx --user tjoke --pass strunz --server-share //192.168.0.2/magetmp --min-space 50000 --mirrors http://192.168.0.2/alx-050 --rsync rsync://192.168.0.2/mage-cvs-alx --profile alx-050"');   echo '"/usr/sbin/update-alx" missing on client "'.$client.'". Updating mage-alx and alxconfig-ng-alx first ...<br>';
98   system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /usr/sbin/update-alx"');   system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage install mage-alx"');
99   echo '</div></pre>';   system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage install alxconfig-ng-alx"');
100   }   }
101   else echo 'unkown operation';   system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /usr/sbin/update-alx"');
102   }   echo '</div></pre>';
103     echo '<script language="JavaScript">alert(\'Upgrade successfully installed on client #'.$client.' .\')</script>';
104   else echo '<img src="pics/offline.gif" align=top> '.strtoupper('Client not online, try again later...<br>');   }
105   }   else echo 'unkown operation';
106   echo '</td></tr></table>';   }
107  ?>  
108     else echo '<img src="pics/offline.gif" align=top> '.strtoupper('Client not online, try again later...<br>');
109     }
110     echo '</td></tr></table>';
111    ?>

Legend:
Removed from v.355  
changed lines
  Added in v.424