mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
refactoring
This commit is contained in:
27
app/SSHCommands/System/CreateUserCommand.php
Executable file
27
app/SSHCommands/System/CreateUserCommand.php
Executable file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class CreateUserCommand extends Command
|
||||
{
|
||||
public function __construct(protected string $user, protected string $password, protected string $key)
|
||||
{
|
||||
}
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/create-user.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__user__', $this->user)
|
||||
->replace('__key__', $this->key)
|
||||
->replace('__password__', $this->password)
|
||||
->toString();
|
||||
}
|
||||
}
|
25
app/SSHCommands/System/DeleteSshKeyCommand.php
Executable file
25
app/SSHCommands/System/DeleteSshKeyCommand.php
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class DeleteSshKeyCommand extends Command
|
||||
{
|
||||
public function __construct(protected string $key)
|
||||
{
|
||||
}
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/delete-ssh-key.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__key__', str($this->key)->replace('/', '\/'))
|
||||
->toString();
|
||||
}
|
||||
}
|
25
app/SSHCommands/System/DeploySshKeyCommand.php
Executable file
25
app/SSHCommands/System/DeploySshKeyCommand.php
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class DeploySshKeyCommand extends Command
|
||||
{
|
||||
public function __construct(protected string $key)
|
||||
{
|
||||
}
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/deploy-ssh-key.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__key__', addslashes($this->key))
|
||||
->toString();
|
||||
}
|
||||
}
|
26
app/SSHCommands/System/EditFileCommand.php
Normal file
26
app/SSHCommands/System/EditFileCommand.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class EditFileCommand extends Command
|
||||
{
|
||||
public function __construct(protected string $path, protected string $content)
|
||||
{
|
||||
}
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/edit-file.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__path__', $this->path)
|
||||
->replace('__content__', $this->content)
|
||||
->toString();
|
||||
}
|
||||
}
|
25
app/SSHCommands/System/GenerateSshKeyCommand.php
Executable file
25
app/SSHCommands/System/GenerateSshKeyCommand.php
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class GenerateSshKeyCommand extends Command
|
||||
{
|
||||
public function __construct(protected string $name)
|
||||
{
|
||||
}
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/generate-ssh-key.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__name__', $this->name)
|
||||
->toString();
|
||||
}
|
||||
}
|
19
app/SSHCommands/System/GetPublicKeyCommand.php
Executable file
19
app/SSHCommands/System/GetPublicKeyCommand.php
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class GetPublicKeyCommand extends Command
|
||||
{
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/get-public-key.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return $this->file();
|
||||
}
|
||||
}
|
25
app/SSHCommands/System/ReadSshKeyCommand.php
Executable file
25
app/SSHCommands/System/ReadSshKeyCommand.php
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class ReadSshKeyCommand extends Command
|
||||
{
|
||||
public function __construct(protected string $name)
|
||||
{
|
||||
}
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/read-ssh-key.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__name__', $this->name)
|
||||
->toString();
|
||||
}
|
||||
}
|
19
app/SSHCommands/System/RebootCommand.php
Normal file
19
app/SSHCommands/System/RebootCommand.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class RebootCommand extends Command
|
||||
{
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/reboot.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return $this->file();
|
||||
}
|
||||
}
|
26
app/SSHCommands/System/RunScript.php
Normal file
26
app/SSHCommands/System/RunScript.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class RunScript extends Command
|
||||
{
|
||||
public function __construct(protected string $path, protected string $script)
|
||||
{
|
||||
}
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/run-script.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__path__', $this->path)
|
||||
->replace('__script__', make_bash_script($this->script))
|
||||
->toString();
|
||||
}
|
||||
}
|
19
app/SSHCommands/System/UpgradeCommand.php
Executable file
19
app/SSHCommands/System/UpgradeCommand.php
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\System;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class UpgradeCommand extends Command
|
||||
{
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/system/upgrade.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return $this->file();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user