Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Console/Commands/Node/MakeNodeCommand.php
7460 views
1
<?php
2
3
namespace Pterodactyl\Console\Commands\Node;
4
5
use Illuminate\Console\Command;
6
use Pterodactyl\Services\Nodes\NodeCreationService;
7
8
class MakeNodeCommand extends Command
9
{
10
protected $signature = 'p:node:make
11
{--name= : A name to identify the node.}
12
{--description= : A description to identify the node.}
13
{--locationId= : A valid locationId.}
14
{--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.}
15
{--public= : Should the node be public or private? (public=1 / private=0).}
16
{--scheme= : Which scheme should be used? (Enable SSL=https / Disable SSL=http).}
17
{--proxy= : Is the daemon behind a proxy? (Yes=1 / No=0).}
18
{--maintenance= : Should maintenance mode be enabled? (Enable Maintenance mode=1 / Disable Maintenance mode=0).}
19
{--maxMemory= : Set the max memory amount.}
20
{--overallocateMemory= : Enter the amount of ram to overallocate (% or -1 to overallocate the maximum).}
21
{--maxDisk= : Set the max disk amount.}
22
{--overallocateDisk= : Enter the amount of disk to overallocate (% or -1 to overallocate the maximum).}
23
{--uploadSize= : Enter the maximum upload filesize.}
24
{--daemonListeningPort= : Enter the wings listening port.}
25
{--daemonSFTPPort= : Enter the wings SFTP listening port.}
26
{--daemonBase= : Enter the base folder.}';
27
28
protected $description = 'Creates a new node on the system via the CLI.';
29
30
/**
31
* MakeNodeCommand constructor.
32
*/
33
public function __construct(private NodeCreationService $creationService)
34
{
35
parent::__construct();
36
}
37
38
/**
39
* Handle the command execution process.
40
*
41
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
42
*/
43
public function handle()
44
{
45
$data['name'] = $this->option('name') ?? $this->ask('Enter a short identifier used to distinguish this node from others');
46
$data['description'] = $this->option('description') ?? $this->ask('Enter a description to identify the node');
47
$data['location_id'] = $this->option('locationId') ?? $this->ask('Enter a valid location id');
48
$data['scheme'] = $this->option('scheme') ?? $this->anticipate(
49
'Please either enter https for SSL or http for a non-ssl connection',
50
['https', 'http'],
51
'https'
52
);
53
$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');
54
$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);
55
$data['behind_proxy'] = $this->option('proxy') ?? $this->confirm('Is your FQDN behind a proxy?');
56
$data['maintenance_mode'] = $this->option('maintenance') ?? $this->confirm('Should maintenance mode be enabled?');
57
$data['memory'] = $this->option('maxMemory') ?? $this->ask('Enter the maximum amount of memory');
58
$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');
59
$data['disk'] = $this->option('maxDisk') ?? $this->ask('Enter the maximum amount of disk space');
60
$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');
61
$data['upload_size'] = $this->option('uploadSize') ?? $this->ask('Enter the maximum filesize upload', '100');
62
$data['daemonListen'] = $this->option('daemonListeningPort') ?? $this->ask('Enter the wings listening port', '8080');
63
$data['daemonSFTP'] = $this->option('daemonSFTPPort') ?? $this->ask('Enter the wings SFTP listening port', '2022');
64
$data['daemonBase'] = $this->option('daemonBase') ?? $this->ask('Enter the base folder', '/var/lib/pterodactyl/volumes');
65
66
$node = $this->creationService->handle($data);
67
$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 . '.');
68
}
69
}
70
71