From: Vincent Date: Wed, 10 Jul 2019 06:24:22 +0000 (+0200) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=856045a3001f35391578de2ab6f0539775b74b02;p=tortuga-home.git . --- diff --git a/composer.json b/composer.json index 46af289..98bc97e 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "predis/predis": "^1.1", "zendframework/zend-db": "^2.10", "zendframework/zend-i18n": "^2.9", - "zendframework/zend-i18n-resources": "^2.6" + "zendframework/zend-i18n-resources": "^2.6", + "ext-ssh2": "*" } } diff --git a/scripts/lib/ssh.php b/scripts/lib/ssh.php index 6c6c9ce..7024339 100644 --- a/scripts/lib/ssh.php +++ b/scripts/lib/ssh.php @@ -13,7 +13,7 @@ function getSSHInstance($device = null, $sudo = false) $instance_key = $device . ($sudo ? '_sudo' : ''); - if (!isset($ssh[$instance_key])) { + if (!isset($ssh[$instance_key]) || !is_resource($ssh[$instance_key])) { if (!isset($devices[$device])) { $ssh[$instance_key] = false; } else { @@ -30,20 +30,20 @@ function getSSHInstance($device = null, $sudo = false) } } } - return $ssh[$device]; + return $ssh[$instance_key]; } function sshCommand($command, $device = null, $blocking = true, $sudo = false) { - return sshRunCommand($command, $device, $blocking, $sudo); -// $redis = connectRedis(); -// $queue = $redis->get('ssh_queue'); -// if (!is_array($queue)) { -// $queue = []; -// } -// $queue[] = ['command' => $command, 'device' => $device, 'blocking' => $blocking, 'sudo' => $sudo]; -// $redis->igbset('ssh_queue', $queue); -// $redis->publish('ssh_event', 'handle_queue'); + //return sshRunCommand($command, $device, $blocking, $sudo); + $redis = connectRedis(); + $queue = $redis->get('ssh_queue'); + if (!is_array($queue)) { + $queue = []; + } + $queue[] = ['command' => $command, 'device' => $device, 'blocking' => $blocking, 'sudo' => $sudo]; + $redis->igbset('ssh_queue', $queue); + $redis->publish('ssh_event', 'handle_queue'); } function sshRunCommand($command, $device = null, $blocking = true, $sudo = false)