feat: harden updater layout sync, patching, backups, and apache checks
Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/93d8a20b-c675-4542-8c4d-667a576f7483 Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
ced5c54d3f
commit
7af4383397
7 changed files with 1635 additions and 1297 deletions
36
Panel/modules/update/patches/001_layout_bootstrap.php
Normal file
36
Panel/modules/update/patches/001_layout_bootstrap.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
if (!function_exists('gsp_patch_001_layout_bootstrap')) {
|
||||
function gsp_patch_001_layout_bootstrap($context)
|
||||
{
|
||||
$created = [];
|
||||
$targets = [
|
||||
!empty($context['root_dir']) ? $context['root_dir'] . '/logs' : null,
|
||||
!empty($context['root_dir']) ? $context['root_dir'] . '/backups' : null,
|
||||
!empty($context['root_dir']) ? $context['root_dir'] . '/examples' : null,
|
||||
!empty($context['panel_dir']) ? $context['panel_dir'] : null,
|
||||
!empty($context['website_dir']) ? $context['website_dir'] : null,
|
||||
];
|
||||
foreach ($targets as $dir) {
|
||||
if (empty($dir)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_dir($dir)) {
|
||||
if (!@mkdir($dir, 0755, true) && !is_dir($dir)) {
|
||||
return ['success' => false, 'details' => 'Failed to create directory: ' . $dir];
|
||||
}
|
||||
$created[] = $dir;
|
||||
}
|
||||
}
|
||||
$details = empty($created)
|
||||
? 'Layout already in expected state.'
|
||||
: 'Created directories: ' . implode(', ', $created);
|
||||
return ['success' => true, 'details' => $details];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => '001_layout_bootstrap',
|
||||
'title' => 'Ensure baseline GSP root directories exist',
|
||||
'runner' => 'gsp_patch_001_layout_bootstrap',
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue