Plugins base (#613)

* wip

* wip

* cleanup

* notification channels

* phpstan

* services

* remove server types

* refactoring

* refactoring
This commit is contained in:
Saeed Vaziry
2025-06-14 14:35:18 +02:00
committed by GitHub
parent adc0653d15
commit 131b828807
311 changed files with 3976 additions and 2660 deletions

102
app/SSH/OS/Systemd.php Normal file
View File

@ -0,0 +1,102 @@
<?php
namespace App\SSH\OS;
use App\Exceptions\SSHError;
use App\Models\Server;
class Systemd
{
public function __construct(protected Server $server) {}
/**
* @throws SSHError
*/
public function status(string $unit): string
{
$command = <<<EOD
sudo systemctl status $unit | cat
EOD;
return $this->server->ssh()->exec($command, sprintf('status-%s', $unit));
}
/**
* @throws SSHError
*/
public function start(string $unit): string
{
$command = <<<EOD
sudo systemctl start $unit
sudo systemctl status $unit | cat
EOD;
return $this->server->ssh()->exec($command, sprintf('start-%s', $unit));
}
/**
* @throws SSHError
*/
public function stop(string $unit): string
{
$command = <<<EOD
sudo systemctl stop $unit
sudo systemctl status $unit | cat
EOD;
return $this->server->ssh()->exec($command, sprintf('stop-%s', $unit));
}
/**
* @throws SSHError
*/
public function restart(string $unit): string
{
$command = <<<EOD
sudo systemctl restart $unit
sudo systemctl status $unit | cat
EOD;
return $this->server->ssh()->exec($command, sprintf('restart-%s', $unit));
}
/**
* @throws SSHError
*/
public function enable(string $unit): string
{
$command = <<<EOD
sudo systemctl start $unit
sudo systemctl enable $unit
sudo systemctl status $unit | cat
EOD;
return $this->server->ssh()->exec($command, sprintf('enable-%s', $unit));
}
/**
* @throws SSHError
*/
public function disable(string $unit): string
{
$command = <<<EOD
sudo systemctl stop $unit
sudo systemctl disable $unit
sudo systemctl status $unit | cat
EOD;
return $this->server->ssh()->exec($command, sprintf('disable-%s', $unit));
}
/**
* @throws SSHError
*/
public function reload(): string
{
$command = <<<'EOD'
sudo systemctl daemon-reload
EOD;
return $this->server->ssh()->exec($command, 'reload-systemctl');
}
}