diff --git a/web/app/Filament/Resources/PhyreServerResource.php b/web/app/Filament/Resources/PhyreServerResource.php index 72dcba9..1427ada 100644 --- a/web/app/Filament/Resources/PhyreServerResource.php +++ b/web/app/Filament/Resources/PhyreServerResource.php @@ -82,6 +82,10 @@ class PhyreServerResource extends Resource ->action(function ($record) { $record->healthCheck(); }), + Tables\Actions\Action::make('Update Server') + ->action(function ($record) { + $record->updateServer(); + }), Tables\Actions\Action::make('Sync Resources') ->action(function ($record) { $record->syncResources(); diff --git a/web/app/Models/PhyreServer.php b/web/app/Models/PhyreServer.php index a470e65..fcfd2f0 100644 --- a/web/app/Models/PhyreServer.php +++ b/web/app/Models/PhyreServer.php @@ -6,6 +6,7 @@ use App\ApiSDK\PhyreApiSDK; use App\Events\ModelPhyreServerCreated; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use phpseclib3\Net\SSH2; class PhyreServer extends Model { @@ -79,7 +80,7 @@ class PhyreServer extends Model } } - + // // Sync Hosting Plans // $getHostingPlans = HostingPlan::all(); @@ -90,6 +91,19 @@ class PhyreServer extends Model // } } + public function updateServer() + { + $ssh = new SSH2($this->ip); + if ($ssh->login($this->username, $this->password)) { + + $output = $ssh->exec('rm -rf /usr/local/phyre/update/update-web-panel.sh'); + $output = $ssh->exec('cd /usr/local/phyre/update && wget https://raw.githubusercontent.com/CloudVisionApps/PhyrePanel/main/update/update-web-panel.sh'); + $output = $ssh->exec('chmod +x /usr/local/phyre/update/update-web-panel.sh'); + $output = $ssh->exec('cd /usr/local/phyre/update && ./update-web-panel.sh'); + + } + } + public function healthCheck() { try {