Add auth stack conf vars and storage mode selection to setup wizard
host.conf.template: add AUTH STACK section (NPM/lldap/Authelia) so conf_upgrade.sh stops stripping those keys from host*.conf at 1am. setup wizard: storage mode selector auto-detects USB vs NVMe at first run; user can override; triggers storage_migrate.sh when mode differs from current SCRIPTS_DIR location. claude_startup.sh: reads HOST*_STORAGE_MODE_INTERNAL to pick internal or appdata path rather than always requiring array to be mounted.
This commit is contained in:
+22
-10
@@ -215,18 +215,25 @@ $hostId = strtoupper($mySlot);
|
||||
$hostIdLow = strtolower($mySlot);
|
||||
$confFile = $hostIdLow . '.conf';
|
||||
|
||||
// Storage mode: use wizard selection, fall back to auto-detect from boot transport
|
||||
$smParam = trim($_POST['storage_mode'] ?? '');
|
||||
if ($smParam === 'flash') {
|
||||
$storageInternal = 'false';
|
||||
} elseif ($smParam === 'internal') {
|
||||
$storageInternal = 'true';
|
||||
} else {
|
||||
$bootPart = trim(shell_exec('findmnt -n -o SOURCE /boot 2>/dev/null') ?: '');
|
||||
$bootDisk = $bootPart ? trim(shell_exec('lsblk -no pkname ' . escapeshellarg($bootPart) . ' 2>/dev/null') ?: '') : '';
|
||||
$transport = $bootDisk ? strtolower(trim(shell_exec('lsblk -dno TRAN /dev/' . escapeshellarg($bootDisk) . ' 2>/dev/null') ?: '')) : '';
|
||||
$storageInternal = ($transport !== 'usb') ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if (!file_exists(CONF_DIR . '/' . $confFile)) {
|
||||
$template = @file_get_contents(CONF_DIR . '/host.conf.template') ?: '';
|
||||
if ($template) {
|
||||
$sshOwner = strtolower(preg_replace('/^unraid-/i', '', $myHostname));
|
||||
$sshKeyPath = '/root/.ssh/' . $sshOwner . '_rsync_automation';
|
||||
|
||||
// Auto-detect storage mode from boot device transport
|
||||
$bootPart = trim(shell_exec('findmnt -n -o SOURCE /boot 2>/dev/null') ?: '');
|
||||
$bootDisk = $bootPart ? trim(shell_exec('lsblk -no pkname ' . escapeshellarg($bootPart) . ' 2>/dev/null') ?: '') : '';
|
||||
$transport = $bootDisk ? strtolower(trim(shell_exec('lsblk -dno TRAN /dev/' . escapeshellarg($bootDisk) . ' 2>/dev/null') ?: '')) : '';
|
||||
$storageInternal = ($transport !== 'usb') ? 'true' : 'false';
|
||||
|
||||
$conf = str_replace('HOSTN', $hostId, $template);
|
||||
$conf = str_replace('hostn', $hostIdLow, $conf);
|
||||
$conf = preg_replace('/^(\s*' . $hostId . '_SSH_KEY\s*=\s*)""/m',
|
||||
@@ -251,9 +258,14 @@ if (file_exists($sshScript)) {
|
||||
// Auto-create Unraid API key and write into the fresh conf
|
||||
$apiKeyResult = vv_auto_create_api_key($hostId, $confFile);
|
||||
|
||||
$targetDir = ($storageInternal === 'true') ? '/boot/config/plugins/varaverk' : '/mnt/user/appdata/Varaverk';
|
||||
$needsMigration = (defined('SCRIPTS_DIR') && SCRIPTS_DIR !== $targetDir);
|
||||
|
||||
echo json_encode([
|
||||
'ok' => true,
|
||||
'host_id' => $hostId,
|
||||
'api_key' => $apiKeyResult,
|
||||
'redirect' => '?tab=scheduler&vv_setup=master.conf',
|
||||
'ok' => true,
|
||||
'host_id' => $hostId,
|
||||
'api_key' => $apiKeyResult,
|
||||
'needs_migration'=> $needsMigration,
|
||||
'migrate_to' => $needsMigration ? ($storageInternal === 'true' ? 'internal' : 'flash') : null,
|
||||
'redirect' => '?tab=scheduler&vv_setup=master.conf',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user