diff --git a/Changelog b/Changelog index 4264e3db9..41e4d8bda 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-07-28 DariusIII + * Chg: Use App\Models\Tmux in Tmux class, adjust tmux-ui start and stop commands * Chg: Remove unused, update current code in run.php and NZBContents class * Chg: Update tmux starting and stopping commands with option to kill tmux session (in stop command) * Chg: Add Tmux Model for future usage diff --git a/app/Console/Commands/TmuxUIStart.php b/app/Console/Commands/TmuxUIStart.php index 9d6269286..8bf5a86fe 100644 --- a/app/Console/Commands/TmuxUIStart.php +++ b/app/Console/Commands/TmuxUIStart.php @@ -42,6 +42,7 @@ class TmuxUIStart extends Command public function handle() { $process = new Process('php misc/update/nix/tmux/start.php'); + $process->setTty(true); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'ERR > '.$buffer; diff --git a/app/Console/Commands/TmuxUIStop.php b/app/Console/Commands/TmuxUIStop.php index c89dc716a..2c394b537 100644 --- a/app/Console/Commands/TmuxUIStop.php +++ b/app/Console/Commands/TmuxUIStop.php @@ -37,6 +37,7 @@ class TmuxUIStop extends Command * Execute the console command. * * @return mixed + * @throws \Symfony\Component\Process\Exception\InvalidArgumentException * @throws \Symfony\Component\Process\Exception\LogicException * @throws \Symfony\Component\Process\Exception\RuntimeException * @throws \RuntimeException @@ -45,6 +46,7 @@ class TmuxUIStop extends Command { if ($this->argument('type') === 'false' || $this->argument('type') === 'true') { $process = new Process('php misc/update/nix/tmux/stop.php'); + $process->setTimeout(600); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'ERR > ' . $buffer; diff --git a/misc/update/nix/tmux/start.php b/misc/update/nix/tmux/start.php index e72dafb03..639396e6b 100644 --- a/misc/update/nix/tmux/start.php +++ b/misc/update/nix/tmux/start.php @@ -17,15 +17,15 @@ $pdo = new DB(); // Ensure compatible tmux version is installed $tmux_version == "tmux 2.1\n" || $tmux_version == "tmux 2.2\n" if (`which tmux`) { $tmux_version = trim(str_replace('tmux ', '', shell_exec('tmux -V'))); - if (version_compare($tmux_version, '2.0', '>') && version_compare($tmux_version, '2.3', '<')) { - exit(ColorCLI::error('tmux versions 2.1 and 2.2 are not compatible with NNTmux. Aborting' . PHP_EOL)); + if (version_compare($tmux_version, '2.0', '>') && version_compare($tmux_version, '2.4', '<')) { + exit(ColorCLI::error('tmux versions above 2.0 are not compatible with NNTmux. Aborting' . PHP_EOL)); } } else { exit(ColorCLI::error('tmux binary not found. Aborting' . PHP_EOL)); } $tmux = new Tmux(); -$tmux_settings = $tmux->get(); +$tmux_settings = $tmux->get('tmux_session'); $tmux_session = $tmux_settings->tmux_session ?? 0; $path = __DIR__; diff --git a/nntmux/Tmux.php b/nntmux/Tmux.php index 8ab60083f..ef9366bb2 100755 --- a/nntmux/Tmux.php +++ b/nntmux/Tmux.php @@ -2,6 +2,7 @@ namespace nntmux; use App\Extensions\util\Versions; +use App\Models\Tmux as TmuxModel; use nntmux\db\DB; /** @@ -70,10 +71,11 @@ class Tmux */ public function get($setting = '') { - $pdo = $this->pdo; - $where = ($setting !== '' ? sprintf('WHERE setting = %s', $pdo->escapeString($setting)) : ''); - - $rows = $pdo->query(sprintf('SELECT * FROM tmux %s', $where)); + if ($setting === '') { + $rows = TmuxModel::all(); + } else { + $rows = TmuxModel::query()->where('setting', $setting)->get(); + } if ($rows === false) { return false;