2016-09-17 02:55:10 +00:00
< ? php
/**
* Pterodactyl - Panel
2017-01-24 22:57:08 +00:00
* Copyright ( c ) 2015 - 2017 Dane Everitt < dane @ daneeveritt . com >.
2016-09-17 02:55:10 +00:00
*
2017-09-26 02:43:01 +00:00
* This software is licensed under the terms of the MIT license .
* https :// opensource . org / licenses / MIT
2016-09-17 02:55:10 +00:00
*/
2016-12-07 22:46:38 +00:00
use Illuminate\Database\Seeder ;
2017-03-12 22:02:15 +00:00
use Pterodactyl\Models\Service ;
use Pterodactyl\Models\ServiceOption ;
use Pterodactyl\Models\ServiceVariable ;
2017-08-21 00:23:50 +00:00
use Pterodactyl\Traits\Services\CreatesServiceIndex ;
2016-09-17 02:55:10 +00:00
class TerrariaServiceTableSeeder extends Seeder
{
2017-08-21 00:23:50 +00:00
use CreatesServiceIndex ;
2016-09-17 02:55:10 +00:00
/**
* The core service ID .
*
* @ var Models\Service
*/
protected $service ;
/**
2016-12-07 22:46:38 +00:00
* Stores all of the option objects .
2016-09-17 02:55:10 +00:00
*
* @ var array
*/
protected $option = [];
/**
* Run the database seeds .
*/
public function run ()
{
$this -> addCoreService ();
$this -> addCoreOptions ();
$this -> addVariables ();
}
private function addCoreService ()
{
2017-03-12 22:02:15 +00:00
$this -> service = Service :: updateOrCreate ([
'author' => config ( 'pterodactyl.service.core' ),
'folder' => 'terraria' ,
], [
2016-09-17 02:55:10 +00:00
'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.' ,
2017-03-12 22:02:15 +00:00
'startup' => 'mono TerrariaServer.exe -port {{SERVER_PORT}} -autocreate 2 -worldname World' ,
2017-08-21 00:23:50 +00:00
'index_file' => $this -> getIndexScript (),
2016-09-17 02:55:10 +00:00
]);
}
private function addCoreOptions ()
{
2017-04-27 20:16:57 +00:00
$script = <<< 'EOF'
#!/bin/ash
# TShock Installation Script
#
# Server Files: /mnt/server
apk update
apk add curl unzip
cd / tmp
curl - sSLO https :// github . com / NyxStudios / TShock / releases / download / v $ { T_VERSION } / tshock_ $ { T_VERSION } . zip
unzip - o tshock_ $ { T_VERSION } . zip - d / mnt / server
EOF ;
2017-03-12 22:02:15 +00:00
$this -> option [ 'tshock' ] = ServiceOption :: updateOrCreate ([
2017-02-16 23:06:16 +00:00
'service_id' => $this -> service -> id ,
2017-03-12 22:02:15 +00:00
'tag' => 'tshock' ,
], [
2016-09-17 02:55:10 +00:00
'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.' ,
2017-03-18 18:49:48 +00:00
'docker_image' => 'quay.io/pterodactyl/core:mono' ,
2017-03-12 22:02:15 +00:00
'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 ,
2017-04-27 20:16:57 +00:00
'script_install' => $script ,
2016-09-17 02:55:10 +00:00
]);
}
private function addVariables ()
{
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-17 02:55:10 +00:00
'option_id' => $this -> option [ 'tshock' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'T_VERSION' ,
], [
2016-09-17 02:55:10 +00:00
'name' => 'TShock Version' ,
'description' => 'Which version of TShock to install and use.' ,
2017-03-12 22:02:15 +00:00
'default_value' => '4.3.22' ,
2016-09-17 02:55:10 +00:00
'user_viewable' => 1 ,
'user_editable' => 1 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|regex:/^([0-9_\.-]{5,10})$/' ,
2016-09-17 02:55:10 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-21 20:04:48 +00:00
'option_id' => $this -> option [ 'tshock' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'MAX_SLOTS' ,
], [
2016-09-17 02:55:10 +00:00
'name' => 'Maximum Slots' ,
'description' => 'Total number of slots to allow on the server.' ,
2017-03-12 22:02:15 +00:00
'default_value' => 20 ,
2016-09-17 02:55:10 +00:00
'user_viewable' => 1 ,
'user_editable' => 0 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|numeric|digits_between:1,3' ,
2016-09-17 02:55:10 +00:00
]);
}
}