include('include/dbconn.php'); include('include/basesql.php'); include('include/common-functions.php'); echo '
';
?>
function update_client_settings()
{
global $client;
// set verbose off
ssh_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');
ssh_editvar('MAGE_RSYNC', $rsync, '/etc/alxconfig-ng/config.rc');
ssh_editvar('RSYNC', $rsync, '/etc/mage.rc');
// update repository server location
$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');
ssh_editvar('MAGE_MIRRORS', $repository, '/etc/alxconfig-ng/config.rc');
ssh_editvar('MIRRORS', $repository, '/etc/mage.rc');
// update samba update host
$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');
ssh_editvar('SMB_UPDATE_HOST', $updateserver, '/etc/alxconfig-ng/config.rc');
// update samba update user
$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');
ssh_editvar('SMB_UPDATE_USER', $smbusername, '/etc/alxconfig-ng/config.rc');
// update samba update password
$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');
ssh_editvar('SMB_UPDATE_PASS', $smbpassword, '/etc/alxconfig-ng/config.rc');
}
// get alx version info
$alxinfo = sqlfirst('SELECT * FROM client_version WHERE serial='.$client);
$alxos = $alxinfo[os];
$alxutils = $alxinfo[utils];
// always update the client settings first
update_client_settings();
if($op=="calc")
{
echo ' '.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', $ip); } echo ' '; echo '
'); echo ' '; echo ' '; echo ''; } elseif($op=="upgrade") { echo ' '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')... '); echo ' '; echo ' '; } else echo 'unkown operation'; echo ' |