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 486 by niro, Sat Jun 7 17:25:27 2008 UTC
# Line 1  Line 1 
1  <?  <?
2  # echo '<body onload="window.setTimeout(\'window.close()\', 1750)">';   include('include/config.inc.php');
  echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>';  
3   include('include/dbconn.php');   include('include/dbconn.php');
4     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>';
 # $ip = '192.168.0.159';  
 # $op = 'calcdsfs';  
   
  $home = '/home/www-data';  
 # $update_alx_cmd = '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/magellan-050  
 # --rsync rsync://192.168.0.2/mage-cvs-alx  
 # --profile alx-050';  
 # --proxy  
 # --ftp-proxy  
 # --http-proxy  
 # --no-proxy';  
   
   
7  ?>  ?>
8   <style type="text/css">   <style type="text/css">
9   div.left { margin-left:20%; }   div.left { margin-left:20%; }
10   </style>   </style>
11  <?  <?
12     function editvar($var, $value, $file)
13     {
14     global $ip;
15     global $sshcmd;
16    
17     // sed cmd: ssh -l root 10.11.12.13 'sed -i -e "s|^(VAR=).*|\"VALUE\"| FILE'
18     $str = $sshcmd.' -l root '.$ip.' \'sed -i -e "s|^\\('.$var.'=\\).*|\\1\\"'.$value.'\\"|" '.$file.'\'';
19     system($str);
20     }
21    
22   $pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$client.'');   $pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$client.'');
23   while ($row = mysql_fetch_row ($pubkey))   while ($row = mysql_fetch_row ($pubkey))
# Line 39  Line 29 
29   fclose($hostfile);   fclose($hostfile);
30    
31   # reboot des clients   # reboot des clients
32   passthru('/usr/sbin/fping -c 1 -t 50 -q '.$ip.' &> /dev/null && exit 0 || exit 1',$retval);   passthru($pingcmd.' '.$ip.' &> /dev/null && exit 0 || exit 1',$retval);
33   if($retval==0)   if($retval==0)
34   {   {
35   if($op=="calc")   if($op=="calc")
36   {   {
37   echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...<br>');   echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...<br>');
38   exec('/usr/bin/ssh -l root '.$ip.' /sbin/mageupgrade --calc-bash',$out,$err);   exec($sshcmd.' -l root '.$ip.' /sbin/mageupgrade --calc-bash',$out,$err);
39   echo '<pre>';   echo '<pre>';
40   echo '<table border="0">';   echo '<table border="0">';
41   if (array_key_exists("0", $out))   if (array_key_exists("0", $out))
# Line 75  Line 65 
65   echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...<br>');   echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...<br>');
66   echo '<br>';   echo '<br>';
67   echo '<pre><div align=left class=left>';   echo '<pre><div align=left class=left>';
68   system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /sbin/mage update"');   editvar("VERBOSE","off","/etc/mage.rc");
69    
70     // update rsync server location
71     $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');
72     echo $rsync;
73     editvar("RSYNC",$rsync,"/etc/mage.rc");
74    
75     system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage update"');
76   echo '</div></pre>';   echo '</div></pre>';
77     echo '<script language="JavaScript">alert(\'Database-update successfully completed on client #'.$client.' .\')</script>';
78   }   }
79   elseif($op=="upgrade")   elseif($op=="upgrade")
80   {   {
# Line 84  Line 82 
82   echo '<br>';   echo '<br>';
83   echo '<pre><div align=left class=left>';   echo '<pre><div align=left class=left>';
84   echo 'forcing verbose=off <br>';   echo 'forcing verbose=off <br>';
85   system('/usr/bin/ssh -l root '.$ip.' \'sed -i -e "s:^\\(VERBOSE=\\).*:\\1\\"off\\":" /etc/mage.rc\'');   editvar("VERBOSE","off","/etc/mage.rc");
86    
87     // update repository server locations
88     $repo = sqlfirst('SELECT repository FROM client_locations WHERE location="HAT"', 'repository');
89     editvar("MIRRORS",$repo,"/etc/mage.rc");
90    
91   # check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first   # check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first
92   exec('/usr/bin/ssh -l root '.$ip.' "[ -x /usr/sbin/update-alx ] && exit 0 || exit 1"',$outarr,$err);   exec($sshcmd.' -l root '.$ip.' "[ -x /usr/sbin/update-alx ] && exit 0 || exit 1"',$outarr,$err);
93   if($err!=0)   if($err!=0)
94   {   {
95   echo '"/usr/sbin/update-alx" missing on client "'.$client.'". Updating mage-alx and alxconfig-ng-alx first ...<br>';   echo '"/usr/sbin/update-alx" missing on client "'.$client.'". Updating mage-alx and alxconfig-ng-alx first ...<br>';
96   system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /sbin/mage install mage-alx"');   system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage install mage-alx"');
97   #system('/usr/bin/scp /var/www/localhost/htdocs/alx/he/update-alx root@'.$ip.':/usr/sbin');   system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage install alxconfig-ng-alx"');
  system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /sbin/mage install alxconfig-ng-alx"');  
98   }   }
99   #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"');   system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /usr/sbin/update-alx"');
  system('/usr/bin/ssh -l root '.$ip.' "NOCOLORS=true /usr/sbin/update-alx"');  
100   echo '</div></pre>';   echo '</div></pre>';
101     echo '<script language="JavaScript">alert(\'Upgrade successfully installed on client #'.$client.' .\')</script>';
102   }   }
103   else echo 'unkown operation';   else echo 'unkown operation';
104   }   }

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