2020-01-18 23:26:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Remote\Servers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
2020-01-19 21:50:38 +00:00
|
|
|
use Illuminate\Http\Response;
|
2020-01-18 23:26:15 +00:00
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
|
|
|
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
2020-01-19 21:50:38 +00:00
|
|
|
use Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest;
|
2020-01-18 23:26:15 +00:00
|
|
|
|
|
|
|
class ServerInstallController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
|
|
|
*/
|
|
|
|
private $repository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ServerInstallController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct(ServerRepository $repository)
|
|
|
|
{
|
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns installation information for a server.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
2020-01-19 21:50:38 +00:00
|
|
|
public function index(Request $request, string $uuid)
|
2020-01-18 23:26:15 +00:00
|
|
|
{
|
|
|
|
$server = $this->repository->getByUuid($uuid);
|
|
|
|
$egg = $server->egg;
|
|
|
|
|
|
|
|
return JsonResponse::create([
|
|
|
|
'container_image' => $egg->copy_script_container,
|
|
|
|
'entrypoint' => $egg->copy_script_entry,
|
|
|
|
'script' => $egg->copy_script_install,
|
|
|
|
]);
|
|
|
|
}
|
2020-01-19 21:50:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the installation state of a server.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
*/
|
|
|
|
public function store(InstallationDataRequest $request, string $uuid)
|
|
|
|
{
|
|
|
|
$server = $this->repository->getByUuid($uuid);
|
|
|
|
|
|
|
|
$this->repository->update($server->id, [
|
2020-01-19 22:08:28 +00:00
|
|
|
'installed' => (string) $request->input('successful') === '1' ? 1 : 2,
|
|
|
|
], true, true);
|
2020-01-19 21:50:38 +00:00
|
|
|
|
|
|
|
return JsonResponse::create([], Response::HTTP_NO_CONTENT);
|
|
|
|
}
|
2020-01-18 23:26:15 +00:00
|
|
|
}
|