1.0.5 fix first login after install .php

This commit is contained in:
2026-06-03 11:59:44 +02:00
parent 25168debc0
commit fcbb6fb061
13 changed files with 191 additions and 70 deletions
+27 -10
View File
@@ -292,7 +292,7 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
println(color(' 4/7 — REGISTRAZIONE PACCHETTI', 'yellow'));
println(color('══════════════════════════════════════════', 'yellow'));
runCapture("php artisan package:discover --ansi 2>/dev/null");
runCapture("php artisan package:discover --ansi");
ok('Pacchetti registrati');
// ── Step 5: Migration + Seed ─────────────────────
@@ -306,7 +306,7 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
}
ok('Struttura database creata e dati di base inseriti');
runCapture('php artisan storage:link --force 2>/dev/null');
runCapture('php artisan storage:link --force');
// ── Step 6: Admin user ───────────────────────────
println();
@@ -320,11 +320,14 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
\$u->name = '{$adminName}';
\$u->email = '{$adminEmail}';
\$u->password = bcrypt('{$adminPass}');
\$u->is_admin = true;
\$u->status = 'active';
\$u->permissions = ['individui' => 2, 'gruppi' => 2, 'eventi' => 2, 'documenti' => 2, 'mailing' => 2, 'viste' => 2, 'report' => 2, 'settings' => 2];
\$u->save();
echo "OK: " . \$u->id;
PHP;
$result = runCapture("php artisan tinker --execute=" . escapeshellarg($tinkerScript) . " 2>/dev/null");
$result = runCapture("php artisan tinker --execute=" . escapeshellarg($tinkerScript));
if (str_contains($result, 'OK:')) {
ok("Amministratore {$adminEmail} creato");
} else {
@@ -351,9 +354,17 @@ PHP;
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
info('Impostazione permessi...');
$wwwUser = trim(shell_exec('ps aux | grep -E "apache|httpd" | grep -v grep | head -1 | awk \'{print \$1}\'') ?: 'www-data');
runCapture("chown -R {$wwwUser}:{$wwwUser} storage bootstrap/cache 2>/dev/null");
run("chown -R {$wwwUser}:{$wwwUser} storage bootstrap/cache", 'Proprietà file (chown)');
chmod("{$scriptDir}/storage", 0775);
chmod("{$scriptDir}/bootstrap/cache", 0775);
// Verifica permessi sessione (causa comune di errori 419)
$sessionDir = "{$scriptDir}/storage/framework/sessions";
if (is_dir($sessionDir) && !is_writable($sessionDir)) {
warn("{$sessionDir} non è scrivibile — possibile errore 419 (CSRF) al login");
chmod($sessionDir, 0775);
}
ok("Permessi impostati (utente: {$wwwUser})");
}
@@ -447,11 +458,14 @@ if ($mode === 'Fresh Install via Docker') {
\$u->name = '{$adminName}';
\$u->email = '{$adminEmail}';
\$u->password = bcrypt('{$adminPass}');
\$u->is_admin = true;
\$u->status = 'active';
\$u->permissions = ['individui' => 2, 'gruppi' => 2, 'eventi' => 2, 'documenti' => 2, 'mailing' => 2, 'viste' => 2, 'report' => 2, 'settings' => 2];
\$u->save();
echo "OK: " . \$u->id;
PHP;
$result = runCapture(
"docker exec -i {$containerId} php artisan tinker --execute=" . escapeshellarg($tinkerScript) . " 2>/dev/null"
"docker exec -i {$containerId} php artisan tinker --execute=" . escapeshellarg($tinkerScript)
);
if (str_contains($result, 'OK:')) {
ok("Amministratore {$adminEmail} creato nel container");
@@ -579,22 +593,22 @@ if ($mode === 'Restore da Backup (Apache)') {
$storageBackup = "{$tmpDir}/storage";
if (is_dir($storageBackup)) {
info('Ripristino file storage...');
runCapture("cp -r {$storageBackup}/* {$scriptDir}/storage/ 2>/dev/null");
run("cp -r {$storageBackup}/* {$scriptDir}/storage/", null);
ok('Storage ripristinato');
}
// Composer
run('composer install --no-dev --optimize-autoloader', 'Installazione dipendenze Composer...');
runCapture('php artisan package:discover --ansi 2>/dev/null');
runCapture('php artisan package:discover --ansi');
// Storage link + cache
runCapture('php artisan storage:link --force 2>/dev/null');
runCapture('php artisan storage:link --force');
runCapture('php artisan optimize:clear');
// Permissions
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
$wwwUser = trim(shell_exec('ps aux | grep -E "apache|httpd" | grep -v grep | head -1 | awk \'{print \$1}\'') ?: 'www-data');
runCapture("chown -R {$wwwUser}:{$wwwUser} storage bootstrap/cache 2>/dev/null");
run("chown -R {$wwwUser}:{$wwwUser} storage bootstrap/cache", 'Proprietà file (chown)');
chmod("{$scriptDir}/storage", 0775);
chmod("{$scriptDir}/bootstrap/cache", 0775);
ok("Permessi impostati (utente: {$wwwUser})");
@@ -608,13 +622,16 @@ if ($mode === 'Restore da Backup (Apache)') {
\$u->name = '{$adminName}';
\$u->email = '{$adminEmail}';
\$u->password = bcrypt('{$adminPass}');
\$u->is_admin = true;
\$u->status = 'active';
\$u->permissions = ['individui' => 2, 'gruppi' => 2, 'eventi' => 2, 'documenti' => 2, 'mailing' => 2, 'viste' => 2, 'report' => 2, 'settings' => 2];
\$u->save();
echo 'OK';
} else {
echo 'EXISTS';
}
PHP;
$result = runCapture("php artisan tinker --execute=" . escapeshellarg($tinkerScript) . " 2>/dev/null");
$result = runCapture("php artisan tinker --execute=" . escapeshellarg($tinkerScript));
if (str_contains($result, 'OK')) {
ok("Amministratore {$adminEmail} creato");
} elseif (str_contains($result, 'EXISTS')) {