Ejemplo n.º 1
0
function zarafa_server()
{
    if (!$GLOBALS["CLASS_USERS"]->ZARAFA_INSTALLED) {
        if ($GLOBALS["VERBOSE"]) {
            echo __FUNCTION__ . " not installed\n";
        }
        return null;
    }
    $enabled = 1;
    $pid_path = "/var/run/zarafa-server.pid";
    $master_pid = trim(@file_get_contents($pid_path));
    $l[] = "[APP_ZARAFA_SERVER]";
    $l[] = "service_name=APP_ZARAFA_SERVER";
    $l[] = "master_version=" . $GLOBALS["CLASS_UNIX"]->ZARAFA_VERSION();
    $l[] = "service_cmd=zarafa";
    $l[] = "service_disabled={$enabled}";
    $l[] = "pid_path={$pid_path}";
    $l[] = "remove_cmd=--zarafa-remove";
    $l[] = "watchdog_features=1";
    $l[] = "family=mailbox";
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        WATCHDOG("APP_ZARAFA", "zarafa");
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
    } else {
        $l[] = "running=1";
    }
    $meme = GetMemoriesOf($master_pid);
    $l[] = $meme;
    $l[] = "";
    $l[] = "[APP_ZARAFA]";
    $l[] = "service_name=APP_ZARAFA";
    $l[] = "master_version=" . $GLOBALS["CLASS_UNIX"]->ZARAFA_VERSION();
    $l[] = "family=mailbox";
    $l[] = "service_cmd=zarafa";
    $l[] = "service_disabled={$enabled}";
    $l[] = "pid_path={$pid_path}";
    $l[] = "remove_cmd=--zarafa-remove";
    $l[] = "watchdog_features=1";
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        WATCHDOG("APP_ZARAFA", "zarafa");
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
        return implode("\n", $l);
        return;
    }
    if (!$GLOBALS["DISABLE_WATCHDOG"]) {
        $nohup = $GLOBALS["CLASS_UNIX"]->find_program("nohup") . " ";
        if ($GLOBALS["PHP5"] == null) {
            $GLOBALS["PHP5"] = LOCATE_PHP5_BIN2();
        }
        $cmd = trim($nohup . "{$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.zarafa.build.stores.php --export-hash >/dev/null 2>&1 &");
        events("running {$cmd}", __FUNCTION__, __LINE__);
        shell_exec($cmd);
    }
    zarafa_mapi();
    $l[] = "running=1";
    $l[] = $meme;
    $l[] = "";
    return implode("\n", $l);
    return;
}
Ejemplo n.º 2
0
function zarafa_server()
{
    if (!$GLOBALS["CLASS_USERS"]->ZARAFA_INSTALLED) {
        if ($GLOBALS["VERBOSE"]) {
            echo __FUNCTION__ . " not installed\n";
        }
        return null;
    }
    if (is_file("/etc/artica-postfix/ZARFA_FIRST_INSTALL")) {
        shell_exec2("{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.zarafa.build.stores.php --remove-database >/dev/null 2>&1 &");
        @unlink("/etc/artica-postfix/ZARFA_FIRST_INSTALL");
    }
    $enabled = 1;
    $pid_path = "/var/run/zarafa-server.pid";
    $master_pid = trim(@file_get_contents($pid_path));
    $enabled = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("ZarafaEnableServer");
    if (!is_numeric($enabled)) {
        $enabled = 1;
    }
    $master_version = $GLOBALS["CLASS_UNIX"]->ZARAFA_VERSION();
    $l[] = "[APP_ZARAFA_SERVER]";
    $l[] = "service_name=APP_ZARAFA_SERVER";
    $l[] = "master_version={$master_version}";
    $l[] = "service_cmd=/etc/init.d/zarafa-server";
    $l[] = "service_disabled={$enabled}";
    $l[] = "pid_path={$pid_path}";
    $l[] = "remove_cmd=--zarafa-remove";
    $l[] = "watchdog_features=1";
    $l[] = "family=mailbox";
    if (is_dir("/usr/share/zarafa-webaccess")) {
        if (!is_file("/usr/share/zarafa-webaccess/VERSION")) {
            @file_put_contents("/usr/share/zarafa-webaccess/VERSION", $master_version);
        }
    }
    if ($enabled == 0) {
        return implode("\n", $l);
        return;
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        WATCHDOG("APP_ZARAFA", "zarafa");
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
    } else {
        $l[] = "running=1";
    }
    $meme = GetMemoriesOf($master_pid);
    $l[] = $meme;
    $l[] = "";
    $l[] = "[APP_ZARAFA]";
    $l[] = "service_name=APP_ZARAFA";
    $l[] = "master_version=" . $GLOBALS["CLASS_UNIX"]->ZARAFA_VERSION();
    $l[] = "family=mailbox";
    $l[] = "service_cmd=/etc/init.d/zarafa-server";
    $l[] = "service_disabled={$enabled}";
    $l[] = "pid_path={$pid_path}";
    $l[] = "remove_cmd=--zarafa-remove";
    $l[] = "watchdog_features=1";
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        shell_exec("/etc/init.d/zarafa-server start");
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
        return implode("\n", $l);
        return;
    }
    if (!$GLOBALS["DISABLE_WATCHDOG"]) {
        $nohup = $GLOBALS["CLASS_UNIX"]->find_program("nohup") . " ";
        if ($GLOBALS["PHP5"] == null) {
            $GLOBALS["PHP5"] = LOCATE_PHP5_BIN2();
        }
        $cmd = trim($nohup . "{$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.zarafa.build.stores.php --export-hash >/dev/null 2>&1 &");
        events("running {$cmd}", __FUNCTION__, __LINE__);
        shell_exec2($cmd);
    }
    zarafa_mapi();
    $l[] = "running=1";
    $l[] = $meme;
    $l[] = "";
    $filetime = "/etc/artica-postfix/pids/exec.zarafa.build.stores.php.exoprhs.time";
    $time_file = $GLOBALS["CLASS_UNIX"]->file_time_min($filetime);
    if ($time_file > 60) {
        @unlink($filetime);
        @file_put_contents($filetime, time());
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.zarafa.build.stores.php --exoprhs >/dev/null 2>&1 &");
    }
    $filetime = "/etc/artica-postfix/pids/exec.zarafa-backup.php.Clean_dirs.time";
    $time_file = $GLOBALS["CLASS_UNIX"]->file_time_min($filetime);
    if ($time_file > 1440) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.zarafa-backup.php --clean-dirs >/dev/null 2>&1 &");
    }
    return implode("\n", $l);
}