Skip to content

Commit e26a7ac

Browse files
ygtrippsDaneEveritt
authored andcommitted
Created a GMOD Service Option (pterodactyl#542)
1 parent 4c63990 commit e26a7ac

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

database/seeds/SourceServiceTableSeeder.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,50 @@ private function addCoreOptions()
236236
'script_entry' => 'bash',
237237
'script_container' => 'ubuntu:16.04',
238238
]);
239+
240+
$script = <<<'EOF'
241+
#!/bin/bash
242+
# Garry's Mod Installation Script
243+
#
244+
# Server Files: /mnt/server
245+
apt -y update
246+
apt -y --no-install-recommends install curl lib32gcc1 ca-certificates
247+
248+
cd /tmp
249+
curl -sSL -o steamcmd.tar.gz http://media.steampowered.com/installer/steamcmd_linux.tar.gz
250+
251+
mkdir -p /mnt/server/steamcmd
252+
tar -xzvf steamcmd.tar.gz -C /mnt/server/steamcmd
253+
cd /mnt/server/steamcmd
254+
255+
# SteamCMD fails otherwise for some reason, even running as root.
256+
# This is changed at the end of the install process anyways.
257+
chown -R root:root /mnt
258+
259+
export HOME=/mnt/server
260+
./steamcmd.sh +login anonymous +force_install_dir /mnt/server +app_update 4020 +quit
261+
262+
mkdir -p /mnt/server/.steam/sdk32
263+
cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so
264+
EOF;
265+
266+
$this->option['gmod'] = ServiceOption::updateOrCreate([
267+
'service_id' => $this->service->id,
268+
'tag' => 'gmod',
269+
], [
270+
'name' => 'Garrys Mod',
271+
'description' => 'Garrys Mod, is a sandbox physics game created by Garry Newman, and developed by his company, Facepunch Studios.',
272+
'docker_image' => 'quay.io/pterodactyl/core:source',
273+
'config_startup' => '{"done": "VAC secure mode is activated.", "userInteraction": []}',
274+
'config_files' => null,
275+
'config_logs' => '{"custom": true, "location": "logs/latest.log"}',
276+
'config_stop' => 'quit',
277+
'config_from' => $this->option['source']->id,
278+
'startup' => './srcds_run -game garrysmod -console -port {{SERVER_PORT}} +ip 0.0.0.0 +map {{SRCDS_MAP}} -strictportbind -norestart +sv_setsteamaccount {{STEAM_ACC}}',
279+
'script_install' => $script,
280+
'script_entry' => 'bash',
281+
'script_container' => 'ubuntu:16.04',
282+
]);
239283
}
240284

241285
private function addVariables()
@@ -244,6 +288,7 @@ private function addVariables()
244288
$this->addTF2Variables();
245289
$this->addArkVariables();
246290
$this->addCSGOVariables();
291+
$this->addGMODVariables();
247292
$this->addCustomVariables();
248293
}
249294

@@ -391,6 +436,33 @@ private function addCSGOVariables()
391436
]);
392437
}
393438

439+
private function addGMODVariables()
440+
{
441+
ServiceVariable::updateOrCreate([
442+
'option_id' => $this->option['gmod']->id,
443+
'env_variable' => 'SRCDS_MAP',
444+
], [
445+
'name' => 'Map',
446+
'description' => 'The default map for the server.',
447+
'default_value' => 'gm_flatgrass',
448+
'user_viewable' => 1,
449+
'user_editable' => 1,
450+
'rules' => 'required|string|alpha_dash',
451+
]);
452+
453+
ServiceVariable::updateOrCreate([
454+
'option_id' => $this->option['gmod']->id,
455+
'env_variable' => 'STEAM_ACC',
456+
], [
457+
'name' => 'Steam Account Token',
458+
'description' => 'The Steam Account Token required for the server to be displayed publicly.',
459+
'default_value' => '',
460+
'user_viewable' => 1,
461+
'user_editable' => 1,
462+
'rules' => 'required|string|alpha_num|size:32',
463+
]);
464+
}
465+
394466
private function addCustomVariables()
395467
{
396468
ServiceVariable::updateOrCreate([

0 commit comments

Comments
 (0)