mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 03:36:53 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			64 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace Pterodactyl\Http\Controllers\Api\Remote;
 | 
						|
 | 
						|
use Illuminate\Http\Request;
 | 
						|
use Illuminate\Http\JsonResponse;
 | 
						|
use Pterodactyl\Http\Controllers\Controller;
 | 
						|
use Pterodactyl\Services\Servers\EnvironmentService;
 | 
						|
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
 | 
						|
 | 
						|
class EggInstallController extends Controller
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * @var \Pterodactyl\Services\Servers\EnvironmentService
 | 
						|
     */
 | 
						|
    private $environment;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
 | 
						|
     */
 | 
						|
    private $repository;
 | 
						|
 | 
						|
    /**
 | 
						|
     * EggInstallController constructor.
 | 
						|
     */
 | 
						|
    public function __construct(EnvironmentService $environment, ServerRepositoryInterface $repository)
 | 
						|
    {
 | 
						|
        $this->environment = $environment;
 | 
						|
        $this->repository = $repository;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Handle request to get script and installation information for a server
 | 
						|
     * that is being created on the node.
 | 
						|
     *
 | 
						|
     * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
 | 
						|
     */
 | 
						|
    public function index(Request $request, string $uuid): JsonResponse
 | 
						|
    {
 | 
						|
        $node = $request->attributes->get('node');
 | 
						|
 | 
						|
        /** @var \Pterodactyl\Models\Server $server */
 | 
						|
        $server = $this->repository->findFirstWhere([
 | 
						|
            ['uuid', '=', $uuid],
 | 
						|
            ['node_id', '=', $node->id],
 | 
						|
        ]);
 | 
						|
 | 
						|
        $this->repository->loadEggRelations($server);
 | 
						|
        $egg = $server->getRelation('egg');
 | 
						|
 | 
						|
        return response()->json([
 | 
						|
            'scripts' => [
 | 
						|
                'install' => !$egg->copy_script_install ? null : str_replace(["\r\n", "\n", "\r"], "\n", $egg->copy_script_install),
 | 
						|
                'privileged' => $egg->script_is_privileged,
 | 
						|
            ],
 | 
						|
            'config' => [
 | 
						|
                'container' => $egg->copy_script_container,
 | 
						|
                'entry' => $egg->copy_script_entry,
 | 
						|
            ],
 | 
						|
            'env' => $this->environment->handle($server),
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
}
 |