summaryrefslogtreecommitdiff
path: root/src/FileModule.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-04-20 12:44:20 +0200
committerDaniel Weipert <code@drogueronin.de>2021-04-20 12:44:20 +0200
commit11dc8c730dda2c5bd38cb386f96331c5ce3cac9c (patch)
treeb2c03112114af00e33ce8e1276194906064fcf93 /src/FileModule.php
parentd4d5ae3bb6566311b2d42cf888e463b62f6cf0dc (diff)
Adds a bunch of new Modules
Diffstat (limited to 'src/FileModule.php')
-rw-r--r--src/FileModule.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/FileModule.php b/src/FileModule.php
new file mode 100644
index 0000000..95ba771
--- /dev/null
+++ b/src/FileModule.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace PHPIAC\Modules;
+
+use PHPIAC\Connection;
+use PHPIAC\Module\Module;
+use PHPIAC\Module\State;
+use PHPIAC\Modules\Support\HasPermissions;
+
+class FileModule extends Module
+{
+ use HasPermissions;
+
+ protected string $path;
+
+ protected string $state = State::PRESENT;
+
+ /**
+ * @inheritDoc
+ */
+ public function checkState(): bool
+ {
+ return false;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getCommands(): array
+ {
+ if ($this->state === State::PRESENT) {
+ Connection::exec(
+ "sudo touch $this->path" . PHP_EOL .
+ $this->getPermissions($this->path)
+ );
+ }
+ else {
+ Connection::exec("sudo rm -rf $this->path");
+ }
+
+ return [];
+ }
+}