Restart After Upgrade
This commit is contained in:
parent
5f006ce042
commit
69d9fe5fb0
|
@ -33,6 +33,14 @@ class Pterodactyl
|
||||||
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
|
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function clientadmin()
|
||||||
|
{
|
||||||
|
return Http::withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . config("SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN"),
|
||||||
|
'Content-type' => 'application/json',
|
||||||
|
'Accept' => 'Application/vnd.pterodactyl.v1+json',
|
||||||
|
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @return Exception
|
* @return Exception
|
||||||
*/
|
*/
|
||||||
|
@ -317,4 +325,11 @@ class Pterodactyl
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function powerAction(Server $server, $action)
|
||||||
|
{
|
||||||
|
return self::clientadmin()->post("/client/servers/{$server->identifier}/power", [
|
||||||
|
"signal" => $action
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,6 +289,9 @@ class ServerController extends Controller
|
||||||
if ($response->failed()) return $this->serverCreationFailed($response, $server);
|
if ($response->failed()) return $this->serverCreationFailed($response, $server);
|
||||||
//update user balance
|
//update user balance
|
||||||
$user->decrement('credits', $priceupgrade);
|
$user->decrement('credits', $priceupgrade);
|
||||||
|
//restart the server
|
||||||
|
$response = Pterodactyl::powerAction($server, "restart");
|
||||||
|
if ($response->failed()) return $this->serverCreationFailed($response, $server);
|
||||||
return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
|
return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue