Пример #1
0
function install_package($filename, $expected = null)
{
    $unix = new unix();
    $sock = new sockets();
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $rm = $unix->find_program("rm");
    $RebootAfterArticaUpgrade = $sock->GET_INFO("RebootAfterArticaUpgrade");
    if (!is_numeric($RebootAfterArticaUpgrade)) {
        $RebootAfterArticaUpgrade = 0;
    }
    events("Starting......: " . date("H:i:s") . " install_package() Extracting package {$filename}, please wait... ");
    echo "Starting......: " . date("H:i:s") . " install_package() Extracting package {$filename}, please wait... \n";
    $tarbin = $unix->find_program("tar");
    $killall = $unix->find_program("killall");
    echo "Starting......: " . date("H:i:s") . " tar: {$tarbin}\n";
    echo "Starting......: " . date("H:i:s") . " killall: {$killall}\n";
    @file_put_contents("/usr/share/artica-postfix/download_progress", 10);
    events("Starting......: " . date("H:i:s") . " install_package() Testing Package");
    echo "Starting......: " . date("H:i:s") . " Testing Package " . basename($filename) . "\n";
    if (!$unix->TARGZ_TEST_CONTAINER($filename)) {
        echo "Starting......: " . date("H:i:s") . " Testing Package " . basename($filename) . " failed\n";
        _artica_update_event(0, "Compressed package seems corrupted", null, __FILE__, __LINE__);
        events("Fatal, Compressed package seems corrupted");
        events($GLOBALS["TARGZ_TEST_CONTAINER_ERROR"]);
        @unlink($filename);
        @file_put_contents("/usr/share/artica-postfix/download_progress", 100);
        return false;
    }
    events("Starting......: " . date("H:i:s") . " Purge directories...");
    @file_put_contents("/usr/share/artica-postfix/download_progress", 40);
    system("{$rm} -f /usr/share/artica-postfix/ressources/logs/*");
    system("{$rm} -f /usr/share/artica-postfix/ressources/logs/web/*");
    if (is_dir("/usr/share/artica-postfix/ressources/conf/upload")) {
        system("{$rm} -f /usr/share/artica-postfix/ressources/conf/upload/*");
    }
    if (is_dir("/usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded")) {
        system("{$rm} -f /usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded/*");
    }
    events("Starting......: " . date("H:i:s") . " Extracting...");
    exec("{$tarbin} xf {$filename} -C /usr/share/ 2>&1", $results);
    if (is_file("{$killall}")) {
        shell_exec("{$killall} artica-install >/dev/null 2>&1");
    }
    @unlink($filename);
    shell_exec("{$nohup} {$php} " . dirname(__FILE__) . "/exec.checkfolder-permissions.php --force >/dev/null 2>&1 &");
    $MyCurrentVersion = GetCurrentVersionString();
    if ($expected != null) {
        if ($MyCurrentVersion != $expected) {
            _artica_update_event(1, "install_package(): Expected version:{$expected} does not match {$MyCurrentVersion}", $results, __FILE__, __LINE__);
            return;
        }
    }
    _artica_update_event(2, "install_package(): Success updating to a new version v{$MyCurrentVersion}", $results, __FILE__, __LINE__);
    if ($RebootAfterArticaUpgrade == 1) {
        @file_put_contents("/usr/share/artica-postfix/download_progress", 100);
        _artica_update_event(1, "install_package() Reboot the server in 10s...", null, __FILE__, __LINE__);
        events("Reboot the server in 10s...");
        system_admin_events("Warning: Reboot the server in 10s...", __FUNCTION__, __FILE__, __LINE__, "artica-update");
        $shutdown = $unix->find_program("shutdown");
        shell_exec("shutdown -r -t 10");
        return true;
    }
    _artica_update_event(2, "install_package(): restart dedicated services...", null, __FILE__, __LINE__);
    system_admin_events("Warning: Restart Artica dedicated services after an upgrade...", __FUNCTION__, __FILE__, __LINE__, "artica-update");
    RestartDedicatedServices();
    _artica_update_event(2, "install_package(): finish", null, __FILE__, __LINE__);
    return true;
}
Пример #2
0
    ini_set('error_reporting', E_ALL);
    ini_set('error_prepend_string', " Fatal..:");
    ini_set('error_append_string', "\n");
}
if (preg_match("#--reload#", implode(" ", $argv))) {
    $GLOBALS["RELOAD"] = true;
}
if (preg_match("#--bycron#", implode(" ", $argv))) {
    $GLOBALS["BYCRON"] = true;
}
if ($argv[1] == "--refresh") {
    RefreshIndex(true);
    exit;
}
if ($argv[1] == "--restart-services") {
    RestartDedicatedServices(true);
    exit;
}
if ($argv[1] == "--meta-release") {
    ArticaMeta_release($argv[2]);
    exit;
}
if ($argv[1] == "--hypercache") {
    hypercache();
    exit;
}
nightly();
hypercache();
function hypercachestoreid_version()
{
    if (isset($GLOBALS[__FUNCTION__])) {