Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/views/admin/servers/view/startup.blade.php
7461 views
1
@extends('layouts.admin')
2
3
@section('title')
4
Server — {{ $server->name }}: Startup
5
@endsection
6
7
@section('content-header')
8
<h1>{{ $server->name }}<small>Control startup command as well as variables.</small></h1>
9
<ol class="breadcrumb">
10
<li><a href="{{ route('admin.index') }}">Admin</a></li>
11
<li><a href="{{ route('admin.servers') }}">Servers</a></li>
12
<li><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></li>
13
<li class="active">Startup</li>
14
</ol>
15
@endsection
16
17
@section('content')
18
@include('admin.servers.partials.navigation')
19
<form action="{{ route('admin.servers.view.startup', $server->id) }}" method="POST">
20
<div class="row">
21
<div class="col-xs-12">
22
<div class="box box-primary">
23
<div class="box-header with-border">
24
<h3 class="box-title">Startup Command Modification</h3>
25
</div>
26
<div class="box-body">
27
<label for="pStartup" class="form-label">Startup Command</label>
28
<input id="pStartup" name="startup" class="form-control" type="text" value="{{ old('startup', $server->startup) }}" />
29
<p class="small text-muted">Edit your server's startup command here. The following variables are available by default: <code>@{{SERVER_MEMORY}}</code>, <code>@{{SERVER_IP}}</code>, and <code>@{{SERVER_PORT}}</code>.</p>
30
</div>
31
<div class="box-body">
32
<label for="pDefaultStartupCommand" class="form-label">Default Service Start Command</label>
33
<input id="pDefaultStartupCommand" class="form-control" type="text" readonly />
34
</div>
35
<div class="box-footer">
36
{!! csrf_field() !!}
37
<button type="submit" class="btn btn-primary btn-sm pull-right">Save Modifications</button>
38
</div>
39
</div>
40
</div>
41
</div>
42
<div class="row">
43
<div class="col-md-6">
44
<div class="box">
45
<div class="box-header with-border">
46
<h3 class="box-title">Service Configuration</h3>
47
</div>
48
<div class="box-body row">
49
<div class="col-xs-12">
50
<p class="small text-danger">
51
Changing any of the below values will result in the server processing a re-install command. The server will be stopped and will then proceed.
52
If you would like the service scripts to not run, ensure the box is checked at the bottom.
53
</p>
54
<p class="small text-danger">
55
<strong>This is a destructive operation in many cases. This server will be stopped immediately in order for this action to proceed.</strong>
56
</p>
57
</div>
58
<div class="form-group col-xs-12">
59
<label for="pNestId">Nest</label>
60
<select name="nest_id" id="pNestId" class="form-control">
61
@foreach($nests as $nest)
62
<option value="{{ $nest->id }}"
63
@if($nest->id === $server->nest_id)
64
selected
65
@endif
66
>{{ $nest->name }}</option>
67
@endforeach
68
</select>
69
<p class="small text-muted no-margin">Select the Nest that this server will be grouped into.</p>
70
</div>
71
<div class="form-group col-xs-12">
72
<label for="pEggId">Egg</label>
73
<select name="egg_id" id="pEggId" class="form-control"></select>
74
<p class="small text-muted no-margin">Select the Egg that will provide processing data for this server.</p>
75
</div>
76
<div class="form-group col-xs-12">
77
<div class="checkbox checkbox-primary no-margin-bottom">
78
<input id="pSkipScripting" name="skip_scripts" type="checkbox" value="1" @if($server->skip_scripts) checked @endif />
79
<label for="pSkipScripting" class="strong">Skip Egg Install Script</label>
80
</div>
81
<p class="small text-muted no-margin">If the selected Egg has an install script attached to it, the script will run during install. If you would like to skip this step, check this box.</p>
82
</div>
83
</div>
84
</div>
85
<div class="box">
86
<div class="box-header with-border">
87
<h3 class="box-title">Docker Image Configuration</h3>
88
</div>
89
<div class="box-body">
90
<div class="form-group">
91
<label for="pDockerImage">Image</label>
92
<select id="pDockerImage" name="docker_image" class="form-control"></select>
93
<input id="pDockerImageCustom" name="custom_docker_image" value="{{ old('custom_docker_image') }}" class="form-control" placeholder="Or enter a custom image..." style="margin-top:1rem"/>
94
<p class="small text-muted no-margin">This is the Docker image that will be used to run this server. Select an image from the dropdown or enter a custom image in the text field above.</p>
95
</div>
96
</div>
97
</div>
98
</div>
99
<div class="col-md-6">
100
<div class="row" id="appendVariablesTo"></div>
101
</div>
102
</div>
103
</form>
104
@endsection
105
106
@section('footer-scripts')
107
@parent
108
{!! Theme::js('vendor/lodash/lodash.js') !!}
109
<script>
110
function escapeHtml(str) {
111
var div = document.createElement('div');
112
div.appendChild(document.createTextNode(str));
113
return div.innerHTML;
114
}
115
116
$(document).ready(function () {
117
$('#pEggId').select2({placeholder: 'Select a Nest Egg'}).on('change', function () {
118
var selectedEgg = _.isNull($(this).val()) ? $(this).find('option').first().val() : $(this).val();
119
var parentChain = _.get(Pterodactyl.nests, $("#pNestId").val());
120
var objectChain = _.get(parentChain, 'eggs.' + selectedEgg);
121
122
const images = _.get(objectChain, 'docker_images', [])
123
$('#pDockerImage').html('');
124
const keys = Object.keys(images);
125
for (let i = 0; i < keys.length; i++) {
126
let opt = document.createElement('option');
127
opt.value = images[keys[i]];
128
opt.innerText = keys[i] + " (" + images[keys[i]] + ")";
129
if (objectChain.id === parseInt(Pterodactyl.server.egg_id) && Pterodactyl.server.image == opt.value) {
130
opt.selected = true
131
}
132
$('#pDockerImage').append(opt);
133
}
134
$('#pDockerImage').on('change', function () {
135
$('#pDockerImageCustom').val('');
136
})
137
138
if (objectChain.id === parseInt(Pterodactyl.server.egg_id)) {
139
if ($('#pDockerImage').val() != Pterodactyl.server.image) {
140
$('#pDockerImageCustom').val(Pterodactyl.server.image);
141
}
142
}
143
144
if (!_.get(objectChain, 'startup', false)) {
145
$('#pDefaultStartupCommand').val(_.get(parentChain, 'startup', 'ERROR: Startup Not Defined!'));
146
} else {
147
$('#pDefaultStartupCommand').val(_.get(objectChain, 'startup'));
148
}
149
150
$('#appendVariablesTo').html('');
151
$.each(_.get(objectChain, 'variables', []), function (i, item) {
152
var setValue = _.get(Pterodactyl.server_variables, item.env_variable, item.default_value);
153
var isRequired = (item.required === 1) ? '<span class="label label-danger">Required</span> ' : '';
154
var dataAppend = ' \
155
<div class="col-xs-12"> \
156
<div class="box"> \
157
<div class="box-header with-border"> \
158
<h3 class="box-title">' + isRequired + escapeHtml(item.name) + '</h3> \
159
</div> \
160
<div class="box-body"> \
161
<input name="environment[' + escapeHtml(item.env_variable) + ']" class="form-control" type="text" id="egg_variable_' + escapeHtml(item.env_variable) + '" /> \
162
<p class="no-margin small text-muted">' + escapeHtml(item.description) + '</p> \
163
</div> \
164
<div class="box-footer"> \
165
<p class="no-margin text-muted small"><strong>Startup Command Variable:</strong> <code>' + escapeHtml(item.env_variable) + '</code></p> \
166
<p class="no-margin text-muted small"><strong>Input Rules:</strong> <code>' + escapeHtml(item.rules) + '</code></p> \
167
</div> \
168
</div> \
169
</div>';
170
$('#appendVariablesTo').append(dataAppend).find('#egg_variable_' + item.env_variable).val(setValue);
171
});
172
});
173
174
$('#pNestId').select2({placeholder: 'Select a Nest'}).on('change', function () {
175
$('#pEggId').html('').select2({
176
data: $.map(_.get(Pterodactyl.nests, $(this).val() + '.eggs', []), function (item) {
177
return {
178
id: item.id,
179
text: item.name,
180
};
181
}),
182
});
183
184
if (_.isObject(_.get(Pterodactyl.nests, $(this).val() + '.eggs.' + Pterodactyl.server.egg_id))) {
185
$('#pEggId').val(Pterodactyl.server.egg_id);
186
}
187
188
$('#pEggId').change();
189
}).change();
190
});
191
</script>
192
@endsection
193
194