Example #1
0
function testHastCtlStatus()
{
    $disks = get_hast_disks_list();
    $errors = array();
    foreach ($disks as $i => $disk) {
        $replication = false;
        $dirty = false;
        $output = execCmd("/sbin/hastctl list " . $disk['name']);
        if ($disk['status'] != 'complete') {
            $errors[] = "Disque " . $disk['name'] . " : mauvais statut (" . $disk['status'] . ")";
        }
        $res = explode("\n", $output);
        foreach ($res as $row) {
            $pos = strpos(Trim($row), 'dirty');
            if ($pos === 0) {
                $dirty = true;
                $end = substr(Trim($row), $pos + 7);
                if (strlen($end) > 6) {
                    $errors[] = "Disque " . $disk['name'] . " : dirty ({$end})";
                }
            }
            $pos = strpos(Trim($row), 'replication');
            if ($pos === 0) {
                $replication = true;
                $end = substr(Trim($row), $pos + 13);
                if ($end != 'fullsync') {
                    $errors[] = "Disque " . $disk['name'] . " : replication ({$end})";
                }
            }
            if ($dirty and $replication) {
                break;
            }
        }
    }
    return $errors;
}
Example #2
0
// ================ MAIN =================
$logger = Logger::getLogger("chmod");
if (Tools::isConnectedUser()) {
    $session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
    if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
        // /tmp/codevtt/logs
        $pos = strrpos(Constants::$codevtt_logfile, '/');
        $tmp = substr(Constants::$codevtt_logfile, 0, $pos);
        $uxCommand = "mkdir -p {$tmp}";
        execCmd($uxCommand);
        $logger->info($uxCommand);
        echo "{$uxCommand}<br>";
        $uxCommand = "chmod -R a+r {$tmp}";
        execCmd($uxCommand);
        $logger->info($uxCommand);
        echo "{$uxCommand}<br>";
        // --- reports
        $codevReportsDir = Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports';
        $uxCommand = "mkdir -p {$codevReportsDir}";
        execCmd($uxCommand);
        $logger->info($uxCommand);
        echo "{$uxCommand}<br>";
        // ---- /tmp/codevtt
        $pos = strrpos($tmp, '/');
        $tmp = substr(Constants::$codevtt_logfile, 0, $pos);
        $uxCommand = "chmod a+r {$tmp}";
        execCmd($uxCommand);
        $logger->info($uxCommand);
        echo "{$uxCommand}<br>";
    }
}
function action_split($options)
{
    global $config;
    $gitDir = $config['git_dir'];
    $tmpFolder = $config['tmp_dir'];
    $projectFolder = $config['project_dir'];
    $moduleRelPath = $config['module_rel_path'];
    if (!isset($options['package'])) {
        writeError('package not provided in param --package');
        exit(1);
    }
    if (!isset($options['module-dir'])) {
        writeError('module-dir not provided in param --module-dir');
        exit(1);
    }
    $package = $options['package'];
    $moduleDir = $options['module-dir'];
    //prepare tmp
    execCmd("rm -Rf {$tmpFolder};mkdir {$tmpFolder};cd {$tmpFolder};git init --bare");
    execCmd("git subtree split --prefix={$moduleRelPath}/{$moduleDir} -b {$package}", $projectFolder);
    execCmd("git push {$tmpFolder}/ {$package}:master");
    execCmd("git remote add origin {$gitDir}/{$package}.git", $tmpFolder);
    execCmd("git push origin master", $tmpFolder);
    execCmd("git rm -r {$moduleRelPath}/{$moduleDir}", $projectFolder);
    execCmd('git commit -am "Remove split code from module."', $projectFolder);
    execCmd("git remote add origin/modules-{$package} {$gitDir}/{$package}.git", $projectFolder);
    execCmd("git subtree add --prefix={$moduleRelPath}/{$moduleDir} --squash origin/modules-{$package} master", $projectFolder);
    //git branch -D rest
    execCmd("git branch -D {$package}", $projectFolder);
    echo "\nUpdate file [configs.php] add new key under [subtrees]:\n    '{$package}'    => '{$moduleDir}',\n\nLater, you can also use this same script to push, tag these subtrees.\n";
}
Example #4
0
function cmdIsValid(&$a_trade, $s_cmd, $a_argument)
{
    if (count($a_argument) != 2) {
        $a_trade['error'] = tradeError::BADARGUMENT;
        return false;
    }
    if (!is_numeric($a_argument[1])) {
        $a_trade['error'] = tradeError::ARGNOTNUMERIC;
        return false;
    }
    $i_number = intval($a_argument[1]);
    if ($i_number < 0) {
        $a_trade['error'] = tradeError::BADARGUMENT;
        return false;
    }
    if ($s_cmd == BUY) {
        if ($i_number * intval(@$a_trade['data'][$a_trade['currentDay']]) > $a_trade['currentMoney']) {
            $a_trade['error'] = tradeError::CANTBUY;
            return false;
        }
        if ($a_trade['daysNb'] == $a_trade['currentDay']) {
            $a_trade['error'] = tradeError::CANTBUYLASTDAY;
            return false;
        }
    }
    if ($s_cmd == SELL) {
        if ($i_number > $a_trade['share']) {
            $a_trade['error'] = tradeError::CANTSELL;
            return false;
        }
    }
    execCmd($a_trade, $s_cmd, $i_number);
    return true;
}