Esempio n. 1
0
function findNextVersion($lastversion = null)
{
    global $gbl, $sgbl, $login, $ghtml;
    $maj = $sgbl->__ver_major;
    $thisversion = $sgbl->__ver_major_minor_release;
    $upgrade = null;
    $nlist = getVersionList($lastversion);
    dprintr($nlist);
    $k = 0;
    foreach ($nlist as $l) {
        if (version_cmp($thisversion, $l) === -1) {
            $upgrade = $l;
            break;
        }
        $k++;
    }
    if (!$upgrade) {
        return 0;
    }
    print "Updating from {$thisversion} to {$upgrade}\n";
    return $upgrade;
}
Esempio n. 2
0
function check_for_remote($rmt)
{
    global $gbl, $sgbl, $login, $ghtml;
    $local = false;
    $res = new Remote();
    $res->exception = null;
    if (!$rmt->authenticated) {
        $local = true;
        if (!($rmt->password === getAdminDbPass())) {
            log_message("Failed Local access to {$rmt->remote_login} from localhost");
            $res->exception = new lxException("login_failed", $rmt->machine);
            return $res;
        }
    }
    if (!$local) {
        log_message("Successful Access access to {$rmt->remote_login} from {$rmt->machine}");
    }
    $vercmp = version_cmp($rmt->version, $sgbl->__ver_major_minor_release);
    if ($local) {
        if ($vercmp > 0) {
            $res->exception = new lxException("backend_server_restarting", $rmt->machine);
            os_restart_program();
            return $res;
        }
    }
    //dprintr($rmt);
    /* Even if it is demo, versions must be updated, otherwise, results are unpredictable.
    	if (if_demo()) {
    		do_the_action($rmt, $res);
    
    		$res->state = 'success';
    		return $res;
    	}
    */
    if ($vercmp < 0) {
        $res->state = 'version_greater';
        print "Version Greater <br> \n";
        $res->exception = new lxException("slave_version_higher._please_update_master_to_the_latest_version", $rmt->machine);
        return $res;
    }
    if ($vercmp > 0) {
        update_from_master($rmt);
        //$res->state = 'upgrade';
        $res->exception = new lxException("slave_upgrading_please_try_after_a_few_minutes", 'machine', $rmt->machine);
        print "Version Lesser <br> \n";
        return $res;
    }
    do_the_action($rmt, $res);
    $res->state = 'success';
    return $res;
}
Esempio n. 3
0
/**
 * Get a version list and see if a update is avaible
 * Issue #781 - Update to the latest version instead one by one
 * Added _ () for the future :)
 *
 * @param      string $LastVersion Not Used?
 * @return     string    Returns zero or version number
 * @author     Danny Terweij d.terweij@lxcenter.org
 */
function findNextVersion($lastVersion = null)
{
    global $sgbl;
    $thisVersion = $sgbl->__ver_major_minor_release;
    $Upgrade = null;
    $versionList = getVersionList($lastVersion);
    print _('Found version(s):');
    foreach ($versionList as $newVersion) {
        print ' ' . $newVersion;
    }
    print PHP_EOL;
    if (version_cmp($thisVersion, $newVersion) === -1) {
        $Upgrade = $newVersion;
    }
    if (version_cmp($thisVersion, $newVersion) === 1) {
        unset($Upgrade);
        print _('Your version ') . $thisVersion . _(' is higher then ') . $newVersion . PHP_EOL;
        print _('Script aborted') . PHP_EOL;
        exit;
    }
    if (!$Upgrade) {
        return 0;
    }
    print _('Upgrading from ') . $thisVersion . _(' to ') . $Upgrade . PHP_EOL;
    return $Upgrade;
}