Magellan Linux

Diff of /alx-src/branches/alx-web-060/mageupgrade.php

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

alx-src/branches/alx-web-050/mageupgrade.php revision 1610 by niro, Thu Dec 2 23:02:19 2010 UTC alx-src/branches/alx-web-060/mageupgrade.php revision 2020 by niro, Mon May 9 21:06:14 2011 UTC
# Line 35  Line 35 
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($sshcmd.' '.$ip.' /sbin/mageupgrade --calc-bash',$out,$err);   exec($sshcmd.' '.$ip.' NOCOLORS=true /sbin/mage uppretend | egrep "\[.*\]" | sed "s:\[.*\]\ \(.*\):\1:" | sed "s:/:,:" | sed "s:\(.*\)-:\1,:" | sed "s:\(.*\)-:\1,:"',$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))
42   {   {
43   foreach( $out as $i)   foreach( $out as $i)
44   {   {
45     if(strstr($i,"Magellan")
46     {
47     continue;
48     }
49     if(strstr($i,"dependencies")
50     {
51     continue;
52     }
53   $item=explode(",",$i);   $item=explode(",",$i);
54   $pcat=$item[0];   $pcat=$item[0];
55   $pname=$item[1];   $pname=$item[1];
56   $opver=$item[2];   $pver=$item[2];
57   $npver=$item[3];   $pbuild=$item[3];
58    
59   echo '<tr><td>';   echo '<tr><td>';
60   echo '<font color=green>'.$pcat.'/'.$pname.'</font>';   echo '<font color=green>'.$pcat.'/'.$pname.'</font>';
61   echo '<td>';   echo '<td>';
62   echo '<font color=blue> [ '.$opver.' -> '.$npver.' ] </font>';   echo '<font color=blue> => [ '.$pver.'-'.$pbuild.' ] </font>';
63   echo '</td>';   echo '</td>';
64   echo '</td></tr>';   echo '</td></tr>';
65   }   }
# Line 65  Line 73 
73   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>');
74   echo '<br>';   echo '<br>';
75   echo '<pre><div align=left class=left>';   echo '<pre><div align=left class=left>';
  // hotfix copy a fixed mage.rc  
  system('scp /var/www/localhost/htdocs/alx/he/mage.rc root@'.$ip.':/etc/mage.rc');  
  // hotfix2 and a config.rc  
  system('scp /var/www/localhost/htdocs/alx/he/config.rc root@'.$ip.':/etc/alxconfig-ng/config.rc');  
76   editvar("VERBOSE","off","/etc/mage.rc");   editvar("VERBOSE","off","/etc/mage.rc");
77    
78   // update rsync server location   // update rsync server location
79   $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');   $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, 'client_locations.rsync');
  echo $rsync;  
80   editvar("MAGE_RSYNC",$rsync,"/etc/alxconfig-ng/config.rc");   editvar("MAGE_RSYNC",$rsync,"/etc/alxconfig-ng/config.rc");
81   editvar("RSYNC",$rsync,"/etc/mage.rc");   editvar("RSYNC",$rsync,"/etc/mage.rc");
82    
83     // update repository server location
84     $repository = sqlfirst('select client_locations.repository from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'repository');
85     editvar("MAGE_MIRRORS",$repository,"/etc/alxconfig-ng/config.rc");
86     editvar("MIRRORS",$repository,"/etc/mage.rc");
87    
88     // update samba update host
89     $updateserver = sqlfirst('select client_locations.updateserver from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'updateserver');
90     editvar("SMB_UPDATE_HOST",$updateserver,"/etc/alxconfig-ng/config.rc");
91    
92     // update samba update user
93     $smbusername = sqlfirst('select client_locations.username from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'username');
94     editvar("SMB_UPDATE_USER",$smbusername,"/etc/alxconfig-ng/config.rc");
95    
96     // update samba update password
97     $smbpassword = sqlfirst('select client_locations.password from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'password');
98     editvar("SMB_UPDATE_PASS",$smbpassword,"/etc/alxconfig-ng/config.rc");
99   system($sshcmd.' '.$ip.' "NOCOLORS=true /sbin/mage update"');   system($sshcmd.' '.$ip.' "NOCOLORS=true /sbin/mage update"');
100    
101   echo '</div></pre>';   echo '</div></pre>';
102   echo '<script language="JavaScript">alert(\'Database-update successfully completed on client #'.$client.' .\')</script>';   echo '<script language="JavaScript">alert(\'Database-update successfully completed on client #'.$client.' .\')</script>';
103   }   }
# Line 86  Line 106 
106   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>');
107   echo '<br>';   echo '<br>';
108   echo '<pre><div align=left class=left>';   echo '<pre><div align=left class=left>';
  #echo 'forcing verbose=off <br>';  
  // hotfix copy a fixed mage.rc  
  system('scp /var/www/localhost/htdocs/alx/he/mage.rc root@'.$ip.':/etc/mage.rc');  
  // hotfix2 and a config.rc  
  system('scp /var/www/localhost/htdocs/alx/he/config.rc root@'.$ip.':/etc/alxconfig-ng/config.rc');  
109   editvar("VERBOSE","off","/etc/mage.rc");   editvar("VERBOSE","off","/etc/mage.rc");
110    
111   // update rsync server location   // update rsync server location
# Line 120  Line 135 
135   exec($sshcmd.' '.$ip.' "[ -x /usr/sbin/update-alx ] && exit 0 || exit 1"',$outarr,$err);   exec($sshcmd.' '.$ip.' "[ -x /usr/sbin/update-alx ] && exit 0 || exit 1"',$outarr,$err);
136   if($err!=0)   if($err!=0)
137   {   {
138   echo '"/usr/sbin/update-alx" missing on client "'.$client.'". Updating mage-alx and alxconfig-ng-alx first ...<br>';   echo '"update-alx" missing on client "'.$client.'". Updating mage and alxconfig-ng first ...<br>';
139   system($sshcmd.' '.$ip.' "NOCOLORS=true /sbin/mage install mage-alx"');   system($sshcmd.' '.$ip.' "NOCOLORS=true mage install mage"');
140   system($sshcmd.' '.$ip.' "NOCOLORS=true /sbin/mage install alxconfig-ng-alx"');   system($sshcmd.' '.$ip.' "NOCOLORS=true mage install alxconfig-ng"');
141   }   }
  //system($sshcmd.' '.$ip.' "NOCOLORS=true /usr/sbin/update-alx"');  
142   exec($sshcmd.' '.$ip.' "NOCOLORS=true /usr/sbin/update-alx && exit 0 || exit 1"',$outarr,$err);   exec($sshcmd.' '.$ip.' "NOCOLORS=true /usr/sbin/update-alx && exit 0 || exit 1"',$outarr,$err);
143   echo '</div></pre>';   echo '</div></pre>';
144   if ($err!=0) echo '<script language="JavaScript">alert(\'Upgrade *failed* on client #'.$client.' .\')</script>';   if ($err!=0) echo '<script language="JavaScript">alert(\'Upgrade *failed* on client #'.$client.' .\')</script>';

Legend:
Removed from v.1610  
changed lines
  Added in v.2020