diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-04-20 12:44:20 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-04-20 12:44:20 +0200 |
commit | 11dc8c730dda2c5bd38cb386f96331c5ce3cac9c (patch) | |
tree | b2c03112114af00e33ce8e1276194906064fcf93 /src/CopyModule.php | |
parent | d4d5ae3bb6566311b2d42cf888e463b62f6cf0dc (diff) |
Adds a bunch of new Modules
Diffstat (limited to 'src/CopyModule.php')
-rw-r--r-- | src/CopyModule.php | 50 |
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 []; + } +} |