Use App\Models\Tmux in Tmux class, adjust tmux-ui start and stop commands

This commit is contained in:
DariusIII
2017-07-28 16:02:25 +02:00
parent f5882a85e6
commit e2e9e52bbb
5 changed files with 13 additions and 7 deletions
+1
View File
@@ -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
+1
View File
@@ -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;
+2
View File
@@ -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;
+3 -3
View File
@@ -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__;
+6 -4
View File
@@ -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;