Installer: auto-create storage directory and seed settings/db files

This commit is contained in:
AudioCore Bot
2026-03-04 22:40:59 +00:00
parent 2e92b9f421
commit 89b4b1eefd

View File

@@ -700,7 +700,18 @@ class AdminController
. " 'pass' => '" . addslashes($dbPass) . "',\n" . " 'pass' => '" . addslashes($dbPass) . "',\n"
. " 'port' => " . (int)$dbPort . ",\n" . " 'port' => " . (int)$dbPort . ",\n"
. "];\n"; . "];\n";
$configPath = __DIR__ . '/../../storage/db.php'; $storageDir = __DIR__ . '/../../storage';
if (!is_dir($storageDir)) {
if (!@mkdir($storageDir, 0775, true) && !is_dir($storageDir)) {
return new Response('', 302, ['Location' => '/admin/installer?error=' . rawurlencode('Unable to create storage directory.')]);
}
}
$settingsPath = $storageDir . '/settings.php';
if (!is_file($settingsPath)) {
$settingsSeed = "<?php\nreturn [\n 'site_title' => 'AudioCore V1.5',\n];\n";
@file_put_contents($settingsPath, $settingsSeed);
}
$configPath = $storageDir . '/db.php';
if (file_put_contents($configPath, $config) === false) { if (file_put_contents($configPath, $config) === false) {
return new Response('', 302, ['Location' => '/admin/installer?error=' . rawurlencode('Unable to write DB config file.')]); return new Response('', 302, ['Location' => '/admin/installer?error=' . rawurlencode('Unable to write DB config file.')]);
} }