Ejemplo n.º 1
0
                $response = chr(10) . 'NEW SECTION ' . $section . ' GENERATED.' . chr(10) . chr(10);
                // On completion of procedure, check reports for process failure:
                foreach ($procedure_report as $process => $status) {
                    // If a process(s) failed, roll back procedure:
                    if ($status == false) {
                        $procedure_report = runProcess($procedure_report, $procedure, 1, $mysql);
                        $response = chr(10) . 'ERROR --- SOMETHING WENT WRONG, SECTION NOT GENERATED!' . chr(10) . chr(10);
                        break;
                    }
                }
            } else {
                $response = chr(10) . 'ERROR --- SECTION ALREADY GENERATED!' . chr(10) . chr(10);
            }
        }
        // On command DELETE:
        if ($command == 'delete') {
            // Check to see that section exists:
            if (isset($routes[$section])) {
                // If so, run remove section procedure:
                $procedure_report = runProcess($procedure_report, $procedure, 1, $mysql);
                $response = chr(10) . 'SECTION ' . $section . ' REMOVED.' . chr(10) . chr(10);
            } else {
                $response = chr(10) . 'ERROR --- SECTION DOES NOT EXIST!' . chr(10) . chr(10);
            }
        }
    }
    // Report activity and show procedure log:
    echo $response;
    echo chr(10) . 'Report...' . chr(10) . chr(10);
    print_r($procedure_report);
}
Ejemplo n.º 2
0
 * the lock file exists the server runs. If we delete the file the server gets
 * shutdown. In this way we can spawn a process in the ant file and kill the
 * process when deleting the lock file.
 */
$service = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null;
$iniFile = DIRECTORY_SEPARATOR === '\\' ? 'build-win.properties' : 'build-default.properties';
$config = parse_ini_file($iniFile);
// we are currently in the build dir we must change to the public dir to start
// a service
chdir(__DIR__ . '/../public');
switch ($service) {
    case 'webserver':
        runProcess('webserver', $config['php'] . ' -S 127.0.0.1:8008 server.php');
        break;
    case 'webdriver':
        runProcess('webdriver', $config['nodejs'] . ' node_modules/protractor/bin/webdriver-manager start');
        break;
    default:
        echo 'Unknown service' . "\n";
        exit(1);
        break;
}
function runProcess($name, $cmd)
{
    echo 'Start ' . $name . ' (' . $cmd . ')' . "\n";
    $process = proc_open($cmd, array(), $pipes);
    $status = proc_get_status($process);
    $pid = $status['pid'];
    $file = __DIR__ . '/../cache/' . $name . '.lock';
    file_put_contents($file, $pid);
    while (is_file($file)) {
Ejemplo n.º 3
0
    return $output;
}
/**
 * Composer setup.
 */
if (!file_exists('./composer.phar')) {
    out("Downloading composer.");
    $cmd = "php -r \"eval('?>'.file_get_contents('https://getcomposer.org/installer'));\"";
    $output = runProcess($cmd);
    out($output);
} else {
    out("Composer already installed.");
}
out("Installing dependencies.");
$cmd = 'php ./composer.phar update --prefer-dist';
$output = runProcess($cmd);
out($output);
/**
 * File permissions.
 */
out('Checking permissions for cache directory.');
$worldWritable = bindec('0000000111');
// Get current permissions in decimal format so we can bitmask it.
$currentPerms = octdec(substr(sprintf('%o', fileperms('./cache')), -4));
if (($currentPerms & $worldWritable) != $worldWritable) {
    out('Attempting to set permissions on cache/');
    $result = chmod('./cache', $currentPerms | $worldWritable);
    if ($result) {
        out('Permissions set on cache/');
    } else {
        out('Failed to set permissions on cache/ you must do it yourself.');
Ejemplo n.º 4
0
<?php

include __DIR__ . "/../vendor/autoload.php";
use Symfony\Component\Process\Process;
function runProcess($command)
{
    $address = 'localhost';
    $port = 5600;
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    socket_connect($socket, $address, $port);
    $process = new Process($command);
    $process->setTimeout(3600);
    $process->run(function ($type, $buffer) use($socket) {
        if ('err' === $type) {
            socket_write($socket, "ERROR\n", strlen("ERROR\n"));
            socket_write($socket, $buffer, strlen($buffer));
        } else {
            socket_write($socket, $buffer, strlen($buffer));
        }
    });
    if (!$process->isSuccessful()) {
        throw new \RuntimeException($process->getErrorOutput());
    }
    socket_close($socket);
}
$command = filter_input(INPUT_GET, 'command', FILTER_SANITIZE_STRING);
runProcess($command);
Ejemplo n.º 5
0
function configureSauce()
{
    global $BASE, $IS_WIN, $SAUCE_USERNAME, $SAUCE_ACCESS_KEY;
    out("- Configuring Sauce...", NULL, false);
    list($output, $exitcode) = runProcess("{$BASE}/vendor/bin/sauce_config {$SAUCE_USERNAME} {$SAUCE_ACCESS_KEY}");
    if ($exitcode !== 0) {
        out('failed', 'error');
        $FIX = TRUE;
        if (!$IS_WIN) {
            out("  Sauce configuration failed. Please run vendor/bin/sauce_config USERNAME ACCESS_KEY manually.", 'info');
        } else {
            out("  Sauce configuration failed. Usage: php givememysausage.php <sauceusername> <sauceaccesskey>", 'info');
        }
    } else {
        out('done', 'success');
    }
}
Ejemplo n.º 6
0
<?php

include __DIR__ . "/../vendor/autoload.php";
use Symfony\Component\Process\Process;
function runProcess($command)
{
    $address = 'localhost';
    $port = 5600;
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    socket_connect($socket, $address, $port);
    $process = new Process($command);
    $process->setTimeout(3600);
    $process->run(function ($type, $buffer) use($socket) {
        if ('err' === $type) {
            socket_write($socket, "ERROR\n", strlen("ERROR\n"));
            socket_write($socket, $buffer, strlen($buffer));
        } else {
            socket_write($socket, $buffer, strlen($buffer));
        }
    });
    if (!$process->isSuccessful()) {
        throw new \RuntimeException($process->getErrorOutput());
    }
    socket_close($socket);
}
runProcess('ls -latr /');
runProcess('ls -latr /home/gonzalo');