Skip to content

Commit d67f65b

Browse files
committed
Attempt to properly handle new start lines on servers for migration
1 parent 63029bb commit d67f65b

File tree

3 files changed

+54
-38
lines changed

3 files changed

+54
-38
lines changed

database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,29 @@ class DeleteServiceExecutableOption extends Migration
1313
*/
1414
public function up()
1515
{
16-
Schema::table('services', function (Blueprint $table) {
17-
$table->dropColumn('executable');
18-
$table->renameColumn('file', 'folder');
19-
$table->text('description')->nullable()->change();
20-
$table->text('startup')->nullable()->change();
16+
DB::transaction(function () {
17+
Schema::table('services', function (Blueprint $table) {
18+
$table->renameColumn('file', 'folder');
19+
$table->text('description')->nullable()->change();
20+
$table->text('startup')->nullable()->change();
21+
});
22+
23+
// Attempt to fix any startup commands for servers
24+
// that we possibly can.
25+
foreach (ServiceOption::with('servers')->get() as $option) {
26+
$option->servers->each(function ($s) use ($option) {
27+
$prepend = $option->display_executable;
28+
$prepend = ($prepend === './ShooterGameServer') ? './ShooterGame/Binaries/Linux/ShooterGameServer' : $prepend;
29+
$prepend = ($prepend === 'TerrariaServer.exe') ? 'mono TerrariaServer.exe' : $prepend;
30+
31+
$s->startup = $prepend . ' ' . $s->startup;
32+
$s->save();
33+
});
34+
}
35+
36+
Schema::table('services', function (Blueprint $table) {
37+
$table->dropColumn('executable');
38+
});
2139
});
2240
}
2341

database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@ class AddNewServiceOptionsColumns extends Migration
1313
*/
1414
public function up()
1515
{
16-
DB::transaction(function () {
17-
Schema::table('service_options', function (Blueprint $table) {
18-
$table->dropColumn('executable');
16+
Schema::table('service_options', function (Blueprint $table) {
17+
$table->dropColumn('executable');
1918

20-
$table->unsignedInteger('config_from')->nullable()->after('docker_image');
21-
$table->string('config_stop')->nullable()->after('docker_image');
22-
$table->text('config_logs')->nullable()->after('docker_image');
23-
$table->text('config_startup')->nullable()->after('docker_image');
24-
$table->text('config_files')->nullable()->after('docker_image');
19+
$table->unsignedInteger('config_from')->nullable()->after('docker_image');
20+
$table->string('config_stop')->nullable()->after('docker_image');
21+
$table->text('config_logs')->nullable()->after('docker_image');
22+
$table->text('config_startup')->nullable()->after('docker_image');
23+
$table->text('config_files')->nullable()->after('docker_image');
2524

26-
$table->foreign('config_from')->references('id')->on('service_options');
27-
});
25+
$table->foreign('config_from')->references('id')->on('service_options');
2826
});
2927
}
3028

@@ -35,18 +33,16 @@ public function up()
3533
*/
3634
public function down()
3735
{
38-
DB::transaction(function () {
39-
Schema::table('service_options', function (Blueprint $table) {
40-
$table->dropForeign('config_from');
36+
Schema::table('service_options', function (Blueprint $table) {
37+
$table->dropForeign('config_from');
4138

42-
$table->dropColumn('config_from');
43-
$table->dropColumn('config_stop');
44-
$table->dropColumn('config_logs');
45-
$table->dropColumn('config_startup');
46-
$table->dropColumn('config_files');
39+
$table->dropColumn('config_from');
40+
$table->dropColumn('config_stop');
41+
$table->dropColumn('config_logs');
42+
$table->dropColumn('config_startup');
43+
$table->dropColumn('config_files');
4744

48-
$table->string('executable')->after('docker_image')->nullable();
49-
});
45+
$table->string('executable')->after('docker_image')->nullable();
5046
});
5147
}
5248
}

database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@ class MigrateToNewServiceSystem extends Migration
3434
*/
3535
public function up()
3636
{
37-
$service = Service::where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first();
38-
if (! $service) {
39-
return;
40-
}
41-
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';
37+
DB::transaction(function () {
38+
$service = Service::where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first();
39+
if (! $service) {
40+
return;
5041
}
42+
43+
$options = ServiceOption::where('service_id', $service->id)->get();
44+
$options->each(function ($item) use ($options) {
45+
if ($item->tag === 'srcds' && $item->name === 'Insurgency') {
46+
$item->tag = 'insurgency';
47+
} elseif ($item->tag === 'srcds' && $item->name === 'Team Fortress 2') {
48+
$item->tag = 'tf2';
49+
} elseif ($item->tag === 'srcds' && $item->name === 'Custom Source Engine Game') {
50+
$item->tag = 'source';
51+
}
52+
});
5153
});
5254
}
5355

0 commit comments

Comments
 (0)