summaryrefslogtreecommitdiff
path: root/src/CopyModule.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/CopyModule.php')
-rw-r--r--src/CopyModule.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/CopyModule.php b/src/CopyModule.php
new file mode 100644
index 0000000..069f594
--- /dev/null
+++ b/src/CopyModule.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace PHPIAC\Modules;
+
+use PHPIAC\Connection;
+use PHPIAC\Module\Module;
+use PHPIAC\Modules\Support\HasPermissions;
+
+class CopyModule extends Module
+{
+ use HasPermissions;
+
+ protected string $src;
+ protected string $dest;
+
+ protected bool $remoteSrc = false;
+
+ /**
+ * @inheritDoc
+ */
+ public function __construct(array $config)
+ {
+ parent::__construct($config);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function checkState(): bool
+ {
+ return false;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getCommands(): array
+ {
+ if ($this->remoteSrc) {
+ Connection::exec("sudo cp -r $this->src $this->dest");
+ }
+ else {
+ Connection::put($this->dest, $this->src);
+ }
+
+ Connection::exec($this->getPermissions($this->dest));
+
+ return [];
+ }
+}