mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-21 19:01:37 +00:00
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\SSH\Systemd;
|
|
|
|
use App\Models\Server;
|
|
|
|
class Systemd
|
|
{
|
|
public function __construct(protected Server $server)
|
|
{
|
|
}
|
|
|
|
public function status(string $unit): string
|
|
{
|
|
$command = <<<EOD
|
|
sudo service $unit status | cat
|
|
EOD;
|
|
|
|
return $this->server->ssh()->exec($command, sprintf('status-%s', $unit));
|
|
}
|
|
|
|
public function start(string $unit): string
|
|
{
|
|
$command = <<<EOD
|
|
sudo service $unit start
|
|
sudo service $unit status | cat
|
|
EOD;
|
|
|
|
return $this->server->ssh()->exec($command, sprintf('start-%s', $unit));
|
|
}
|
|
|
|
public function stop(string $unit): string
|
|
{
|
|
$command = <<<EOD
|
|
sudo service $unit stop
|
|
sudo service $unit status | cat
|
|
EOD;
|
|
|
|
return $this->server->ssh()->exec($command, sprintf('stop-%s', $unit));
|
|
}
|
|
|
|
public function restart(string $unit): string
|
|
{
|
|
$command = <<<EOD
|
|
sudo service $unit restart
|
|
sudo service $unit status | cat
|
|
EOD;
|
|
|
|
return $this->server->ssh()->exec($command, sprintf('restart-%s', $unit));
|
|
}
|
|
}
|