mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 06:56:15 +00:00
Merge (#127)
This commit is contained in:
73
app/SSH/Systemd/Systemd.php
Normal file
73
app/SSH/Systemd/Systemd.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?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 systemctl status $unit | cat
|
||||
EOD;
|
||||
|
||||
return $this->server->ssh()->exec($command, sprintf('status-%s', $unit));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user