'; ?> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...
'); if($alxos >= '0.6.0') { $out = @sshdo('NOCOLORS=true /sbin/mage uppretend | egrep "\[.*\]" | sed "s:\[.*\]\ \(.*\):\1:" | sed "s:/:,:" | sed "s:\(.*\)-:\1,:" | sed "s:\(.*\)-:\1,:"', $ip); } else { $out = @sshdo('NOCOLORS=true /sbin/mageupgrade --calc-bash | cut -d, -f1-2,4 | sed "s/\(.*\)-r\(.*\)/\1,r\2/"', $ip); } echo '
';
	echo '';
	if (array_key_exists("0", $out))
	{
		// tell that there are no updates if $out/$i is empty
		if ( $out[1] == "")
		{
			echo "No updates available. The system is fully upgraded.";
		} else {
			foreach( $out as $i)
			{
				// element 0 is always 0
				if ($i=="0") continue;

				$row=explode("\n", $i);
				foreach( $row as $x)
				{
					//ignore empty rows
					//(the last one may empty)
					if ($x=="") continue;

					$item=explode(",",trim($x));
					$pcat=$item[0];
					$pname=$item[1];
					$pver=$item[2];
					$pbuild=$item[3];

					echo '';
					echo '';
				}
			}
		}
	}
	else echo 'No updates for client '.$client.' available.';			
	echo '
'; echo ''.$pcat.'/'.$pname.''; echo ''; echo ' => [ '.$pver.'-'.$pbuild.' ] '; echo '
'; echo '
'; } elseif($op=="update") { echo ' '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...
'); echo '
'; echo '
'; @sshdo('NOCOLORS=true /sbin/mage update', $ip); echo '
'; echo ''; } elseif($op=="upgrade") { echo ' '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')...
'); echo '
'; echo '
'; # check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first $err = @sshdo('[ -x /usr/sbin/update-alx ]', $ip); if($err[0]!=0) { echo '"update-alx" missing on client "'.$client.'". Updating mage and alxconfig-ng first ...
'; @sshdo('NOCOLORS=true mage install mage', $ip); @sshdo('NOCOLORS=true mage install alxconfig-ng', $ip); } $err = @sshdo('NOCOLORS=true /usr/sbin/update-alx', $ip); if ($err[0]!=0) echo ''; else echo ''; echo '
'; } else echo 'unknown operation'; echo ''; ?>