mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
init
This commit is contained in:
36
app/SSHCommands/Database/BackupDatabaseCommand.php
Normal file
36
app/SSHCommands/Database/BackupDatabaseCommand.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BackupDatabaseCommand extends Command
|
||||
{
|
||||
protected $provider;
|
||||
|
||||
protected $database;
|
||||
|
||||
protected $fileName;
|
||||
|
||||
public function __construct($provider, $database, $fileName)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->database = $database;
|
||||
$this->fileName = $fileName;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/database/'.$this->provider.'/backup.sh'));
|
||||
}
|
||||
|
||||
public function content(string $os): string
|
||||
{
|
||||
$command = $this->file($os);
|
||||
$command = Str::replace('__database__', $this->database, $command);
|
||||
|
||||
return Str::replace('__file__', $this->fileName, $command);
|
||||
}
|
||||
}
|
36
app/SSHCommands/Database/CreateCommand.php
Executable file
36
app/SSHCommands/Database/CreateCommand.php
Executable file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function __construct($provider, $name)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/database/'.$this->provider.'/create.sh'));
|
||||
}
|
||||
|
||||
public function content(string $os): string
|
||||
{
|
||||
return Str::replace('__name__', $this->name, $this->file($os));
|
||||
}
|
||||
}
|
51
app/SSHCommands/Database/CreateUserCommand.php
Executable file
51
app/SSHCommands/Database/CreateUserCommand.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateUserCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $host;
|
||||
|
||||
public function __construct($provider, $username, $password, $host)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/database/'.$this->provider.'/create-user.sh'));
|
||||
}
|
||||
|
||||
public function content(string $os): string
|
||||
{
|
||||
$command = Str::replace('__username__', $this->username, $this->file($os));
|
||||
$command = Str::replace('__password__', $this->password, $command);
|
||||
|
||||
return Str::replace('__host__', $this->host, $command);
|
||||
}
|
||||
}
|
36
app/SSHCommands/Database/DeleteCommand.php
Executable file
36
app/SSHCommands/Database/DeleteCommand.php
Executable file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DeleteCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function __construct($provider, $name)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/database/'.$this->provider.'/delete.sh'));
|
||||
}
|
||||
|
||||
public function content(string $os): string
|
||||
{
|
||||
return Str::replace('__name__', $this->name, $this->file($os));
|
||||
}
|
||||
}
|
44
app/SSHCommands/Database/DeleteUserCommand.php
Executable file
44
app/SSHCommands/Database/DeleteUserCommand.php
Executable file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DeleteUserCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $host;
|
||||
|
||||
public function __construct($provider, $username, $host)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->username = $username;
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/database/'.$this->provider.'/delete-user.sh'));
|
||||
}
|
||||
|
||||
public function content(string $os): string
|
||||
{
|
||||
$command = Str::replace('__username__', $this->username, $this->file($os));
|
||||
|
||||
return Str::replace('__host__', $this->host, $command);
|
||||
}
|
||||
}
|
48
app/SSHCommands/Database/LinkCommand.php
Executable file
48
app/SSHCommands/Database/LinkCommand.php
Executable file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class LinkCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
protected $host;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $database;
|
||||
|
||||
public function __construct($provider, $username, $host, $database)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->username = $username;
|
||||
$this->host = $host;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/database/'.$this->provider.'/link.sh'));
|
||||
}
|
||||
|
||||
public function content(string $os): string
|
||||
{
|
||||
$command = Str::replace('__username__', $this->username, $this->file($os));
|
||||
$command = Str::replace('__host__', $this->host, $command);
|
||||
|
||||
return Str::replace('__database__', $this->database, $command);
|
||||
}
|
||||
}
|
36
app/SSHCommands/Database/RestoreDatabaseCommand.php
Normal file
36
app/SSHCommands/Database/RestoreDatabaseCommand.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class RestoreDatabaseCommand extends Command
|
||||
{
|
||||
protected $provider;
|
||||
|
||||
protected $database;
|
||||
|
||||
protected $fileName;
|
||||
|
||||
public function __construct($provider, $database, $fileName)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->database = $database;
|
||||
$this->fileName = $fileName;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/database/'.$this->provider.'/restore.sh'));
|
||||
}
|
||||
|
||||
public function content(string $os): string
|
||||
{
|
||||
$command = $this->file($os);
|
||||
$command = Str::replace('__database__', $this->database, $command);
|
||||
|
||||
return Str::replace('__file__', $this->fileName, $command);
|
||||
}
|
||||
}
|
41
app/SSHCommands/Database/UnlinkCommand.php
Executable file
41
app/SSHCommands/Database/UnlinkCommand.php
Executable file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UnlinkCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
protected $host;
|
||||
|
||||
public function __construct($provider, $username, $host)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->username = $username;
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/database/'.$this->provider.'/unlink.sh'));
|
||||
}
|
||||
|
||||
public function content(string $os): string
|
||||
{
|
||||
$command = Str::replace('__username__', $this->username, $this->file($os));
|
||||
|
||||
return Str::replace('__host__', $this->host, $command);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user