mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
27
app/SSH/Cron/Cron.php
Normal file
27
app/SSH/Cron/Cron.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSH\Cron;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class Cron
|
||||
{
|
||||
public function __construct(protected Server $server)
|
||||
{
|
||||
}
|
||||
|
||||
public function update(string $user, string $cron): void
|
||||
{
|
||||
$command = <<<EOD
|
||||
if ! echo '$cron' | sudo -u $user crontab -; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo -u $user crontab -l; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
EOD;
|
||||
|
||||
$this->server->ssh()->exec($command);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user