2016-09-07 21:48:20 +00:00
< ? php
/**
* Pterodactyl - Panel
2017-01-24 22:57:08 +00:00
* Copyright ( c ) 2015 - 2017 Dane Everitt < dane @ daneeveritt . com >.
2016-09-07 21:48:20 +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-07 21:48:20 +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-07 21:48:20 +00:00
class SourceServiceTableSeeder extends Seeder
{
2017-08-21 00:23:50 +00:00
use CreatesServiceIndex ;
2016-09-07 21:48:20 +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-07 21:48:20 +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' => 'srcds' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Source Engine' ,
2016-09-14 19:19:59 +00:00
'description' => 'Includes support for most Source Dedicated Server games.' ,
2017-03-12 22:02:15 +00:00
'startup' => './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +ip 0.0.0.0 -strictportbind -norestart' ,
2017-08-21 00:23:50 +00:00
'index_file' => $this -> getIndexScript (),
2016-09-07 21:48:20 +00:00
]);
}
private function addCoreOptions ()
{
2017-04-27 20:16:57 +00:00
$script = <<< 'EOF'
#!/bin/bash
# SRCDS Base Installation Script
#
# Server Files: /mnt/server
2017-05-05 23:15:18 +00:00
apt - y update
apt - y -- no - install - recommends install curl lib32gcc1 ca - certificates
2017-04-27 20:16:57 +00:00
cd / tmp
curl - sSL - o steamcmd . tar . gz http :// media . steampowered . com / installer / steamcmd_linux . tar . gz
2017-05-05 23:15:18 +00:00
mkdir - p / mnt / server / steamcmd
2017-04-27 20:16:57 +00:00
tar - xzvf steamcmd . tar . gz - C / mnt / server / steamcmd
cd / mnt / server / steamcmd
2017-05-05 23:15:18 +00:00
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown - R root : root / mnt
export HOME =/ mnt / server
2017-04-27 20:16:57 +00:00
./ steamcmd . sh + login anonymous + force_install_dir / mnt / server + app_update $ { SRCDS_APPID } + quit
mkdir - p / mnt / server /. steam / sdk32
cp - v linux32 / steamclient . so ../. steam / sdk32 / steamclient . so
EOF ;
2017-03-12 22:02:15 +00:00
$this -> option [ 'source' ] = ServiceOption :: updateOrCreate ([
2017-02-16 23:06:16 +00:00
'service_id' => $this -> service -> id ,
2017-03-12 22:02:15 +00:00
'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.' ,
2017-03-19 00:20:14 +00:00
'docker_image' => 'quay.io/pterodactyl/core:source' ,
2017-03-16 23:59:24 +00:00
'config_startup' => '{"done": "gameserver Steam ID", "userInteraction": []}' ,
2017-03-12 22:02:15 +00:00
'config_files' => '{}' ,
'config_logs' => '{"custom": true, "location": "logs/latest.log"}' ,
'config_stop' => 'quit' ,
'config_from' => null ,
'startup' => null ,
2017-04-27 20:16:57 +00:00
'script_install' => $script ,
'script_entry' => 'bash' ,
'script_container' => 'ubuntu:16.04' ,
2017-03-12 22:02:15 +00:00
]);
$this -> option [ 'insurgency' ] = ServiceOption :: updateOrCreate ([
'service_id' => $this -> service -> id ,
'tag' => 'insurgency' ,
], [
2016-09-07 21:48:20 +00:00
'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.' ,
2017-03-18 21:42:50 +00:00
'docker_image' => 'quay.io/pterodactyl/core:source' ,
2017-03-12 22:02:15 +00:00
'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' ,
2017-04-27 20:16:57 +00:00
'copy_script_from' => $this -> option [ 'source' ] -> id ,
2016-09-07 21:48:20 +00:00
]);
2017-03-12 22:02:15 +00:00
$this -> option [ 'tf2' ] = ServiceOption :: updateOrCreate ([
2017-02-16 23:06:16 +00:00
'service_id' => $this -> service -> id ,
2017-03-12 22:02:15 +00:00
'tag' => 'tf2' ,
], [
2016-09-28 03:33:49 +00:00
'name' => 'Team Fortress 2' ,
2016-09-07 21:48:20 +00:00
'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.' ,
2017-03-18 21:42:50 +00:00
'docker_image' => 'quay.io/pterodactyl/core:source' ,
2017-03-12 22:02:15 +00:00
'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' ,
2017-04-27 20:16:57 +00:00
'copy_script_from' => $this -> option [ 'source' ] -> id ,
2016-09-07 21:48:20 +00:00
]);
2017-04-27 20:16:57 +00:00
$script = <<< 'EOF'
#!/bin/bash
# ARK: Installation Script
#
# Server Files: /mnt/server
2017-05-05 23:15:18 +00:00
apt - y update
apt - y -- no - install - recommends install curl lib32gcc1 ca - certificates
2017-04-27 20:16:57 +00:00
cd / tmp
curl - sSL - o steamcmd . tar . gz http :// media . steampowered . com / installer / steamcmd_linux . tar . gz
2017-05-05 23:15:18 +00:00
mkdir - p / mnt / server / steamcmd
2017-04-27 20:16:57 +00:00
mkdir - p / mnt / server / Engine / Binaries / ThirdParty / SteamCMD / Linux
tar - xzvf steamcmd . tar . gz - C / mnt / server / steamcmd
tar - xzvf steamcmd . tar . gz - C / mnt / server / Engine / Binaries / ThirdParty / SteamCMD / Linux
cd / mnt / server / steamcmd
2017-05-05 23:15:18 +00:00
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown - R root : root / mnt
export HOME =/ mnt / server
2017-04-27 20:16:57 +00:00
./ steamcmd . sh + login anonymous + force_install_dir / mnt / server + app_update 376030 + quit
mkdir - p / mnt / server /. steam / sdk32
cp - v linux32 / steamclient . so ../. steam / sdk32 / steamclient . so
EOF ;
2017-03-12 22:02:15 +00:00
$this -> option [ 'ark' ] = ServiceOption :: updateOrCreate ([
2017-02-16 23:06:16 +00:00
'service_id' => $this -> service -> id ,
2017-03-12 22:02:15 +00:00
'tag' => 'ark' ,
], [
2016-11-05 00:37:40 +00:00
'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' ,
2017-03-18 21:42:50 +00:00
'docker_image' => 'quay.io/pterodactyl/core:source' ,
2017-03-12 22:02:15 +00:00
'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}}' ,
2017-04-27 20:16:57 +00:00
'script_install' => $script ,
'script_entry' => 'bash' ,
'script_container' => 'ubuntu:16.04' ,
2016-09-07 21:48:20 +00:00
]);
2017-07-08 20:52:40 +00:00
$script = <<< 'EOF'
#!/bin/bash
# CSGO Installation Script
#
# Server Files: /mnt/server
apt - y update
apt - y -- no - install - recommends install curl lib32gcc1 ca - certificates
cd / tmp
curl - sSL - o steamcmd . tar . gz http :// media . steampowered . com / installer / steamcmd_linux . tar . gz
mkdir - p / mnt / server / steamcmd
tar - xzvf steamcmd . tar . gz - C / mnt / server / steamcmd
cd / mnt / server / steamcmd
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown - R root : root / mnt
export HOME =/ mnt / server
./ steamcmd . sh + login anonymous + force_install_dir / mnt / server + app_update 740 + quit
mkdir - p / mnt / server /. steam / sdk32
cp - v linux32 / steamclient . so ../. steam / sdk32 / steamclient . so
EOF ;
$this -> option [ 'csgo' ] = ServiceOption :: updateOrCreate ([
'service_id' => $this -> service -> id ,
'tag' => 'csgo' ,
], [
'name' => 'Counter-Strike: Global Offensive' ,
'description' => 'Counter-Strike: Global Offensive is a multiplayer first-person shooter video game developed by Hidden Path Entertainment and Valve Corporation.' ,
'docker_image' => 'quay.io/pterodactyl/core:source' ,
'config_startup' => '{"done": "VAC secure mode is activated.", "userInteraction": []}' ,
'config_files' => null ,
'config_logs' => '{"custom": true, "location": "logs/latest.log"}' ,
'config_stop' => 'quit' ,
'config_from' => $this -> option [ 'source' ] -> id ,
'startup' => './srcds_run -game csgo -console -port {{SERVER_PORT}} +ip 0.0.0.0 +map {{SRCDS_MAP}} -strictportbind -norestart +sv_setsteamaccount {{STEAM_ACC}}' ,
'script_install' => $script ,
'script_entry' => 'bash' ,
'script_container' => 'ubuntu:16.04' ,
]);
2017-07-09 02:17:36 +00:00
$script = <<< 'EOF'
#!/bin/bash
# Garry's Mod Installation Script
#
# Server Files: /mnt/server
apt - y update
apt - y -- no - install - recommends install curl lib32gcc1 ca - certificates
cd / tmp
curl - sSL - o steamcmd . tar . gz http :// media . steampowered . com / installer / steamcmd_linux . tar . gz
mkdir - p / mnt / server / steamcmd
tar - xzvf steamcmd . tar . gz - C / mnt / server / steamcmd
cd / mnt / server / steamcmd
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown - R root : root / mnt
export HOME =/ mnt / server
./ steamcmd . sh + login anonymous + force_install_dir / mnt / server + app_update 4020 + quit
mkdir - p / mnt / server /. steam / sdk32
cp - v linux32 / steamclient . so ../. steam / sdk32 / steamclient . so
EOF ;
$this -> option [ 'gmod' ] = ServiceOption :: updateOrCreate ([
'service_id' => $this -> service -> id ,
'tag' => 'gmod' ,
], [
'name' => 'Garrys Mod' ,
'description' => 'Garrys Mod, is a sandbox physics game created by Garry Newman, and developed by his company, Facepunch Studios.' ,
'docker_image' => 'quay.io/pterodactyl/core:source' ,
'config_startup' => '{"done": "VAC secure mode is activated.", "userInteraction": []}' ,
'config_files' => null ,
'config_logs' => '{"custom": true, "location": "logs/latest.log"}' ,
'config_stop' => 'quit' ,
'config_from' => $this -> option [ 'source' ] -> id ,
'startup' => './srcds_run -game garrysmod -console -port {{SERVER_PORT}} +ip 0.0.0.0 +map {{SRCDS_MAP}} -strictportbind -norestart +sv_setsteamaccount {{STEAM_ACC}}' ,
'script_install' => $script ,
'script_entry' => 'bash' ,
'script_container' => 'ubuntu:16.04' ,
]);
2016-09-07 21:48:20 +00:00
}
private function addVariables ()
{
$this -> addInsurgencyVariables ();
$this -> addTF2Variables ();
2016-11-05 00:37:40 +00:00
$this -> addArkVariables ();
2017-07-08 20:52:40 +00:00
$this -> addCSGOVariables ();
2017-07-09 02:17:36 +00:00
$this -> addGMODVariables ();
2016-09-07 21:48:20 +00:00
$this -> addCustomVariables ();
}
private function addInsurgencyVariables ()
{
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-07 21:48:20 +00:00
'option_id' => $this -> option [ 'insurgency' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'SRCDS_APPID' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Game ID' ,
'description' => 'The ID corresponding to the game to download and run using SRCDS.' ,
'default_value' => '17705' ,
'user_viewable' => 1 ,
'user_editable' => 0 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|regex:/^(17705)$/' ,
2016-09-07 21:48:20 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-07 21:48:20 +00:00
'option_id' => $this -> option [ 'insurgency' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'SRCDS_GAME' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Game Name' ,
'description' => 'The name corresponding to the game to download and run using SRCDS.' ,
'default_value' => 'insurgency' ,
'user_viewable' => 1 ,
'user_editable' => 0 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|regex:/^(insurgency)$/' ,
2016-09-07 21:48:20 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-07 21:48:20 +00:00
'option_id' => $this -> option [ 'insurgency' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'SRCDS_MAP' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Default Map' ,
'description' => 'The default map to use when starting the server.' ,
'default_value' => 'sinjar' ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|regex:/^(\w{1,20})$/' ,
2016-09-07 21:48:20 +00:00
]);
}
private function addTF2Variables ()
{
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-07 21:48:20 +00:00
'option_id' => $this -> option [ 'tf2' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'SRCDS_APPID' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Game ID' ,
'description' => 'The ID corresponding to the game to download and run using SRCDS.' ,
'default_value' => '232250' ,
'user_viewable' => 1 ,
'user_editable' => 0 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|regex:/^(232250)$/' ,
2016-09-07 21:48:20 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-07 21:48:20 +00:00
'option_id' => $this -> option [ 'tf2' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'SRCDS_GAME' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Game Name' ,
'description' => 'The name corresponding to the game to download and run using SRCDS.' ,
'default_value' => 'tf' ,
'user_viewable' => 1 ,
'user_editable' => 0 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|regex:/^(tf)$/' ,
2016-09-07 21:48:20 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-09-07 21:48:20 +00:00
'option_id' => $this -> option [ 'tf2' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'SRCDS_MAP' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Default Map' ,
'description' => 'The default map to use when starting the server.' ,
'default_value' => 'cp_dustbowl' ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|regex:/^(\w{1,20})$/' ,
2016-09-07 21:48:20 +00:00
]);
}
2016-11-05 00:37:40 +00:00
private function addArkVariables ()
{
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-11-05 00:37:40 +00:00
'option_id' => $this -> option [ 'ark' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'ARK_PASSWORD' ,
], [
2016-11-05 00:37:40 +00:00
'name' => 'Server Password' ,
'description' => 'If specified, players must provide this password to join the server.' ,
'default_value' => '' ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
2017-03-12 22:02:15 +00:00
'rules' => 'alpha_dash|between:1,100' ,
2016-11-05 00:37:40 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-11-05 00:37:40 +00:00
'option_id' => $this -> option [ 'ark' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'ARK_ADMIN_PASSWORD' ,
], [
2016-11-05 00:37:40 +00:00
'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.' ,
'default_value' => '' ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
2017-03-12 22:02:15 +00:00
'rules' => 'alpha_dash|between:1,100' ,
2016-11-05 00:37:40 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
2016-11-05 00:37:40 +00:00
'option_id' => $this -> option [ 'ark' ] -> id ,
2017-03-12 22:02:15 +00:00
'env_variable' => 'SERVER_MAX_PLAYERS' ,
], [
2016-11-05 00:37:40 +00:00
'name' => 'Maximum Players' ,
'description' => 'Specifies the maximum number of players that can play on the server simultaneously.' ,
'default_value' => 20 ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|numeric|digits_between:1,4' ,
2016-11-05 00:37:40 +00:00
]);
}
2017-07-08 20:52:40 +00:00
private function addCSGOVariables ()
{
ServiceVariable :: updateOrCreate ([
'option_id' => $this -> option [ 'csgo' ] -> id ,
'env_variable' => 'SRCDS_MAP' ,
], [
'name' => 'Map' ,
'description' => 'The default map for the server.' ,
'default_value' => 'de_dust2' ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
'rules' => 'required|string|alpha_dash' ,
]);
ServiceVariable :: updateOrCreate ([
'option_id' => $this -> option [ 'csgo' ] -> id ,
'env_variable' => 'STEAM_ACC' ,
], [
'name' => 'Steam Account Token' ,
'description' => 'The Steam Account Token required for the server to be displayed publicly.' ,
'default_value' => '' ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
'rules' => 'required|string|alpha_num|size:32' ,
2017-07-09 02:17:36 +00:00
]);
}
private function addGMODVariables ()
{
ServiceVariable :: updateOrCreate ([
'option_id' => $this -> option [ 'gmod' ] -> id ,
'env_variable' => 'SRCDS_MAP' ,
], [
'name' => 'Map' ,
'description' => 'The default map for the server.' ,
'default_value' => 'gm_flatgrass' ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
'rules' => 'required|string|alpha_dash' ,
]);
ServiceVariable :: updateOrCreate ([
'option_id' => $this -> option [ 'gmod' ] -> id ,
'env_variable' => 'STEAM_ACC' ,
], [
'name' => 'Steam Account Token' ,
'description' => 'The Steam Account Token required for the server to be displayed publicly.' ,
'default_value' => '' ,
'user_viewable' => 1 ,
'user_editable' => 1 ,
'rules' => 'required|string|alpha_num|size:32' ,
2017-07-08 20:52:40 +00:00
]);
}
2016-09-07 21:48:20 +00:00
private function addCustomVariables ()
{
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
'option_id' => $this -> option [ 'source' ] -> id ,
'env_variable' => 'SRCDS_APPID' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Game ID' ,
'description' => 'The ID corresponding to the game to download and run using SRCDS.' ,
'default_value' => '' ,
'user_viewable' => 1 ,
'user_editable' => 0 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|numeric|digits_between:1,6' ,
2016-09-07 21:48:20 +00:00
]);
2017-03-12 22:02:15 +00:00
ServiceVariable :: updateOrCreate ([
'option_id' => $this -> option [ 'source' ] -> id ,
'env_variable' => 'SRCDS_GAME' ,
], [
2016-09-07 21:48:20 +00:00
'name' => 'Game Name' ,
'description' => 'The name corresponding to the game to download and run using SRCDS.' ,
'default_value' => '' ,
'user_viewable' => 1 ,
'user_editable' => 0 ,
2017-03-12 22:02:15 +00:00
'rules' => 'required|alpha_dash|between:1,100' ,
2016-09-07 21:48:20 +00:00
]);
}
}