This commit is contained in:
Saeed Vaziry
2023-07-02 12:47:50 +02:00
commit 5c72f12490
825 changed files with 41659 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class ChangeDefaultPHPCommand extends Command
{
/**
* @var string
*/
protected $version;
/**
* InstallPHPCommand constructor.
*/
public function __construct($version)
{
$this->version = $version;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/change-default-php.sh'));
}
public function content(string $os): string
{
return Str::replace('__version__', $this->version, $this->file($os));
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class ChangeNginxPHPVersionCommand extends Command
{
/**
* @var string
*/
protected $domain;
/**
* @var string
*/
protected $oldVersion;
/**
* @var string
*/
protected $newVersion;
/**
* CreateVHostCommand constructor.
*/
public function __construct(string $domain, string $oldVersion, string $newVersion)
{
$this->domain = $domain;
$this->oldVersion = $oldVersion;
$this->newVersion = $newVersion;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/webserver/nginx/change-php-version.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__domain__', $this->domain, $this->file($os));
$command = Str::replace('__old_version__', $this->oldVersion, $command);
return Str::replace('__new_version__', $this->newVersion, $command);
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class CloneRepositoryCommand extends Command
{
/**
* @var string
*/
protected $repository;
/**
* @var string
*/
protected $path;
protected $branch;
/**
* CloneRepositoryCommand constructor.
*/
public function __construct($repository, $path, $branch)
{
$this->repository = $repository;
$this->path = $path;
$this->branch = $branch;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/clone-repository.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__repo__', $this->repository, $this->file($os));
$command = Str::replace('__host__', get_hostname_from_repo($this->repository), $command);
$command = Str::replace('__branch__', $this->branch, $command);
return Str::replace('__path__', $this->path, $command);
}
}

10
app/SSHCommands/Command.php Executable file
View File

@ -0,0 +1,10 @@
<?php
namespace App\SSHCommands;
use App\Contracts\SSHCommand;
abstract class Command implements SSHCommand
{
//
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class ComposerInstallCommand extends Command
{
protected $path;
/**
* ComposerInstallCommand constructor.
*/
public function __construct($path)
{
$this->path = $path;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/composer-install.sh'));
}
public function content(string $os): string
{
return Str::replace('__path__', $this->path, $this->file($os));
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class CreateCustomSSLCommand extends Command
{
protected $path;
protected $certificate;
protected $pk;
protected $certificatePath;
protected $pkPath;
public function __construct($path, $certificate, $pk, $certificatePath, $pkPath)
{
$this->path = $path;
$this->certificate = $certificate;
$this->pk = $pk;
$this->certificatePath = $certificatePath;
$this->pkPath = $pkPath;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/create-custom-ssl.sh'));
}
public function content(string $os): string
{
$content = $this->file($os);
$content = str_replace('__path__', $this->path, $content);
$content = str_replace('__certificate__', $this->certificate, $content);
$content = str_replace('__pk__', $this->pk, $content);
$content = str_replace('__certificate_path__', $this->certificatePath, $content);
return str_replace('__pk_path__', $this->pkPath, $content);
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class CreateLetsencryptSSLCommand extends Command
{
protected $email;
protected $domain;
protected $webDirectory;
public function __construct($email, $domain, $webDirectory)
{
$this->email = $email;
$this->domain = $domain;
$this->webDirectory = $webDirectory;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/create-letsencrypt-ssl.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__email__', $this->email, $this->file($os));
$command = Str::replace('__web_directory__', $this->webDirectory, $command);
return Str::replace('__domain__', $this->domain, $command);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class CreateNginxPHPMyAdminVHostCommand extends Command
{
/**
* @var string
*/
protected $vhost;
public function __construct(string $vhost)
{
$this->vhost = $vhost;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/webserver/nginx/create-phpmyadmin-vhost.sh'));
}
public function content(string $os): string
{
return Str::replace('__vhost__', $this->vhost, $this->file($os));
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class CreateNginxVHostCommand extends Command
{
/**
* @var string
*/
protected $domain;
/**
* @var string
*/
protected $path;
/**
* @var string
*/
protected $vhost;
/**
* CreateVHostCommand constructor.
*/
public function __construct(
string $domain,
string $path,
string $vhost
) {
$this->domain = $domain;
$this->path = $path;
$this->vhost = $vhost;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/webserver/nginx/create-vhost.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__path__', $this->path, $this->file($os));
$command = Str::replace('__domain__', $this->domain, $command);
return Str::replace('__vhost__', $this->vhost, $command);
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class CreateUserCommand extends Command
{
protected $user;
protected $password;
protected $key;
/**
* CreateUserCommand constructor.
*/
public function __construct($user, $password, $key)
{
$this->user = $user;
$this->password = $password;
$this->key = $key;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/create-user.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
$command = Str::replace('__user__', $this->user, $command);
$command = Str::replace('__key__', $this->key, $command);
return Str::replace('__password__', $this->password, $command);
}
}

View 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);
}
}

View 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));
}
}

View 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);
}
}

View 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));
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class DeleteNginxPHPMyAdminVHost extends Command
{
/**
* @var string
*/
protected $path;
public function __construct(
string $path,
) {
$this->path = $path;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/webserver/nginx/delete-phpmyadmin-vhost.sh'));
}
public function content(string $os): string
{
return Str::replace('__path__', $this->path, $this->file($os));
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class DeleteNginxSiteCommand extends Command
{
/**
* @var string
*/
protected $domain;
/**
* @var string
*/
protected $path;
/**
* CloneRepositoryCommand constructor.
*/
public function __construct($domain, $path)
{
$this->domain = $domain;
$this->path = $path;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/webserver/nginx/delete-site.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__domain__', $this->domain, $this->file($os));
return Str::replace('__path__', $this->path, $command);
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class DeleteSshKeyCommand extends Command
{
/**
* @var string
*/
protected $key;
/**
* InstallPHPCommand constructor.
*/
public function __construct($key)
{
$this->key = $key;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/delete-ssh-key.sh'));
}
public function content(string $os): string
{
return Str::replace('__key__', Str::replace('/', '\/', $this->key), $this->file($os));
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class DeploySshKeyCommand extends Command
{
/**
* @var string
*/
protected $key;
/**
* InstallPHPCommand constructor.
*/
public function __construct($key)
{
$this->key = $key;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/deploy-ssh-key.sh'));
}
public function content(string $os): string
{
return Str::replace('__key__', addslashes($this->key), $this->file($os));
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class DownloadPHPMyAdminCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/common/download-phpmyadmin.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class EditFileCommand extends Command
{
protected $path;
protected $content;
public function __construct($path, $content)
{
$this->path = $path;
$this->content = $content;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/edit-file.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__path__', $this->path, $this->file($os));
return Str::replace('__content__', addslashes($this->content), $command);
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\SSHCommands\Firewall;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
class AddRuleCommand extends Command
{
use CommandContent;
/**
* @var string
*/
protected $provider;
/**
* @var string
*/
protected $type;
/**
* @var string
*/
protected $protocol;
/**
* @var string
*/
protected $port;
/**
* @var string
*/
protected $source;
/**
* @var string
*/
protected $mask;
public function __construct($provider, $type, $protocol, $port, $source, $mask)
{
$this->provider = $provider;
$this->type = $type;
$this->protocol = $protocol;
$this->port = $port;
$this->source = $source;
$this->mask = $mask;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/firewall/'.$this->provider.'/add-rule.sh'));
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands\Firewall;
use Illuminate\Support\Str;
trait CommandContent
{
public function content(string $os): string
{
$command = Str::replace('__type__', $this->type, $this->file($os));
$command = Str::replace('__protocol__', $this->protocol, $command);
$command = Str::replace('__source__', $this->source, $command);
$command = Str::replace('__mask__', $this->mask, $command);
return Str::replace('__port__', $this->port, $command);
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\SSHCommands\Firewall;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
class RemoveRuleCommand extends Command
{
use CommandContent;
/**
* @var string
*/
protected $provider;
/**
* @var string
*/
protected $type;
/**
* @var string
*/
protected $protocol;
/**
* @var string
*/
protected $port;
/**
* @var string
*/
protected $source;
/**
* @var string
*/
protected $mask;
public function __construct($provider, $type, $protocol, $port, $source, $mask)
{
$this->provider = $provider;
$this->type = $type;
$this->protocol = $protocol;
$this->port = $port;
$this->source = $source;
$this->mask = $mask;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/firewall/'.$this->provider.'/remove-rule.sh'));
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class GetPHPIniCommand extends Command
{
/**
* @var string
*/
protected $version;
public function __construct($version)
{
$this->version = $version;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/get-php-ini.sh'));
}
public function content(string $os): string
{
return Str::replace('__version__', $this->version, $this->file($os));
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class GetPublicKeyCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/common/get-public-key.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallCertbotCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-certbot.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallComposerCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/common/install-composer.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallDependenciesCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-dependencies.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallMariadbCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-mariadb.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallMysqlCommand extends Command
{
protected $version;
public function __construct($version)
{
$this->version = $version;
}
public function file(string $os): string
{
if ($this->version == '8.0') {
return File::get(base_path('system/commands/ubuntu/install-mysql-8.sh'));
}
return File::get(base_path('system/commands/ubuntu/install-mysql.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class InstallNginxCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-nginx.sh'));
}
public function content(string $os): string
{
return Str::replace('__config__', $this->config(), $this->file($os));
}
/**
* @return string
*/
protected function config()
{
$config = File::get(base_path('system/command-templates/nginx/nginx.conf'));
return Str::replace('__user__', config('core.ssh_user'), $config);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallNodejsCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-nodejs.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class InstallPHPCommand extends Command
{
/**
* @var string
*/
protected $version;
/**
* InstallPHPCommand constructor.
*/
public function __construct($version)
{
$this->version = $version;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-php.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__version__', $this->version, $this->file($os));
return Str::replace('__user__', config('core.ssh_user'), $command);
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class InstallPHPExtensionCommand extends Command
{
/**
* @var string
*/
protected $version;
protected $name;
/**
* InstallPHPCommand constructor.
*/
public function __construct($version, $name)
{
$this->version = $version;
$this->name = $name;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-php-extension.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__version__', $this->version, $this->file($os));
return Str::replace('__name__', $this->name, $command);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallRedisCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-redis.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallRequirementsCommand extends Command
{
protected $email;
protected $name;
public function __construct($email, $name)
{
$this->email = $email;
$this->name = $name;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-requirements.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallSupervisorCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-supervisor.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallUfwCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/install-ufw.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class InstallWordpressCommand extends Command
{
protected $path;
protected $domain;
protected $dbName;
protected $dbUser;
protected $dbPass;
protected $dbHost;
protected $dbPrefix;
protected $username;
protected $password;
protected $email;
protected $title;
/**
* ComposerInstallCommand constructor.
*/
public function __construct($path, $domain, $dbName, $dbUser, $dbPass, $dbHost, $dbPrefix, $username, $password, $email, $title)
{
$this->path = $path;
$this->domain = $domain;
$this->dbName = $dbName;
$this->dbUser = $dbUser;
$this->dbPass = $dbPass;
$this->dbHost = $dbHost;
$this->dbPrefix = $dbPrefix;
$this->username = $username;
$this->password = $password;
$this->email = $email;
$this->title = $title;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/wordpress/install.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
$command = str_replace('__path__', $this->path, $command);
$command = str_replace('__domain__', $this->domain, $command);
$command = str_replace('__db_name__', $this->dbName, $command);
$command = str_replace('__db_user__', $this->dbUser, $command);
$command = str_replace('__db_pass__', $this->dbPass, $command);
$command = str_replace('__db_host__', $this->dbHost, $command);
$command = str_replace('__db_prefix__', $this->dbPrefix, $command);
$command = str_replace('__username__', $this->username, $command);
$command = str_replace('__password__', $this->password, $command);
$command = str_replace('__title__', $this->title, $command);
return str_replace('__email__', $this->email, $command);
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class ManageServiceCommand extends Command
{
/**
* @var string
*/
protected $unit;
/**
* @var string
*/
protected $action;
/**
* ServiceStatusCommand constructor.
*/
public function __construct($unit, $action)
{
$this->unit = $unit;
$this->action = $action;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/manage-service.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__service__', $this->unit, $this->file($os));
return Str::replace('__action__', $this->action, $command);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\SSHCommands\ProcessManager\Supervisor;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class CreateWorkerCommand extends Command
{
protected $id;
protected $config;
public function __construct($id, $config)
{
$this->id = $id;
$this->config = $config;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/process-manager/supervisor/create-worker.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
$command = Str::replace('__id__', $this->id, $command);
return Str::replace('__config__', $this->config, $command);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands\ProcessManager\Supervisor;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class DeleteWorkerCommand extends Command
{
protected $id;
public function __construct($id)
{
$this->id = $id;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/process-manager/supervisor/delete-worker.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
return Str::replace('__id__', $this->id, $command);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands\ProcessManager\Supervisor;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class RestartWorkerCommand extends Command
{
protected $id;
public function __construct($id)
{
$this->id = $id;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/process-manager/supervisor/restart-worker.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
return Str::replace('__id__', $this->id, $command);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands\ProcessManager\Supervisor;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class StartWorkerCommand extends Command
{
protected $id;
public function __construct($id)
{
$this->id = $id;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/process-manager/supervisor/start-worker.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
return Str::replace('__id__', $this->id, $command);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\SSHCommands\ProcessManager\Supervisor;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class StopWorkerCommand extends Command
{
protected $id;
public function __construct($id)
{
$this->id = $id;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/process-manager/supervisor/stop-worker.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
return Str::replace('__id__', $this->id, $command);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class RebootCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/reboot.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\SSHCommands;
class RemoveSSLCommand extends Command
{
protected $path;
public function __construct($path)
{
$this->path = $path;
}
public function file(string $os): string
{
return '';
}
public function content(string $os): string
{
return 'sudo rm -rf '.$this->path.'*'."\n";
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class RestartServiceCommand extends Command
{
/**
* @var string
*/
protected $unit;
/**
* ServiceStatusCommand constructor.
*/
public function __construct($unit)
{
$this->unit = $unit;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/restart-service.sh'));
}
public function content(string $os): string
{
return Str::replace('__service__', $this->unit, $this->file($os));
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class RunScript extends Command
{
protected $path;
protected $script;
public function __construct($path, $script)
{
$this->path = $path;
$this->script = $script;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/run-script.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__path__', $this->path, $this->file($os));
return Str::replace('__script__', make_bash_script($this->script), $command);
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class ServiceStatusCommand extends Command
{
/**
* @var string
*/
protected $unit;
/**
* ServiceStatusCommand constructor.
*/
public function __construct($unit)
{
$this->unit = $unit;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/service-status.sh'));
}
public function content(string $os): string
{
return Str::replace('__service__', $this->unit, $this->file($os));
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class StartServiceCommand extends Command
{
/**
* @var string
*/
protected $unit;
/**
* ServiceStatusCommand constructor.
*/
public function __construct($unit)
{
$this->unit = $unit;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/start-service.sh'));
}
public function content(string $os): string
{
return Str::replace('__service__', $this->unit, $this->file($os));
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class StopServiceCommand extends Command
{
/**
* @var string
*/
protected $unit;
/**
* ServiceStatusCommand constructor.
*/
public function __construct($unit)
{
$this->unit = $unit;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/stop-service.sh'));
}
public function content(string $os): string
{
return Str::replace('__service__', $this->unit, $this->file($os));
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\SSHCommands\Storage;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class DownloadFromDropboxCommand extends Command
{
protected $src;
protected $dest;
protected $token;
public function __construct($src, $dest, $token)
{
$this->src = $src;
$this->dest = $dest;
$this->token = $token;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/storage/download-from-dropbox.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
$command = Str::replace('__src__', $this->src, $command);
$command = Str::replace('__dest__', $this->dest, $command);
return Str::replace('__token__', $this->token, $command);
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\SSHCommands\Storage;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class UploadToDropboxCommand extends Command
{
protected $src;
protected $dest;
protected $token;
public function __construct($src, $dest, $token)
{
$this->src = $src;
$this->dest = $dest;
$this->token = $token;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/storage/upload-to-dropbox.sh'));
}
public function content(string $os): string
{
$command = $this->file($os);
$command = Str::replace('__src__', $this->src, $command);
$command = Str::replace('__dest__', $this->dest, $command);
return Str::replace('__token__', $this->token, $command);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class UninstallPHPCommand extends Command
{
/**
* @var string
*/
protected $version;
/**
* InstallPHPCommand constructor.
*/
public function __construct($version)
{
$this->version = $version;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/uninstall-php.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__version__', $this->version, $this->file($os));
return Str::replace('__user__', config('core.ssh_user'), $command);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class UpdateBranchCommand extends Command
{
protected $path;
protected $branch;
public function __construct($path, $branch)
{
$this->path = $path;
$this->branch = $branch;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/update-branch.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__path__', $this->path, $this->file($os));
return Str::replace('__branch__', $this->branch, $command);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class UpdateCronJobsCommand extends Command
{
protected $user;
protected $data;
/**
* UpdateCronJobsCommand constructor.
*/
public function __construct($user, $data)
{
$this->user = $user;
$this->data = $data;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/common/update-cron-jobs.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__user__', $this->user, $this->file($os));
return Str::replace('__data__', $this->data, $command);
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class UpdateNginxRedirectsCommand extends Command
{
/**
* @var string
*/
protected $domain;
/**
* @var string
*/
protected $redirects;
/**
* CreateVHostCommand constructor.
*/
public function __construct(
string $domain,
string $redirects
) {
$this->domain = $domain;
$this->redirects = $redirects;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/webserver/nginx/update-redirects.sh'));
}
public function content(string $os): string
{
info($this->redirects);
$command = Str::replace('__redirects__', addslashes($this->redirects), $this->file($os));
return Str::replace('__domain__', $this->domain, $command);
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class UpdateNginxVHostCommand extends Command
{
/**
* @var string
*/
protected $domain;
/**
* @var string
*/
protected $path;
/**
* @var string
*/
protected $vhost;
/**
* CreateVHostCommand constructor.
*/
public function __construct(
string $domain,
string $path,
string $vhost
) {
$this->domain = $domain;
$this->path = $path;
$this->vhost = $vhost;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/webserver/nginx/update-vhost.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__path__', $this->path, $this->file($os));
$command = Str::replace('__domain__', $this->domain, $command);
return Str::replace('__vhost__', $this->vhost, $command);
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class UpdatePHPSettingsCommand extends Command
{
/**
* @var string
*/
protected $version;
protected $variable;
protected $value;
/**
* InstallPHPCommand constructor.
*/
public function __construct($version, $variable, $value)
{
$this->version = $version;
$this->variable = $variable;
$this->value = $value;
}
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/update-php-settings.sh'));
}
public function content(string $os): string
{
$command = Str::replace('__version__', $this->version, $this->file($os));
$command = Str::replace('__variable__', $this->variable, $command);
return Str::replace('__value__', $this->value, $command);
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\SSHCommands;
class UpdateWordpressCommand extends Command
{
protected $path;
protected $url;
protected $username;
protected $password;
protected $email;
protected $title;
/**
* ComposerInstallCommand constructor.
*/
public function __construct($path, $url, $username, $password, $email, $title)
{
$this->path = $path;
$this->url = $url;
$this->username = $username;
$this->password = $password;
$this->email = $email;
$this->title = $title;
}
public function file(string $os): string
{
return '';
}
public function content(string $os): string
{
$command = '';
if ($this->title) {
$command .= 'wp --path='.$this->path.' option update blogname "'.addslashes($this->title).'"'."\n";
}
if ($this->url) {
$command .= 'wp --path='.$this->path.' option update siteurl "'.addslashes($this->url).'"'."\n";
$command .= 'wp --path='.$this->path.' option update home "'.addslashes($this->url).'"'."\n";
}
return $command;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\SSHCommands;
use Illuminate\Support\Facades\File;
class UpgradeCommand extends Command
{
public function file(string $os): string
{
return File::get(base_path('system/commands/ubuntu/upgrade.sh'));
}
public function content(string $os): string
{
return $this->file($os);
}
}