'; ?> /dev/null && exit 0 || exit 1',$retval); if($retval==0) { if($op=="calc") { echo ' '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...
'); exec($sshcmd.' -l root '.$ip.' /sbin/mageupgrade --calc-bash',$out,$err); echo '
';
				echo '';
				if (array_key_exists("0", $out))
				{
					foreach( $out as $i)
					{
						$item=explode(",",$i);
						$pcat=$item[0];
						$pname=$item[1];
						$opver=$item[2];
						$npver=$item[3];

						echo '';
						echo '';
					}
				}
				else echo 'No updates for client '.$client.' available.';			
				echo '
'; echo ''.$pcat.'/'.$pname.''; echo ''; echo ' [ '.$opver.' -> '.$npver.' ] '; echo '
'; echo '
'; } elseif($op=="update") { echo ' '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...
'); echo '
'; echo '
'; // hotfix copy a fixed mage.rc system('scp /var/www/localhost/htdocs/alx/he/mage.rc root@'.$ip.':/etc/mage.rc'); editvar("VERBOSE","off","/etc/mage.rc"); // update rsync server location $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'); echo $rsync; editvar("RSYNC",$rsync,"/etc/mage.rc"); system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage update"'); echo '
'; echo ''; } elseif($op=="upgrade") { echo ' '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')...
'); echo '
'; echo '
'; echo 'forcing verbose=off
'; editvar("VERBOSE","off","/etc/mage.rc"); // update repository server locations $repo = sqlfirst('SELECT repository FROM client_locations WHERE location="HAT"', 'repository'); editvar("MIRRORS",$repo,"/etc/mage.rc"); # check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first exec($sshcmd.' -l root '.$ip.' "[ -x /usr/sbin/update-alx ] && exit 0 || exit 1"',$outarr,$err); if($err!=0) { echo '"/usr/sbin/update-alx" missing on client "'.$client.'". Updating mage-alx and alxconfig-ng-alx first ...
'; system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage install mage-alx"'); system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /sbin/mage install alxconfig-ng-alx"'); } system($sshcmd.' -l root '.$ip.' "NOCOLORS=true /usr/sbin/update-alx"'); echo '
'; echo ''; } else echo 'unkown operation'; } else echo ' '.strtoupper('Client not online, try again later...
'); } echo ''; ?>