summaryrefslogtreecommitdiff
path: root/src/Module/AptModule.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-04-18 21:46:12 +0200
committerDaniel Weipert <code@drogueronin.de>2021-04-18 21:46:12 +0200
commit82e4d1ca348748e8cdde86f65e62221968cabed5 (patch)
tree778e3be9a9b3fa8cfb6cda1a34230fdf402da997 /src/Module/AptModule.php
parentc0ebe78089121c0ad23efb0af32c435bee543a3c (diff)
Slight refactoring
Diffstat (limited to 'src/Module/AptModule.php')
-rw-r--r--src/Module/AptModule.php48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/Module/AptModule.php b/src/Module/AptModule.php
deleted file mode 100644
index ff4cb95..0000000
--- a/src/Module/AptModule.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-namespace PHPIAC\Module;
-
-use phpseclib3\Net\SSH2;
-
-class AptModule implements ModuleInterface
-{
- public function __construct(
- private string $package,
- private string $state = State::PRESENT
- ) {}
-
- public function checkState(): bool
- {
- global $ssh;
- /**@var SSH2 $ssh*/
- $ssh->enablePTY();
- $ssh->exec("which $this->package");
-
- if ($this->state === State::PRESENT) {
- $state = ! empty($ssh->read());
- }
- else if ($this->state === State::ABSENT) {
- $state = empty($ssh->read());
- }
-
- $ssh->disablePTY();
-
- return $state;
- }
-
- public function getCommands(): array
- {
- if ($this->state === State::PRESENT) {
- return [
- "sudo apt install -y $this->package",
- ];
- }
- else if ($this->state === State::ABSENT) {
- return [
- "sudo apt remove -y $this->package",
- ];
- }
-
- return [];
- }
-}