2016-09-16 22:07:04 +00:00
< ? php
/**
* Pterodactyl - Panel
2017-01-24 22:57:08 +00:00
* Copyright ( c ) 2015 - 2017 Dane Everitt < dane @ daneeveritt . com >.
2016-09-16 22:07:04 +00:00
*
* 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 .
*/
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 ;
2016-09-16 22:07:04 +00:00
class VoiceServiceTableSeeder extends Seeder
{
/**
* The core service ID .
*
2017-03-12 22:02:15 +00:00
* @ var Service
2016-09-16 22:07:04 +00:00
*/
protected $service ;
/**
2016-12-07 22:46:38 +00:00
* Stores all of the option objects .
2016-09-16 22:07:04 +00:00
*
* @ var array
*/
protected $option = [];
/**
* Run the database seeds .
*
* @ return void
*/
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' => 'voice' ,
], [
2016-09-16 22:07:04 +00:00
'name' => 'Voice Servers' ,
'description' => 'Voice servers such as Mumble and Teamspeak 3.' ,
2016-12-07 22:46:38 +00:00
'startup' => '' ,
2017-04-17 23:26:03 +00:00
'index_file' => Service :: defaultIndexFile (),
2016-09-16 22:07:04 +00:00
]);
}
private function addCoreOptions ()
{
2017-04-27 20:16:57 +00:00
$script = <<< 'EOF'
#!/bin/ash
# Mumble Installation Script
#
# Server Files: /mnt/server
apk update
apk add tar curl
cd / tmp
curl - sSLO https :// github . com / mumble - voip / mumble / releases / download / $ { MUMBLE_VERSION } / murmur - static_x86 - $ { MUMBLE_VERSION } . tar . bz2
tar - xjvf murmur - static_x86 - $ { MUMBLE_VERSION } . tar . bz2
cp - r murmur - static_x86 - $ { MUMBLE_VERSION } /* / mnt / server
EOF ;
2017-03-12 22:02:15 +00:00
$this -> option [ 'mumble' ] = ServiceOption :: updateOrCreate ([
2017-02-16 23:06:16 +00:00
'service_id' => $this -> service -> id ,
2017-03-12 22:02:15 +00:00
'tag' => 'mumble' ,
], [
2016-09-16 22:07:04 +00:00
'name' => 'Mumble Server' ,
'description' => 'Mumble is an open source, low-latency, high quality voice chat software primarily intended for use while gaming.' ,
2017-03-18 18:49:48 +00:00
'docker_image' => 'quay.io/pterodactyl/core:glibc' ,
2017-03-12 22:02:15 +00:00
'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' ,
2017-04-27 20:16:57 +00:00
'script_install' => $script ,
2016-09-16 22:07:04 +00:00
]);
2016-09-17 02:55:10 +00:00
2017-04-27 20:16:57 +00:00
$script = <<< 'EOF'
#!/bin/ash
# TS3 Installation Script
#
# Server Files: /mnt/server
apk update
apk add tar curl
cd / tmp
curl - sSLO http :// dl . 4 players . de / ts / releases / $ { TS_VERSION } / teamspeak3 - server_linux_amd64 - $ { TS_VERSION } . tar . bz2
tar - xjvf teamspeak3 - server_linux_amd64 - $ { TS_VERSION } . tar . bz2
cp - r teamspeak3 - server_linux_amd64 /* / mnt / server
echo " machine_id=
default_voice_port = $ { SERVER_PORT }
voice_ip = 0.0 . 0.0
licensepath =
filetransfer_port = 30033
filetransfer_ip =
query_port = $ { SERVER_PORT }
query_ip = 0.0 . 0.0
query_ip_whitelist = query_ip_whitelist . txt
query_ip_blacklist = query_ip_blacklist . txt
dbplugin = ts3db_sqlite3
dbpluginparameter =
dbsqlpath = sql /
dbsqlcreatepath = create_sqlite /
dbconnections = 10
logpath = logs
logquerycommands = 0
dbclientkeepdays = 30
logappend = 0
query_skipbruteforcecheck = 0 " > /mnt/server/ts3server.ini
EOF ;
2017-03-12 22:02:15 +00:00
$this -> option [ 'ts3' ] = ServiceOption :: updateOrCreate ([
2017-02-16 23:06:16 +00:00
'service_id' => $this -> service -> id ,
2017-03-12 22:02:15 +00:00
'tag' => 'ts3' ,
], [
2016-09-17 02:55:10 +00:00
'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.' ,
2017-03-18 18:49:48 +00:00
'docker_image' => 'quay.io/pterodactyl/core:glibc' ,
2017-03-12 22:02:15 +00:00
'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}}' ,
2017-04-27 20:16:57 +00:00
'script_install' => $script ,
2016-09-17 02:55:10 +00:00
]);
2016-09-16 22:07:04 +00:00
}
private function addVariables ()
{
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-16 22:07:04 +00:00
'option_id' => $this -> option [ 'mumble' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'MAX_USERS' ,
], [
2016-09-16 22:07:04 +00:00
'name' => 'Maximum Users' ,
'description' => 'Maximum concurrent users on the mumble server.' ,
2017-03-12 22:02:15 +00:00
'default_value' => 100 ,
2016-09-16 22:07:04 +00:00
'user_viewable' => 1 ,
'user_editable' => 0 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|numeric|digits_between:1,5' ,
2016-09-16 22:07:04 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-17 02:55:10 +00:00
'option_id' => $this -> option [ 'mumble' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'MUMBLE_VERSION' ,
], [
2016-09-16 22:07:04 +00:00
'name' => 'Server Version' ,
'description' => 'Version of Mumble Server to download and use.' ,
2017-03-12 22:02:15 +00:00
'default_value' => '1.2.19' ,
2016-09-16 22:07:04 +00:00
'user_viewable' => 1 ,
'user_editable' => 1 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|regex:/^([0-9_\.-]{5,8})$/' ,
2016-09-16 22:07:04 +00:00
]);
2016-09-17 02:55:10 +00:00
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-17 02:55:10 +00:00
'option_id' => $this -> option [ 'ts3' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'T_VERSION' ,
], [
2016-09-17 02:55:10 +00:00
'name' => 'Server Version' ,
'description' => 'The version of Teamspeak 3 to use when running the server.' ,
2017-03-12 22:02:15 +00:00
'default_value' => '3.1.1.1' ,
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
]);
2016-09-16 22:07:04 +00:00
}
}