This commit is contained in:
Bozhidar Slaveykov 2024-04-07 01:06:23 +03:00
parent f6344b0aad
commit 19ef66abd4
2 changed files with 19 additions and 1 deletions

View file

@ -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();

View file

@ -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 {