示例#1
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if ($this->confirm('Are you sure you wish to restore to factory defaults? [y/N] ', false)) {
         /**
          * Execute the migration tasks here, meaning that we only have to keep the migrations
          *  up to date and the rest should just work :)
          */
         $app_path = str_replace('/app/commands', '', dirname(__FILE__));
         // We now need to delete all configuration files from the Nginx configuration directory
         $cleanup = new NginxConfig();
         $existing_rules = Rule::all();
         foreach ($existing_rules as $rule) {
             //$cleanup->readConfig($filename)
             $cleanup->setHostheaders($rule->hostheader);
             $cleanup->deleteConfig(Setting::getSetting('nginxconfpath') . '/' . $cleanup->serverNameToFileName() . '.enabled.conf');
         }
         // We now re-build the database using the migrations...
         $execute = new Executer();
         $execute->setApplication('php')->addArgument($app_path . '/artisan')->addArgument('migrate:refresh')->addArgument('--seed')->execute();
         // and then restart the daemon as otherwise Nginx will continue to proxy traffic...
         $cleanup->reloadConfig();
         // We now generate a new API key..
         $genkey = new Executer();
         $genkey->setApplication('php')->addArgument($app_path . '/artisan')->addArgument('turbine:generatekey')->execute();
         /**
          *  Users can uncommet this code block if they want verbose factory resets!
          *
          * foreach ($execute->resultAsArray() as $outputline) {
          *    $this->info($outputline); - Users can uncommet this if they want verbose factory resets!
          * }
          *
          */
         Log::alert('Factory settings restored from the console');
         $this->info('Factory settings restored and a new API key has been generated!');
     } else {
         $this->error('User cancelled!');
     }
 }
示例#2
0
 /**
  * Attemps to reload the nginx service.
  */
 public function reloadConfig()
 {
     $server_reload = new Executer();
     $server_reload->setApplication('sudo /usr/bin/service nginx reload');
     $server_reload->execute();
 }
示例#3
0
文件: index.php 项目: Thomvh/turbine
<?php

/**
 * Executioner Process Execution Library
 *
 * Executioner (executer) is a PHP library for executing system processes
 * and applications with the ability to pass extra arguments and read
 *  CLI output results.
 *
 * @author bobbyallen.uk@gmail.com (Bobby Allen)
 * @version 1.0.0
 * @license http://opensource.org/licenses/MIT
 * @link https://github.com/bobsta63/executioner
 *
 */
require_once '../src/Ballen/Executioner/Executer.php';
use Ballen\Executioner\Executer;
$runner = new Executer();
$runner->setApplication('php')->addArgument('-v')->execute();
echo '<pre>' . $runner->resultAsText() . '</pre><br/><br/>';
var_dump($runner->resultAsArray());
#echo $runner->resultAsJSON();
print_r($runner->getErrors());