48 lines
1.3 KiB
PHP
Executable File
48 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
class FixStoragePermissions extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'fix:storage-permissions';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Fix permissions for the storage/logs directory';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
try {
|
|
// Esegui i comandi di shell
|
|
exec('sudo chown -R debian:www-data /var/www/html/apimacro/storage/logs', $output, $returnVar);
|
|
exec('sudo chmod -R 775 /var/www/html/apimacro/storage/logs', $output, $returnVar);
|
|
|
|
// Controlla se ci sono stati errori
|
|
if ($returnVar !== 0) {
|
|
$this->error('Errore nel fix dei permessi.');
|
|
return 1; // Codice di errore
|
|
}
|
|
|
|
$this->info('Permessi del storage/logs aggiornati con successo.');
|
|
return 0; // Codice di successo
|
|
} catch (\Exception $e) {
|
|
$this->error('Errore durante l\'aggiornamento dei permessi: ' . $e->getMessage());
|
|
}
|
|
}
|
|
}
|