2727
2828class MigrateToNewServiceSystem extends Migration
2929{
30- protected $ services ;
31-
3230 /**
3331 * Run the migrations.
3432 *
3533 * @return void
3634 */
3735 public function up ()
3836 {
39- $ this ->services = Service::where ('author ' , 'ptrdctyl-v040-11e6-8b77-86f30ca893d3 ' )->get ();
37+ $ service = Service::where ('author ' , config ('pterodactyl.service.core ' ))->where ('folder ' , 'srcds ' )->first ();
38+ if (! $ service ) {
39+ return ;
40+ }
4041
41- $ this ->minecraft ();
42- $ this ->srcds ();
43- $ this ->terraria ();
44- $ this ->voice ();
42+ $ options = ServiceOption::where ('service_id ' , $ service ->id )->get ();
43+ $ options ->each (function ($ item ) use ($ options ) {
44+ if ($ item ->tag === 'srcds ' && $ item ->name === 'Insurgency ' ) {
45+ $ item ->tag = 'insurgency ' ;
46+ } elseif ($ item ->tag === 'srcds ' && $ item ->name === 'Team Fortress 2 ' ) {
47+ $ item ->tag = 'tf2 ' ;
48+ } elseif ($ item ->tag === 'srcds ' && $ item ->name === 'Custom Source Engine Game ' ) {
49+ $ item ->tag = 'source ' ;
50+ }
51+ });
4552 }
4653
4754 /**
@@ -53,169 +60,4 @@ public function down()
5360 {
5461 // Not doing reversals right now...
5562 }
56-
57- public function minecraft ()
58- {
59- $ service = $ this ->services ->where ('folder ' , 'minecraft ' )->first ();
60- if (! $ service ) {
61- return ;
62- }
63-
64- // Set New Default Startup
65- $ service ->startup = 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}} ' ;
66-
67- DB ::transaction (function () use ($ service ) {
68- $ options = ServiceOption::where ('service_id ' , $ service ->id )->get ();
69- $ options ->each (function ($ item ) use ($ options ) {
70- switch ($ item ->tag ) {
71- case 'vanilla ' :
72- $ item ->config_startup = '{"done": ")! For help, type ", "userInteraction": [ "Go to eula.txt for more info."]} ' ;
73- $ item ->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}}"}}} ' ;
74- $ item ->config_logs = '{"custom": false, "location": "logs/latest.log"} ' ;
75- $ item ->config_stop = 'stop ' ;
76- break ;
77- case 'spigot ' :
78- $ item ->startup = null ;
79- $ item ->config_from = $ options ->where ('tag ' , 'vanilla ' )->pluck ('id ' )->pop ();
80- $ item ->config_files = '{"spigot.yml":{"parser": "yaml", "find":{"settings.restart-on-crash": "false"}}} ' ;
81- break ;
82- case 'bungeecord ' :
83- $ item ->config_startup = '{"done": "Listening on ", "userInteraction": [ "Listening on /0.0.0.0:25577"]} ' ;
84- $ item ->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}}"}}}} ' ;
85- $ item ->config_logs = '{"custom": false, "location": "proxy.log.0"} ' ;
86- $ item ->config_stop = 'end ' ;
87- break ;
88- case 'sponge ' :
89- $ item ->startup = null ;
90- $ item ->config_from = $ options ->where ('tag ' , 'vanilla ' )->pluck ('id ' )->pop ();
91- $ item ->config_startup = '{"userInteraction": [ "You need to agree to the EULA"]} ' ;
92- break ;
93- default :
94- break ;
95- }
96-
97- $ item ->save ();
98- });
99-
100- $ service ->save ();
101- });
102- }
103-
104- public function srcds ()
105- {
106- $ service = $ this ->services ->where ('folder ' , 'srcds ' )->first ();
107- if (! $ service ) {
108- return ;
109- }
110-
111- $ service ->startup = './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +ip 0.0.0.0 -strictportbind -norestart ' ;
112-
113- DB ::transaction (function () use ($ service ) {
114- $ options = ServiceOption::where ('service_id ' , $ service ->id )->get ();
115- $ options ->each (function ($ item ) use ($ options ) {
116- if ($ item ->tag === 'srcds ' && $ item ->name === 'Insurgency ' ) {
117- $ item ->tag = 'insurgency ' ;
118- } elseif ($ item ->tag === 'srcds ' && $ item ->name === 'Team Fortress 2 ' ) {
119- $ item ->tag = 'tf2 ' ;
120- } elseif ($ item ->tag === 'srcds ' && $ item ->name === 'Custom Source Engine Game ' ) {
121- $ item ->tag = 'source ' ;
122- }
123-
124- switch ($ item ->tag ) {
125- case 'source ' :
126- $ item ->config_startup = '{"done": "Assigned anonymous gameserver", "userInteraction": []} ' ;
127- $ item ->config_files = '{} ' ;
128- $ item ->config_logs = '{"custom": true, "location": "logs/latest.log"} ' ;
129- $ item ->config_stop = 'quit ' ;
130- break ;
131- case 'insurgency ' :
132- case 'tf2 ' :
133- $ item ->startup = './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +map {{SRCDS_MAP}} +ip 0.0.0.0 -strictportbind -norestart ' ;
134- $ item ->config_from = $ options ->where ('name ' , 'Custom Source Engine Game ' )->pluck ('id ' )->pop ();
135- break ;
136- case 'ark ' :
137- $ item ->startup = './ShooterGame/Binaries/Linux/ShooterGameServer TheIsland?listen?ServerPassword={{ARK_PASSWORD}}?ServerAdminPassword={{ARK_ADMIN_PASSWORD}}?Port={{SERVER_PORT}}?MaxPlayers={{SERVER_MAX_PLAYERS}} ' ;
138- $ item ->config_from = $ options ->where ('name ' , 'Custom Source Engine Game ' )->pluck ('id ' )->pop ();
139- $ item ->config_startup = '{"done": "Setting breakpad minidump AppID"} ' ;
140- $ item ->config_stop = '^C ' ;
141- break ;
142- default :
143- break ;
144- }
145-
146- $ item ->save ();
147- });
148-
149- $ service ->save ();
150- });
151- }
152-
153- public function terraria ()
154- {
155- $ service = $ this ->services ->where ('folder ' , 'terraria ' )->first ();
156- if (! $ service ) {
157- return ;
158- }
159-
160- $ service ->startup = 'mono TerrariaServer.exe -port {{SERVER_PORT}} -autocreate 2 -worldname World ' ;
161-
162- DB ::transaction (function () use ($ service ) {
163- $ options = ServiceOption::where ('service_id ' , $ service ->id )->get ();
164- $ options ->each (function ($ item ) use ($ options ) {
165- switch ($ item ->tag ) {
166- case 'tshock ' :
167- $ item ->startup = null ;
168- $ item ->config_startup = '{"done": "Type \'help \' for a list of commands", "userInteraction": []} ' ;
169- $ item ->config_files = '{"tshock/config.json":{"parser": "json", "find":{"ServerPort": "{{server.build.default.port}}", "MaxSlots": "{{server.build.env.MAX_SLOTS}}"}}} ' ;
170- $ item ->config_logs = '{"custom": false, "location": "ServerLog.txt"} ' ;
171- $ item ->config_stop = 'exit ' ;
172- break ;
173- default :
174- break ;
175- }
176-
177- $ item ->save ();
178- });
179-
180- $ service ->save ();
181- });
182- }
183-
184- public function voice ()
185- {
186- $ service = $ this ->services ->where ('folder ' , 'voice ' )->first ();
187- if (! $ service ) {
188- return ;
189- }
190-
191- $ service ->startup = null ;
192-
193- DB ::transaction (function () use ($ service ) {
194- $ options = ServiceOption::where ('service_id ' , $ service ->id )->get ();
195- $ options ->each (function ($ item ) use ($ options ) {
196- switch ($ item ->tag ) {
197- case 'mumble ' :
198- $ item ->startup = './murmur.x86 -fg ' ;
199- $ item ->config_startup = '{"done": "Server listening on", "userInteraction": [ "Generating new server certificate"]} ' ;
200- $ item ->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}}"}}} ' ;
201- $ item ->config_logs = '{"custom": true, "location": "logs/murmur.log"} ' ;
202- $ item ->config_stop = '^C ' ;
203- break ;
204- case 'ts3 ' :
205- $ item ->startup = './ts3server_minimal_runscript.sh default_voice_port={{SERVER_PORT}} query_port={{SERVER_PORT}} ' ;
206- $ item ->config_startup = '{"done": "listening on 0.0.0.0:", "userInteraction": []} ' ;
207- $ item ->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"}}} ' ;
208- $ item ->config_logs = '{"custom": true, "location": "logs/ts3.log"} ' ;
209- $ item ->config_stop = '^C ' ;
210- break ;
211- default :
212- break ;
213- }
214-
215- $ item ->save ();
216- });
217-
218- $ service ->save ();
219- });
220- }
22163}
0 commit comments