mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-09-01 10:48:53 +00:00
Use App\Models\Tmux in Tmux class, adjust tmux-ui start and stop commands
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user