Path: blob/1.0-develop/app/Console/Commands/Node/MakeNodeCommand.php
7460 views
<?php12namespace Pterodactyl\Console\Commands\Node;34use Illuminate\Console\Command;5use Pterodactyl\Services\Nodes\NodeCreationService;67class MakeNodeCommand extends Command8{9protected $signature = 'p:node:make10{--name= : A name to identify the node.}11{--description= : A description to identify the node.}12{--locationId= : A valid locationId.}13{--fqdn= : The domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node.}14{--public= : Should the node be public or private? (public=1 / private=0).}15{--scheme= : Which scheme should be used? (Enable SSL=https / Disable SSL=http).}16{--proxy= : Is the daemon behind a proxy? (Yes=1 / No=0).}17{--maintenance= : Should maintenance mode be enabled? (Enable Maintenance mode=1 / Disable Maintenance mode=0).}18{--maxMemory= : Set the max memory amount.}19{--overallocateMemory= : Enter the amount of ram to overallocate (% or -1 to overallocate the maximum).}20{--maxDisk= : Set the max disk amount.}21{--overallocateDisk= : Enter the amount of disk to overallocate (% or -1 to overallocate the maximum).}22{--uploadSize= : Enter the maximum upload filesize.}23{--daemonListeningPort= : Enter the wings listening port.}24{--daemonSFTPPort= : Enter the wings SFTP listening port.}25{--daemonBase= : Enter the base folder.}';2627protected $description = 'Creates a new node on the system via the CLI.';2829/**30* MakeNodeCommand constructor.31*/32public function __construct(private NodeCreationService $creationService)33{34parent::__construct();35}3637/**38* Handle the command execution process.39*40* @throws \Pterodactyl\Exceptions\Model\DataValidationException41*/42public function handle()43{44$data['name'] = $this->option('name') ?? $this->ask('Enter a short identifier used to distinguish this node from others');45$data['description'] = $this->option('description') ?? $this->ask('Enter a description to identify the node');46$data['location_id'] = $this->option('locationId') ?? $this->ask('Enter a valid location id');47$data['scheme'] = $this->option('scheme') ?? $this->anticipate(48'Please either enter https for SSL or http for a non-ssl connection',49['https', 'http'],50'https'51);52$data['fqdn'] = $this->option('fqdn') ?? $this->ask('Enter a domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node');53$data['public'] = $this->option('public') ?? $this->confirm('Should this node be public? As a note, setting a node to private you will be denying the ability to auto-deploy to this node.', true);54$data['behind_proxy'] = $this->option('proxy') ?? $this->confirm('Is your FQDN behind a proxy?');55$data['maintenance_mode'] = $this->option('maintenance') ?? $this->confirm('Should maintenance mode be enabled?');56$data['memory'] = $this->option('maxMemory') ?? $this->ask('Enter the maximum amount of memory');57$data['memory_overallocate'] = $this->option('overallocateMemory') ?? $this->ask('Enter the amount of memory to over allocate by, -1 will disable checking and 0 will prevent creating new servers');58$data['disk'] = $this->option('maxDisk') ?? $this->ask('Enter the maximum amount of disk space');59$data['disk_overallocate'] = $this->option('overallocateDisk') ?? $this->ask('Enter the amount of memory to over allocate by, -1 will disable checking and 0 will prevent creating new server');60$data['upload_size'] = $this->option('uploadSize') ?? $this->ask('Enter the maximum filesize upload', '100');61$data['daemonListen'] = $this->option('daemonListeningPort') ?? $this->ask('Enter the wings listening port', '8080');62$data['daemonSFTP'] = $this->option('daemonSFTPPort') ?? $this->ask('Enter the wings SFTP listening port', '2022');63$data['daemonBase'] = $this->option('daemonBase') ?? $this->ask('Enter the base folder', '/var/lib/pterodactyl/volumes');6465$node = $this->creationService->handle($data);66$this->line('Successfully created a new node on the location ' . $data['location_id'] . ' with the name ' . $data['name'] . ' and has an id of ' . $node->id . '.');67}68}697071