1.0.7
This commit is contained in:
+34
-19
@@ -206,6 +206,19 @@ if (in_array($mode, ['Fresh Install su Apache (LAMP tradizionale)', 'Restore da
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Web server user detection ─────────────────────────
|
||||||
|
$wwwUser = 'www-data';
|
||||||
|
$sudo = '';
|
||||||
|
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
||||||
|
$detected = trim(shell_exec('ps aux | grep -E "apache|httpd" | grep -v grep | head -1 | awk \'{print $1}\'') ?: '');
|
||||||
|
if ($detected !== '' && $detected !== 'root') {
|
||||||
|
$wwwUser = $detected;
|
||||||
|
}
|
||||||
|
if (function_exists('posix_getuid') && posix_getuid() === 0) {
|
||||||
|
$sudo = "sudo -u {$wwwUser} ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ══════════════════════════════════════════════════════
|
// ══════════════════════════════════════════════════════
|
||||||
// MODE 1: FRESH INSTALL APACHE
|
// MODE 1: FRESH INSTALL APACHE
|
||||||
// ══════════════════════════════════════════════════════
|
// ══════════════════════════════════════════════════════
|
||||||
@@ -251,7 +264,7 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// APP_KEY
|
// APP_KEY
|
||||||
runCapture("php artisan key:generate --force");
|
runCapture("{$sudo}php artisan key:generate --force");
|
||||||
ok('APP_KEY generata');
|
ok('APP_KEY generata');
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
@@ -332,7 +345,7 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
|
|||||||
println(color(' 3/7 — INSTALLAZIONE DIPENDENZE', 'yellow'));
|
println(color(' 3/7 — INSTALLAZIONE DIPENDENZE', 'yellow'));
|
||||||
println(color('══════════════════════════════════════════', 'yellow'));
|
println(color('══════════════════════════════════════════', 'yellow'));
|
||||||
|
|
||||||
run('composer install --no-dev --optimize-autoloader', 'Installazione dipendenze Composer...');
|
run("{$sudo}composer install --no-dev --optimize-autoloader", 'Installazione dipendenze Composer...');
|
||||||
ok('Dipendenze PHP installate');
|
ok('Dipendenze PHP installate');
|
||||||
|
|
||||||
// ── Step 4: Package discovery ────────────────────
|
// ── Step 4: Package discovery ────────────────────
|
||||||
@@ -341,7 +354,7 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
|
|||||||
println(color(' 4/7 — REGISTRAZIONE PACCHETTI', 'yellow'));
|
println(color(' 4/7 — REGISTRAZIONE PACCHETTI', 'yellow'));
|
||||||
println(color('══════════════════════════════════════════', 'yellow'));
|
println(color('══════════════════════════════════════════', 'yellow'));
|
||||||
|
|
||||||
runCapture("php artisan package:discover --ansi 2>/dev/null");
|
runCapture("{$sudo}php artisan package:discover --ansi 2>/dev/null");
|
||||||
ok('Pacchetti registrati');
|
ok('Pacchetti registrati');
|
||||||
|
|
||||||
// ── Step 5: Schema + Seed ────────────────────────
|
// ── Step 5: Schema + Seed ────────────────────────
|
||||||
@@ -362,13 +375,13 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// SQLite fallback: usa le migration (install.sql è solo per MySQL)
|
// SQLite fallback: usa le migration (install.sql è solo per MySQL)
|
||||||
if (!run('php artisan migrate --seed --force', 'Esecuzione migration e seed...')) {
|
if (!run("{$sudo}php artisan migrate --seed --force", 'Esecuzione migration e seed...')) {
|
||||||
fail('Migration fallita. Verifica la configurazione SQLite.');
|
fail('Migration fallita. Verifica la configurazione SQLite.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok('Database popolato con struttura e dati base');
|
ok('Database popolato con struttura e dati base');
|
||||||
|
|
||||||
runCapture('php artisan storage:link --force 2>/dev/null');
|
runCapture("{$sudo}php artisan storage:link --force 2>/dev/null");
|
||||||
|
|
||||||
// ── Step 6: Admin user (via PDO — no tinker) ─────
|
// ── Step 6: Admin user (via PDO — no tinker) ─────
|
||||||
println();
|
println();
|
||||||
@@ -385,12 +398,12 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
|
|||||||
} else {
|
} else {
|
||||||
// SQLite: usa seeder (l'admin verrà creato da DatabaseSeeder)
|
// SQLite: usa seeder (l'admin verrà creato da DatabaseSeeder)
|
||||||
// Poi aggiorna la password con quella scelta dall'utente
|
// Poi aggiorna la password con quella scelta dall'utente
|
||||||
runCapture("php artisan tinker --execute=" . escapeshellarg(
|
runCapture("{$sudo}php artisan tinker --execute=" . escapeshellarg(
|
||||||
"\$u = \App\Models\User::first(); " .
|
"\$u = \App\Models\User::first(); " .
|
||||||
"if (\$u) { " .
|
"if (\$u) { " .
|
||||||
"\$u->name = " . var_export($adminName, true) . "; " .
|
"\$u->name = " . var_export(\$adminName, true) . "; " .
|
||||||
"\$u->email = " . var_export($adminEmail, true) . "; " .
|
"\$u->email = " . var_export(\$adminEmail, true) . "; " .
|
||||||
"\$u->password = bcrypt(" . var_export($adminPass, true) . "); " .
|
"\$u->password = bcrypt(" . var_export(\$adminPass, true) . "); " .
|
||||||
"\$u->is_admin = true; " .
|
"\$u->is_admin = true; " .
|
||||||
"\$u->status = 'active'; " .
|
"\$u->status = 'active'; " .
|
||||||
"\$u->permissions = " . var_export([
|
"\$u->permissions = " . var_export([
|
||||||
@@ -406,6 +419,10 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
|
|||||||
ok("Amministratore {$adminEmail} configurato");
|
ok("Amministratore {$adminEmail} configurato");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear all caches after schema + admin creation
|
||||||
|
runCapture("{$sudo}php artisan optimize:clear 2>/dev/null");
|
||||||
|
ok('Cache ottimizzate');
|
||||||
|
|
||||||
// ── Step 7: Asset ────────────────────────────────
|
// ── Step 7: Asset ────────────────────────────────
|
||||||
println();
|
println();
|
||||||
println(color('══════════════════════════════════════════', 'yellow'));
|
println(color('══════════════════════════════════════════', 'yellow'));
|
||||||
@@ -414,8 +431,8 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
|
|||||||
|
|
||||||
$hasNpm = checkCmd('npm');
|
$hasNpm = checkCmd('npm');
|
||||||
if ($hasNpm && confirm('Compilare gli asset frontend con npm?')) {
|
if ($hasNpm && confirm('Compilare gli asset frontend con npm?')) {
|
||||||
run('npm install', 'Installazione dipendenze npm...');
|
run("{$sudo}npm install", 'Installazione dipendenze npm...');
|
||||||
run('npm run build', 'Compilazione asset...');
|
run("{$sudo}npm run build", 'Compilazione asset...');
|
||||||
ok('Asset compilati');
|
ok('Asset compilati');
|
||||||
} else {
|
} else {
|
||||||
if (!$hasNpm) warn('npm non disponibile — asset non compilati (AdminLTE via CDN)');
|
if (!$hasNpm) warn('npm non disponibile — asset non compilati (AdminLTE via CDN)');
|
||||||
@@ -425,7 +442,6 @@ if ($mode === 'Fresh Install su Apache (LAMP tradizionale)') {
|
|||||||
// ── Permissions ──────────────────────────────────
|
// ── Permissions ──────────────────────────────────
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
||||||
info('Impostazione permessi...');
|
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");
|
runCapture("chown -R {$wwwUser}:{$wwwUser} storage bootstrap/cache 2>/dev/null");
|
||||||
chmod("{$scriptDir}/storage", 0775);
|
chmod("{$scriptDir}/storage", 0775);
|
||||||
chmod("{$scriptDir}/bootstrap/cache", 0775);
|
chmod("{$scriptDir}/bootstrap/cache", 0775);
|
||||||
@@ -691,7 +707,7 @@ if ($mode === 'Restore da Backup (Apache)') {
|
|||||||
file_put_contents('.env', $dotenv);
|
file_put_contents('.env', $dotenv);
|
||||||
|
|
||||||
// Generate APP_KEY
|
// Generate APP_KEY
|
||||||
runCapture('php artisan key:generate --force');
|
runCapture("{$sudo}php artisan key:generate --force");
|
||||||
ok('APP_KEY rigenerata');
|
ok('APP_KEY rigenerata');
|
||||||
|
|
||||||
// Import database
|
// Import database
|
||||||
@@ -721,16 +737,15 @@ if ($mode === 'Restore da Backup (Apache)') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Composer
|
// Composer
|
||||||
run('composer install --no-dev --optimize-autoloader', 'Installazione dipendenze Composer...');
|
run("{$sudo}composer install --no-dev --optimize-autoloader", 'Installazione dipendenze Composer...');
|
||||||
runCapture('php artisan package:discover --ansi 2>/dev/null');
|
runCapture("{$sudo}php artisan package:discover --ansi 2>/dev/null");
|
||||||
|
|
||||||
// Storage link + cache
|
// Storage link + cache
|
||||||
runCapture('php artisan storage:link --force 2>/dev/null');
|
runCapture("{$sudo}php artisan storage:link --force 2>/dev/null");
|
||||||
runCapture('php artisan optimize:clear');
|
runCapture("{$sudo}php artisan optimize:clear");
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
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");
|
runCapture("chown -R {$wwwUser}:{$wwwUser} storage bootstrap/cache 2>/dev/null");
|
||||||
chmod("{$scriptDir}/storage", 0775);
|
chmod("{$scriptDir}/storage", 0775);
|
||||||
chmod("{$scriptDir}/bootstrap/cache", 0775);
|
chmod("{$scriptDir}/bootstrap/cache", 0775);
|
||||||
@@ -758,7 +773,7 @@ if ($mode === 'Restore da Backup (Apache)') {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// SQLite fallback: usa tinker
|
// SQLite fallback: usa tinker
|
||||||
$result = runCapture("php artisan tinker --execute=" . escapeshellarg(
|
$result = runCapture("{$sudo}php artisan tinker --execute=" . escapeshellarg(
|
||||||
"\$e = \App\Models\User::where('email', " . var_export($adminEmail, true) . ")->exists(); " .
|
"\$e = \App\Models\User::where('email', " . var_export($adminEmail, true) . ")->exists(); " .
|
||||||
"if (!\$e) { " .
|
"if (!\$e) { " .
|
||||||
"\$u = new \App\Models\User; " .
|
"\$u = new \App\Models\User; " .
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?php $__env->startSection('title', __('Page Expired')); ?>
|
||||||
|
<?php $__env->startSection('code', '419'); ?>
|
||||||
|
<?php $__env->startSection('message', __('Page Expired')); ?>
|
||||||
|
|
||||||
|
<?php echo $__env->make('errors::minimal', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/glastree/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/views/419.blade.php ENDPATH**/ ?>
|
||||||
Reference in New Issue
Block a user