Update seeders to not error out and allow updating values quickly.

This commit is contained in:
Dane Everitt 2017-03-12 18:02:15 -04:00
parent e791d561ba
commit 97cad1d55e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 305 additions and 174 deletions

View file

@ -49,7 +49,7 @@ class Service extends Model
*
* @return string
*/
public function defaultIndexFile()
public static function defaultIndexFile()
{
return <<<'EOF'
'use strict';

View file

@ -59,7 +59,7 @@ class ServiceRepository
'description' => (isset($data['description'])) ? $data['description'] : null,
'folder' => $data['folder'],
'startup' => (isset($data['startup'])) ? $data['startup'] : null,
'index_file' => $service->defaultIndexFile(),
'index_file' => Service::defaultIndexFile(),
])->save();
// It is possible for an event to return false or throw an exception

View file

@ -21,15 +21,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use Pterodactyl\Models;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\Service;
use Pterodactyl\Models\ServiceOption;
use Pterodactyl\Models\ServiceVariable;
class MinecraftServiceTableSeeder extends Seeder
{
/**
* The core service ID.
*
* @var Models\Service
* @var \Pterodactyl\Models\Service
*/
protected $service;
@ -40,6 +42,47 @@ class MinecraftServiceTableSeeder extends Seeder
*/
protected $option = [];
private $default_mc = <<<'EOF'
'use strict';
/**
* Pterodactyl - Daemon
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const rfr = require('rfr');
const _ = require('lodash');
const Core = rfr('src/services/index.js');
class Service extends Core {
onConsole(data) {
// Hide the output spam from Bungeecord getting pinged.
if (_.endsWith(data, '<-> InitialHandler has connected')) return;
return super.onConsole(data);
}
}
module.exports = Service;
EOF;
/**
* Run the database seeds.
*
@ -54,55 +97,76 @@ class MinecraftServiceTableSeeder extends Seeder
private function addCoreService()
{
$this->service = Models\Service::create([
'author' => 'ptrdctyl-v040-11e6-8b77-86f30ca893d3',
$this->service = Service::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'minecraft',
], [
'name' => 'Minecraft',
'description' => 'Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!',
'file' => 'minecraft',
'executable' => 'java',
'startup' => '-Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}',
'startup' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}',
'index_file' => $this->default_mc,
]);
}
private function addCoreOptions()
{
$this->option['vanilla'] = Models\ServiceOption::create([
$this->option['vanilla'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'vanilla',
], [
'name' => 'Vanilla Minecraft',
'description' => 'Minecraft is a game about placing blocks and going on adventures. Explore randomly generated worlds and build amazing things from the simplest of homes to the grandest of castles. Play in Creative Mode with unlimited resources or mine deep in Survival Mode, crafting weapons and armor to fend off dangerous mobs. Do all this alone or with friends.',
'tag' => 'vanilla',
'docker_image' => 'quay.io/pterodactyl/minecraft',
'executable' => null,
'config_startup' => '{"done": ")! For help, type ", "userInteraction": [ "Go to eula.txt for more info."]}',
'config_logs' => '{"custom": false, "location": "logs/latest.log"}',
'config_files' => '{"server.properties":{"parser": "properties", "find":{"server-ip": "0.0.0.0", "enable-query": "true", "server-port": "{{server.build.default.port}}", "query.port": "{{server.build.default.port}}"}}}',
'config_stop' => 'stop',
'config_from' => null,
'startup' => null,
]);
$this->option['spigot'] = Models\ServiceOption::create([
$this->option['spigot'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'spigot',
], [
'name' => 'Spigot',
'description' => 'Spigot is the most widely-used modded Minecraft server software in the world. It powers many of the top Minecraft server networks around to ensure they can cope with their huge player base and ensure the satisfaction of their players. Spigot works by reducing and eliminating many causes of lag, as well as adding in handy features and settings that help make your job of server administration easier.',
'tag' => 'spigot',
'docker_image' => 'quay.io/pterodactyl/minecraft:spigot',
'executable' => null,
'startup' => '-Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}',
]);
$this->option['sponge'] = Models\ServiceOption::create([
'service_id' => $this->service->id,
'name' => 'Sponge (SpongeVanilla)',
'description' => 'SpongeVanilla is the SpongeAPI implementation for Vanilla Minecraft.',
'tag' => 'sponge',
'docker_image' => 'quay.io/pterodactyl/minecraft:sponge',
'executable' => null,
'config_startup' => null,
'config_files' => '{"spigot.yml":{"parser": "yaml", "find":{"settings.restart-on-crash": "false"}}}',
'config_logs' => null,
'config_stop' => null,
'config_from' => $this->option['vanilla']->id,
'startup' => null,
]);
$this->option['bungeecord'] = Models\ServiceOption::create([
$this->option['sponge'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'sponge',
], [
'name' => 'Sponge (SpongeVanilla)',
'description' => 'SpongeVanilla is the SpongeAPI implementation for Vanilla Minecraft.',
'docker_image' => 'quay.io/pterodactyl/minecraft:sponge',
'config_startup' => '{"userInteraction": [ "You need to agree to the EULA"]}',
'config_files' => null,
'config_logs' => null,
'config_stop' => null,
'config_from' => $this->option['vanilla']->id,
'startup' => null,
]);
$this->option['bungeecord'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'bungeecord',
], [
'name' => 'Bungeecord',
'description' => 'For a long time, Minecraft server owners have had a dream that encompasses a free, easy, and reliable way to connect multiple Minecraft servers together. BungeeCord is the answer to said dream. Whether you are a small server wishing to string multiple game-modes together, or the owner of the ShotBow Network, BungeeCord is the ideal solution for you. With the help of BungeeCord, you will be able to unlock your community\'s full potential.',
'tag' => 'bungeecord',
'docker_image' => 'quay.io/pterodactyl/minecraft:bungeecord',
'executable' => null,
'config_startup' => '{"done": "Listening on ", "userInteraction": [ "Listening on /0.0.0.0:25577"]}',
'config_files' => '{"config.yml":{"parser": "yaml", "find":{"listeners[0].query_enabled": true, "listeners[0].query_port": "{{server.build.default.port}}", "listeners[0].host": "0.0.0.0:{{server.build.default.port}}", "servers.*.address":{"127.0.0.1": "{{config.docker.interface}}", "localhost": "{{config.docker.interface}}"}}}}',
'config_logs' => '{"custom": false, "location": "proxy.log.0"}',
'config_stop' => 'end',
'config_from' => null,
'startup' => null,
]);
}
@ -117,121 +181,130 @@ class MinecraftServiceTableSeeder extends Seeder
private function addVanillaVariables()
{
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['vanilla']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Server Jar File',
'description' => 'The name of the server jarfile to run the server with.',
'env_variable' => 'SERVER_JARFILE',
'default_value' => 'server.jar',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^([\w\d._-]+)(\.jar)$/',
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['vanilla']->id,
'env_variable' => 'VANILLA_VERSION',
], [
'name' => 'Server Version',
'description' => 'The version of Minecraft Vanilla to install. Use "latest" to install the latest version.',
'env_variable' => 'VANILLA_VERSION',
'default_value' => 'latest',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^(latest|[a-zA-Z0-9_\.-]{3,7})$/',
'rules' => 'required|string|between:3,7',
]);
}
private function addSpigotVariables()
{
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['spigot']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Server Jar File',
'description' => 'The name of the server jarfile to run the server with.',
'env_variable' => 'SERVER_JARFILE',
'default_value' => 'server.jar',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^([\w\d._-]+)(\.jar)$/',
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['spigot']->id,
'env_variable' => 'DL_VERSION',
], [
'name' => 'Spigot Version',
'description' => 'The version of Spigot to download (using the --rev tag). Use "latest" for latest.',
'env_variable' => 'DL_VERSION',
'default_value' => 'latest',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^(latest|[a-zA-Z0-9_\.-]{3,7})$/',
'rules' => 'required|string|between:3,7',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['spigot']->id,
'env_variable' => 'DL_PATH',
], [
'name' => 'Download Path',
'description' => 'A URL to use to download Spigot rather than building it on the server. This is not user viewable. Use <code>{{DL_VERSION}}</code> in the URL to automatically insert the assigned version into the URL. If you do not enter a URL Spigot will build directly in the container (this will fail on low memory containers).',
'env_variable' => 'DL_PATH',
'default_value' => '',
'user_viewable' => 0,
'user_editable' => 0,
'required' => 0,
'regex' => '/^(.*)$/',
'rules' => 'required|string',
]);
}
private function addSpongeVariables()
{
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['sponge']->id,
'env_variable' => 'SPONGE_VERSION',
], [
'name' => 'Sponge Version',
'description' => 'The version of SpongeVanilla to download and use.',
'env_variable' => 'SPONGE_VERSION',
'default_value' => '1.10.2-5.1.0-BETA-359',
'default_value' => '1.10.2-5.2.0-BETA-381',
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^([a-zA-Z0-9.\-_]+)$/',
'rules' => 'required|regex:/^([a-zA-Z0-9.\-_]+)$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['sponge']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Server Jar File',
'description' => 'The name of the Jarfile to use when running SpongeVanilla.',
'env_variable' => 'SERVER_JARFILE',
'default_value' => 'server.jar',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^([\w\d._-]+)(\.jar)$/',
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
}
private function addBungeecordVariables()
{
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['bungeecord']->id,
'env_variable' => 'BUNGEE_VERSION',
], [
'name' => 'Bungeecord Version',
'description' => 'The version of Bungeecord to download and use.',
'env_variable' => 'BUNGEE_VERSION',
'default_value' => 'latest',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^(latest|[\d]{1,6})$/',
'rules' => 'required|alpha_num|between:1,6',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['bungeecord']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Bungeecord Jar File',
'description' => 'The name of the Jarfile to use when running Bungeecord.',
'env_variable' => 'SERVER_JARFILE',
'default_value' => 'bungeecord.jar',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^([\w\d._-]+)(\.jar)$/',
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
}
}

View file

@ -21,8 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use Pterodactyl\Models;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\Service;
use Pterodactyl\Models\ServiceOption;
use Pterodactyl\Models\ServiceVariable;
class SourceServiceTableSeeder extends Seeder
{
@ -54,57 +56,78 @@ class SourceServiceTableSeeder extends Seeder
private function addCoreService()
{
$this->service = Models\Service::create([
'author' => 'ptrdctyl-v040-11e6-8b77-86f30ca893d3',
$this->service = Service::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'srcds',
], [
'name' => 'Source Engine',
'description' => 'Includes support for most Source Dedicated Server games.',
'file' => 'srcds',
'executable' => './srcds_run',
'startup' => '-game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} -strictportbind -norestart',
'startup' => './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +ip 0.0.0.0 -strictportbind -norestart',
'index_file' => Service::defaultIndexFile(),
]);
}
private function addCoreOptions()
{
$this->option['insurgency'] = Models\ServiceOption::create([
'service_id' => $this->service->id,
'name' => 'Insurgency',
'description' => 'Take to the streets for intense close quarters combat, where a team\'s survival depends upon securing crucial strongholds and destroying enemy supply in this multiplayer and cooperative Source Engine based experience.',
'tag' => 'srcds',
'docker_image' => 'quay.io/pterodactyl/srcds',
'executable' => null,
'startup' => '-game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +map {{SRCDS_MAP}} -strictportbind -norestart',
]);
$this->option['tf2'] = Models\ServiceOption::create([
'service_id' => $this->service->id,
'name' => 'Team Fortress 2',
'description' => 'Team Fortress 2 is a team-based first-person shooter multiplayer video game developed and published by Valve Corporation. It is the sequel to the 1996 mod Team Fortress for Quake and its 1999 remake.',
'tag' => 'srcds',
'docker_image' => 'quay.io/pterodactyl/srcds',
'executable' => null,
'startup' => '-game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +map {{SRCDS_MAP}} -strictportbind -norestart',
]);
$this->option['ark'] = Models\ServiceOption::create([
'service_id' => $this->service->id,
'name' => 'Ark: Survival Evolved',
'description' => 'As a man or woman stranded, naked, freezing, and starving on the unforgiving shores of a mysterious island called ARK, use your skill and cunning to kill or tame and ride the plethora of leviathan dinosaurs and other primeval creatures roaming the land. Hunt, harvest resources, craft items, grow crops, research technologies, and build shelters to withstand the elements and store valuables, all while teaming up with (or preying upon) hundreds of other players to survive, dominate... and escape! — Gamepedia: ARK',
'tag' => 'ark',
'docker_image' => 'quay.io/pterodactyl/srcds:ark',
'executable' => './ShooterGameServer',
'startup' => 'TheIsland?listen?ServerPassword={{ARK_PASSWORD}}?ServerAdminPassword={{ARK_ADMIN_PASSWORD}}?Port={{SERVER_PORT}}?MaxPlayers={{SERVER_MAX_PLAYERS}}',
]);
$this->option['custom'] = Models\ServiceOption::create([
$this->option['source'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'source',
], [
'name' => 'Custom Source Engine Game',
'description' => 'This option allows modifying the startup arguments and other details to run a custo SRCDS based game on the panel.',
'tag' => 'srcds',
'docker_image' => 'quay.io/pterodactyl/srcds',
'executable' => null,
'config_startup' => '{"done": "Assigned anonymous gameserver", "userInteraction": []}',
'config_files' => '{}',
'config_logs' => '{"custom": true, "location": "logs/latest.log"}',
'config_stop' => 'quit',
'config_from' => null,
'startup' => null,
]);
$this->option['insurgency'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'insurgency',
], [
'name' => 'Insurgency',
'description' => 'Take to the streets for intense close quarters combat, where a team\'s survival depends upon securing crucial strongholds and destroying enemy supply in this multiplayer and cooperative Source Engine based experience.',
'docker_image' => 'quay.io/pterodactyl/srcds',
'config_startup' => null,
'config_files' => null,
'config_logs' => null,
'config_stop' => null,
'config_from' => $this->option['source']->id,
'startup' => './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +map {{SRCDS_MAP}} +ip 0.0.0.0 -strictportbind -norestart',
]);
$this->option['tf2'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'tf2',
], [
'name' => 'Team Fortress 2',
'description' => 'Team Fortress 2 is a team-based first-person shooter multiplayer video game developed and published by Valve Corporation. It is the sequel to the 1996 mod Team Fortress for Quake and its 1999 remake.',
'docker_image' => 'quay.io/pterodactyl/srcds',
'config_startup' => null,
'config_files' => null,
'config_logs' => null,
'config_stop' => null,
'config_from' => $this->option['source']->id,
'startup' => './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +map {{SRCDS_MAP}} +ip 0.0.0.0 -strictportbind -norestart',
]);
$this->option['ark'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'ark',
], [
'name' => 'Ark: Survival Evolved',
'description' => 'As a man or woman stranded, naked, freezing, and starving on the unforgiving shores of a mysterious island called ARK, use your skill and cunning to kill or tame and ride the plethora of leviathan dinosaurs and other primeval creatures roaming the land. Hunt, harvest resources, craft items, grow crops, research technologies, and build shelters to withstand the elements and store valuables, all while teaming up with (or preying upon) hundreds of other players to survive, dominate... and escape! — Gamepedia: ARK',
'docker_image' => 'quay.io/pterodactyl/srcds:ark',
'config_startup' => '{"done": "Setting breakpad minidump AppID"}',
'config_files' => null,
'config_logs' => null,
'config_stop' => '^C',
'config_from' => $this->option['source']->id,
'startup' => './ShooterGame/Binaries/Linux/ShooterGameServer TheIsland?listen?ServerPassword={{ARK_PASSWORD}}?ServerAdminPassword={{ARK_ADMIN_PASSWORD}}?Port={{SERVER_PORT}}?MaxPlayers={{SERVER_MAX_PLAYERS}}',
]);
}
private function addVariables()
@ -117,145 +140,156 @@ class SourceServiceTableSeeder extends Seeder
private function addInsurgencyVariables()
{
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['insurgency']->id,
'env_variable' => 'SRCDS_APPID',
], [
'name' => 'Game ID',
'description' => 'The ID corresponding to the game to download and run using SRCDS.',
'env_variable' => 'SRCDS_APPID',
'default_value' => '17705',
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^(17705)$/',
'rules' => 'required|regex:/^(17705)$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['insurgency']->id,
'env_variable' => 'SRCDS_GAME',
], [
'name' => 'Game Name',
'description' => 'The name corresponding to the game to download and run using SRCDS.',
'env_variable' => 'SRCDS_GAME',
'default_value' => 'insurgency',
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^(insurgency)$/',
'rules' => 'required|regex:/^(insurgency)$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['insurgency']->id,
'env_variable' => 'SRCDS_MAP',
], [
'name' => 'Default Map',
'description' => 'The default map to use when starting the server.',
'env_variable' => 'SRCDS_MAP',
'default_value' => 'sinjar',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^(\w{1,20})$/',
'rules' => 'required|regex:/^(\w{1,20})$/',
]);
}
private function addTF2Variables()
{
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['tf2']->id,
'env_variable' => 'SRCDS_APPID',
], [
'name' => 'Game ID',
'description' => 'The ID corresponding to the game to download and run using SRCDS.',
'env_variable' => 'SRCDS_APPID',
'default_value' => '232250',
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^(232250)$/',
'rules' => 'required|regex:/^(232250)$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['tf2']->id,
'env_variable' => 'SRCDS_GAME',
], [
'name' => 'Game Name',
'description' => 'The name corresponding to the game to download and run using SRCDS.',
'env_variable' => 'SRCDS_GAME',
'default_value' => 'tf',
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^(tf)$/',
'rules' => 'required|regex:/^(tf)$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['tf2']->id,
'env_variable' => 'SRCDS_MAP',
], [
'name' => 'Default Map',
'description' => 'The default map to use when starting the server.',
'env_variable' => 'SRCDS_MAP',
'default_value' => 'cp_dustbowl',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^(\w{1,20})$/',
'rules' => 'required|regex:/^(\w{1,20})$/',
]);
}
private function addArkVariables()
{
DB::table('service_variables')->insert([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['ark']->id,
'env_variable' => 'ARK_PASSWORD',
], [
'name' => 'Server Password',
'description' => 'If specified, players must provide this password to join the server.',
'env_variable' => 'ARK_PASSWORD',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 0,
'regex' => '/^(\w\.*)$/',
'rules' => 'alpha_dash|between:1,100',
]);
DB::table('service_variables')->insert([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['ark']->id,
'env_variable' => 'ARK_ADMIN_PASSWORD',
], [
'name' => 'Admin Password',
'description' => 'If specified, players must provide this password (via the in-game console) to gain access to administrator commands on the server.',
'env_variable' => 'ARK_ADMIN_PASSWORD',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 0,
'regex' => '/^(\w\.*)$/',
'rules' => 'alpha_dash|between:1,100',
]);
DB::table('service_variables')->insert([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['ark']->id,
'env_variable' => 'SERVER_MAX_PLAYERS',
], [
'name' => 'Maximum Players',
'description' => 'Specifies the maximum number of players that can play on the server simultaneously.',
'env_variable' => 'SERVER_MAX_PLAYERS',
'default_value' => 20,
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^(\d{1,4})$/',
'rules' => 'required|numeric|digits_between:1,4',
]);
}
private function addCustomVariables()
{
Models\ServiceVariable::create([
'option_id' => $this->option['custom']->id,
ServiceVariable::updateOrCreate([
'option_id' => $this->option['source']->id,
'env_variable' => 'SRCDS_APPID',
], [
'name' => 'Game ID',
'description' => 'The ID corresponding to the game to download and run using SRCDS.',
'env_variable' => 'SRCDS_APPID',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^(\d){1,6}$/',
'rules' => 'required|numeric|digits_between:1,6',
]);
Models\ServiceVariable::create([
'option_id' => $this->option['custom']->id,
ServiceVariable::updateOrCreate([
'option_id' => $this->option['source']->id,
'env_variable' => 'SRCDS_GAME',
], [
'name' => 'Game Name',
'description' => 'The name corresponding to the game to download and run using SRCDS.',
'env_variable' => 'SRCDS_GAME',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^(.*)$/',
'rules' => 'required|alpha_dash|between:1,100',
]);
}
}

View file

@ -21,8 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use Pterodactyl\Models;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\Service;
use Pterodactyl\Models\ServiceOption;
use Pterodactyl\Models\ServiceVariable;
class TerrariaServiceTableSeeder extends Seeder
{
@ -54,53 +56,60 @@ class TerrariaServiceTableSeeder extends Seeder
private function addCoreService()
{
$this->service = Models\Service::create([
'author' => 'ptrdctyl-v040-11e6-8b77-86f30ca893d3',
$this->service = Service::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'terraria',
], [
'name' => 'Terraria',
'description' => 'Terraria is a land of adventure! A land of mystery! A land that\'s yours to shape, defend, and enjoy. Your options in Terraria are limitless. Are you an action gamer with an itchy trigger finger? A master builder? A collector? An explorer? There\'s something for everyone.',
'file' => 'terraria',
'executable' => 'TerrariaServer.exe',
'startup' => '-port {{SERVER_PORT}} -autocreate 2 -worldname World',
'startup' => 'mono TerrariaServer.exe -port {{SERVER_PORT}} -autocreate 2 -worldname World',
]);
}
private function addCoreOptions()
{
$this->option['tshock'] = Models\ServiceOption::create([
$this->option['tshock'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'tshock',
], [
'name' => 'Terraria Server (TShock)',
'description' => 'TShock is a server modification for Terraria, written in C#, and based upon the Terraria Server API. It uses JSON for configuration management, and offers several features not present in the Terraria Server normally.',
'tag' => 'tshock',
'docker_image' => 'quay.io/pterodactyl/terraria:tshock',
'executable' => '',
'startup' => '',
'config_startup' => '{"userInteraction": [ "You need to agree to the EULA"]}',
'config_startup' => '{"done": "Type \'help\' for a list of commands", "userInteraction": []}',
'config_files' => '{"tshock/config.json":{"parser": "json", "find":{"ServerPort": "{{server.build.default.port}}", "MaxSlots": "{{server.build.env.MAX_SLOTS}}"}}}',
'config_logs' => '{"custom": false, "location": "ServerLog.txt"}',
'config_stop' => 'exit',
'startup' => null,
]);
}
private function addVariables()
{
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['tshock']->id,
'env_variable' => 'T_VERSION',
], [
'name' => 'TShock Version',
'description' => 'Which version of TShock to install and use.',
'env_variable' => 'T_VERSION',
'default_value' => '4.3.17',
'default_value' => '4.3.22',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^([0-9_\.-]{5,10})$/',
'rules' => 'required|regex:/^([0-9_\.-]{5,10})$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['tshock']->id,
'env_variable' => 'MAX_SLOTS',
], [
'name' => 'Maximum Slots',
'description' => 'Total number of slots to allow on the server.',
'env_variable' => 'MAX_SLOTS',
'default_value' => '20',
'default_value' => 20,
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^(\d){1,3}$/',
'rules' => 'required|numeric|digits_between:1,3',
]);
}
}

View file

@ -21,15 +21,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use Pterodactyl\Models;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\Service;
use Pterodactyl\Models\ServiceOption;
use Pterodactyl\Models\ServiceVariable;
class VoiceServiceTableSeeder extends Seeder
{
/**
* The core service ID.
*
* @var Models\Service
* @var Service
*/
protected $service;
@ -54,75 +56,88 @@ class VoiceServiceTableSeeder extends Seeder
private function addCoreService()
{
$this->service = Models\Service::create([
'author' => 'ptrdctyl-v040-11e6-8b77-86f30ca893d3',
$this->service = Service::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'voice',
], [
'name' => 'Voice Servers',
'description' => 'Voice servers such as Mumble and Teamspeak 3.',
'file' => 'voice',
'executable' => '',
'startup' => '',
]);
}
private function addCoreOptions()
{
$this->option['mumble'] = Models\ServiceOption::create([
$this->option['mumble'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'mumble',
], [
'name' => 'Mumble Server',
'description' => 'Mumble is an open source, low-latency, high quality voice chat software primarily intended for use while gaming.',
'tag' => 'mumble',
'docker_image' => 'quay.io/pterodactyl/voice:mumble',
'executable' => './murmur.x86',
'startup' => '-fg',
'config_startup' => '{"done": "Server listening on", "userInteraction": [ "Generating new server certificate"]}',
'config_files' => '{"murmur.ini":{"parser": "ini", "find":{"logfile": "murmur.log", "port": "{{server.build.default.port}}", "host": "0.0.0.0", "users": "{{server.build.env.MAX_USERS}}"}}}',
'config_logs' => '{"custom": true, "location": "logs/murmur.log"}',
'config_stop' => '^C',
'config_from' => null,
'startup' => './murmur.x86 -fg',
]);
$this->option['ts3'] = Models\ServiceOption::create([
$this->option['ts3'] = ServiceOption::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'ts3',
], [
'name' => 'Teamspeak3 Server',
'description' => 'VoIP software designed with security in mind, featuring crystal clear voice quality, endless customization options, and scalabilty up to thousands of simultaneous users.',
'tag' => 'ts3',
'docker_image' => 'quay.io/pterodactyl/voice:ts3',
'executable' => './ts3server_minimal_runscript.sh',
'startup' => 'default_voice_port={{SERVER_PORT}} query_port={{SERVER_PORT}}',
'config_startup' => '{"done": "listening on 0.0.0.0:", "userInteraction": []}',
'config_files' => '{"ts3server.ini":{"parser": "ini", "find":{"default_voice_port": "{{server.build.default.port}}", "voice_ip": "0.0.0.0", "query_port": "{{server.build.default.port}}", "query_ip": "0.0.0.0"}}}',
'config_logs' => '{"custom": true, "location": "logs/ts3.log"}',
'config_stop' => '^C',
'config_from' => null,
'startup' => './ts3server_minimal_runscript.sh default_voice_port={{SERVER_PORT}} query_port={{SERVER_PORT}}',
]);
}
private function addVariables()
{
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['mumble']->id,
'env_variable' => 'MAX_USERS',
], [
'name' => 'Maximum Users',
'description' => 'Maximum concurrent users on the mumble server.',
'env_variable' => 'MAX_USERS',
'default_value' => '100',
'default_value' => 100,
'user_viewable' => 1,
'user_editable' => 0,
'required' => 1,
'regex' => '/^(\d){1,6}$/',
'rules' => 'required|numeric|digits_between:1,5',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['mumble']->id,
'env_variable' => 'MUMBLE_VERSION',
], [
'name' => 'Server Version',
'description' => 'Version of Mumble Server to download and use.',
'env_variable' => 'MUMBLE_VERSION',
'default_value' => '1.2.16',
'default_value' => '1.2.19',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^([0-9_\.-]{5,8})$/',
'rules' => 'required|regex:/^([0-9_\.-]{5,8})$/',
]);
Models\ServiceVariable::create([
ServiceVariable::updateOrCreate([
'option_id' => $this->option['ts3']->id,
'env_variable' => 'T_VERSION',
], [
'name' => 'Server Version',
'description' => 'The version of Teamspeak 3 to use when running the server.',
'env_variable' => 'T_VERSION',
'default_value' => '3.0.13.4',
'default_value' => '3.1.1.1',
'user_viewable' => 1,
'user_editable' => 1,
'required' => 1,
'regex' => '/^([0-9_\.-]{5,10})$/',
'rules' => 'required|regex:/^([0-9_\.-]{5,10})$/',
]);
}
}