Ejemplo n.º 1
0
function update_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    log_cleanup("*** Executing Update (upcp) - BEGIN ***");
    debug_for_backend();
    $login = new Client(null, null, 'upgrade');
    $DoUpdate = false;
    $opt = parse_opt($argv);
    log_cleanup("Kloxo Install/Update");
    if (lxfile_exists("/var/cache/kloxo/kloxo-install-firsttime.flg")) {
        log_cleanup("- Installing Kloxo packages at the first time");
        $DoUpdate = true;
    } else {
        log_cleanup("- Getting Version Info from the LxCenter download Server");
        $upversion = false;
        if (isset($opt['till-version']) && $opt['till-version'] || lxfile_exists("__path_slave_db")) {
            $sgbl->slave = true;
            $upversion = findNextVersion($opt['till-version']);
            $type = 'slave';
        } else {
            $sgbl->slave = false;
            $upversion = findNextVersion();
            $type = 'master';
        }
        if ($upversion) {
            log_cleanup("- Connecting LxCenter download server");
            do_upgrade($upversion);
            log_cleanup("- Upgrade Done. Cleanup....");
            flush();
        } else {
            $localversion = $sgbl->__ver_major_minor_release;
            log_cleanup("- Kloxo is the latest version ({$localversion})");
        }
        // Thirdparty/Webmail/AWstats checks
        $verWM = getVersionNumber(get_package_version("lxwebmail"));
        $verAW = getVersionNumber(get_package_version("lxawstats"));
        $ver = file_get_contents("http://download.lxcenter.org/download/thirdparty/kloxo-version.list");
        $verTP = getVersionNumber($ver);
        if (!lxfile_exists("/var/cache/kloxo/lxwebmail{$verWM}.tar.gz")) {
            $retWM = true;
        } else {
            $retWM = false;
        }
        if (!lxfile_exists("/var/cache/kloxo/lxawstats{$verAW}.tar.gz")) {
            $retAW = true;
        } else {
            $retAW = false;
        }
        if (!lxfile_exists("/var/cache/kloxo/kloxo-thirdparty.{$verTP}.zip")) {
            $retTP = true;
        } else {
            $retTP = false;
        }
        installThirdparty();
        installWebmail();
        installAwstats();
        // Run cleanups or not
        if ($retTP || $retWM || $retAW || $upversion) {
            $DoUpdate = true;
        } else {
            $DoUpdate = false;
        }
    }
    log_cleanup("*** Executing Update (upcp) - END ***");
    if ($DoUpdate == false) {
        log_cleanup("Run /script/cleanup if you want to fix/restore/(re)install non-working components.");
        exit;
    }
    if (is_running_secondary()) {
        log_cleanup("Not running Update cleanup, because this is running as secondary\n");
        exit;
    }
    //
    // Executing update/cleanup process
    //
    lxfile_cp("htmllib/filecore/php.ini", "/usr/local/lxlabs/ext/php/etc/php.ini");
    $res = pcntl_exec("/bin/sh", array("../bin/common/updatecleanup.sh", "--type={$type}"));
}
Ejemplo n.º 2
0
Archivo: lib.php Proyecto: zseand/kloxo
function installAwstats($ver = null)
{
    //	if (!is_numeric($ver)) { return; }
    $file = "lxawstats";
    log_cleanup("Awstats Checks");
    if (!$ver) {
        $ver = getVersionNumber(get_package_version($file));
        log_cleanup("- {$file} version is {$ver}");
    }
    lxfile_mkdir("/var/cache/kloxo");
    lxfile_mkdir("/home/kloxo/httpd/awstats/");
    $path = "/home/kloxo/httpd/awstats";
    if (lxfile_exists("/var/cache/kloxo/kloxo-install-firsttime.flg")) {
        $locverpath = "/var/cache/kloxo/{$file}-version";
        $locver = getVersionNumber(file_get_contents($locverpath));
        log_cleanup("- local copy version is {$locver}");
        if (lxfile_exists("/var/cache/kloxo/{$file}{$locver}.tar.gz")) {
            log_cleanup("- Use version {$locver} local copy for installing");
            $ver = $locver;
        } else {
            log_cleanup("- Download and use version {$ver} for installing");
            system("cd /var/cache/kloxo/ ; rm -f {$file}*.tar.gz; wget download.lxcenter.org/download/{$file}{$ver}.tar.gz");
        }
        $DoUpdate = true;
    } else {
        if (!lxfile_exists("/var/cache/kloxo/{$file}{$ver}.tar.gz")) {
            log_cleanup("- Download and use version {$ver} for updating");
            system("cd /var/cache/kloxo/ ; rm -f {$file}*.tar.gz; wget download.lxcenter.org/download/{$file}{$ver}.tar.gz");
            $DoUpdate = true;
        } else {
            log_cleanup("- No update found.");
            $DoUpdate = false;
        }
    }
    $ret = null;
    if ($DoUpdate) {
        lxfile_rm_rec("{$path}/tools/");
        lxfile_rm_rec("{$path}/wwwroot/");
        //	system("cd $path ; tar -xzf /var/cache/kloxo/$file*.tar.gz tools wwwroot docs");
        $ret = lxshell_unzip("__system__", $path, "/var/cache/kloxo/{$file}{$ver}.tar.gz");
    }
    if (!$ret) {
        return true;
    }
}