From c0ebe78089121c0ad23efb0af32c435bee543a3c Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 18 Apr 2021 15:09:51 +0200 Subject: Initial commit --- src/Command/RunCommand.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Command/RunCommand.php (limited to 'src/Command') diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php new file mode 100644 index 0000000..048e94c --- /dev/null +++ b/src/Command/RunCommand.php @@ -0,0 +1,46 @@ +login($config['user'], PublicKeyLoader::load(file_get_contents($config['private_key_file'])))) { + throw new \Exception('Login failed'); + } + + $commands = []; + foreach ($config['tasks'] as $task) { + /**@var Task $task*/ + if (! $task->module->checkState()) { + $output->writeln('Adding commands from ' . get_class($task->module)); + array_push($commands, ...$task->module->getCommands()); + } + else { + $output->writeln('Skipping commands from ' . get_class($task->module)); + } + } + + $ssh->exec(implode(PHP_EOL, $commands)); + + return Command::SUCCESS; + } +} -- cgit v1.2.3