You've already forked Atomcms-edit
Nitro V3 update: CLI-only (Linux), settings via .env
- Moved Nitro V3 update from web UI (Commandocentrum) to CLI-only - Removed configure paths form and runUpdateNitrov3() from admin panel - update-Nitrov3.sh now loads .env automatically from its directory - Added all NITRO_* env vars to .env.example.linux and .env - Removed configurable paths from database (replaced by .env) - Updated README and CHANGELOG
This commit is contained in:
@@ -228,68 +228,10 @@ final class Commandocentrum extends Page implements HasForms
|
||||
Section::make(__('commandocentrum.nitro_update'))
|
||||
->description(__('commandocentrum.nitro_update_desc'))
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->afterHeader([
|
||||
Action::make('configure_nitro')
|
||||
->label(__('commandocentrum.configure_nitro'))
|
||||
->icon('heroicon-o-cog-6-tooth')
|
||||
->color('primary')
|
||||
->form([
|
||||
\Filament\Forms\Components\TextInput::make('nitro_emulator_path')
|
||||
->label(__('commandocentrum.nitro_emulator_path'))
|
||||
->default(fn () => $this->getSetting('nitro_emulator_path', '/var/www/emulator')),
|
||||
\Filament\Forms\Components\TextInput::make('nitro_emulator_service')
|
||||
->label(__('commandocentrum.nitro_emulator_service'))
|
||||
->default(fn () => $this->getSetting('nitro_emulator_service', 'emulator')),
|
||||
\Filament\Forms\Components\TextInput::make('nitro_db_name')
|
||||
->label(__('commandocentrum.nitro_db_name'))
|
||||
->default(fn () => $this->getSetting('nitro_db_name', 'habbo')),
|
||||
\Filament\Forms\Components\TextInput::make('nitro_sql_dir')
|
||||
->label(__('commandocentrum.nitro_sql_dir'))
|
||||
->default(fn () => $this->getSetting('nitro_sql_dir', '/var/www/emulator/Database Updates')),
|
||||
\Filament\Forms\Components\TextInput::make('nitro_backup_dir')
|
||||
->label(__('commandocentrum.nitro_backup_dir'))
|
||||
->default(fn () => $this->getSetting('nitro_backup_dir', '/var/www/emulator/Database Updates/backups')),
|
||||
\Filament\Forms\Components\TextInput::make('nitro_gamedata_dir')
|
||||
->label(__('commandocentrum.nitro_gamedata_dir'))
|
||||
->default(fn () => $this->getSetting('nitro_gamedata_dir', '/var/www/Gamedata/config')),
|
||||
\Filament\Forms\Components\TextInput::make('nitro_client_dir')
|
||||
->label(__('commandocentrum.nitro_client_dir'))
|
||||
->default(fn () => $this->getSetting('nitro_client_dir', '/var/www/Nitro-V3/public/configuration')),
|
||||
\Filament\Forms\Components\TextInput::make('nitro_client_src')
|
||||
->label(__('commandocentrum.nitro_client_src'))
|
||||
->default(fn () => $this->getSetting('nitro_client_src', '/var/www/Nitro-V3')),
|
||||
\Filament\Forms\Components\TextInput::make('nitro_renderer_src')
|
||||
->label(__('commandocentrum.nitro_renderer_src'))
|
||||
->default(fn () => $this->getSetting('nitro_renderer_src', '/var/www/Nitro_Render_V3')),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$settings = app(SettingsService::class);
|
||||
$settings->set('nitro_emulator_path', $data['nitro_emulator_path'] ?? '/var/www/emulator');
|
||||
$settings->set('nitro_emulator_service', $data['nitro_emulator_service'] ?? 'emulator');
|
||||
$settings->set('nitro_db_name', $data['nitro_db_name'] ?? 'habbo');
|
||||
$settings->set('nitro_sql_dir', $data['nitro_sql_dir'] ?? '/var/www/emulator/Database Updates');
|
||||
$settings->set('nitro_backup_dir', $data['nitro_backup_dir'] ?? '/var/www/emulator/Database Updates/backups');
|
||||
$settings->set('nitro_gamedata_dir', $data['nitro_gamedata_dir'] ?? '/var/www/Gamedata/config');
|
||||
$settings->set('nitro_client_dir', $data['nitro_client_dir'] ?? '/var/www/Nitro-V3/public/configuration');
|
||||
$settings->set('nitro_client_src', $data['nitro_client_src'] ?? '/var/www/Nitro-V3');
|
||||
$settings->set('nitro_renderer_src', $data['nitro_renderer_src'] ?? '/var/www/Nitro_Render_V3');
|
||||
$this->fillForm();
|
||||
Notification::make()
|
||||
->title(__('commandocentrum.success'))
|
||||
->body(__('commandocentrum.nitro_config_saved'))
|
||||
->color('success')
|
||||
->send();
|
||||
}),
|
||||
Action::make('run_nitro_update')
|
||||
->label(__('commandocentrum.run_update'))
|
||||
->icon('heroicon-o-play')
|
||||
->color('success')
|
||||
->action('runUpdateNitrov3'),
|
||||
])
|
||||
->schema([
|
||||
Placeholder::make('nitro_config_summary')
|
||||
Placeholder::make('nitro_cli_only')
|
||||
->label('')
|
||||
->content(fn () => view('filament.components.commandocentrum.nitro-config-summary')),
|
||||
->content(__('commandocentrum.nitro_cli_only')),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.clothing_sync'))
|
||||
@@ -735,64 +677,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
}
|
||||
}
|
||||
|
||||
public function runUpdateNitrov3(): void
|
||||
{
|
||||
try {
|
||||
$scriptPath = base_path('update-Nitrov3.sh');
|
||||
|
||||
if (! $this->fileExists($scriptPath)) {
|
||||
$this->notify(__('commandocentrum.error'), 'Script niet gevonden: ' . $scriptPath, 'danger');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$dbHost = config('database.connections.mysql.host', '127.0.0.1');
|
||||
$dbPort = config('database.connections.mysql.port', '3306');
|
||||
$dbUser = config('database.connections.mysql.username', 'root');
|
||||
$dbPass = config('database.connections.mysql.password', '');
|
||||
|
||||
$env = [
|
||||
'NITRO_EMULATOR_PATH' => $this->data['nitro_emulator_path'] ?? '/var/www/emulator',
|
||||
'NITRO_EMULATOR_SERVICE' => $this->data['nitro_emulator_service'] ?? 'emulator',
|
||||
'NITRO_DB_NAME' => $this->data['nitro_db_name'] ?? 'habbo',
|
||||
'NITRO_DB_HOST' => $dbHost,
|
||||
'NITRO_DB_PORT' => $dbPort,
|
||||
'NITRO_DB_USER' => $dbUser,
|
||||
'NITRO_DB_PASS' => $dbPass,
|
||||
'NITRO_SQL_DIR' => $this->data['nitro_sql_dir'] ?? '/var/www/emulator/Database Updates',
|
||||
'NITRO_BACKUP_DIR' => $this->data['nitro_backup_dir'] ?? '/var/www/emulator/Database Updates/backups',
|
||||
'NITRO_GAMEDATA_DIR' => $this->data['nitro_gamedata_dir'] ?? '/var/www/Gamedata/config',
|
||||
'NITRO_CLIENT_DIR' => $this->data['nitro_client_dir'] ?? '/var/www/Nitro-V3/public/configuration',
|
||||
'NITRO_CLIENT_SRC' => $this->data['nitro_client_src'] ?? '/var/www/Nitro-V3',
|
||||
'NITRO_RENDERER_SRC' => $this->data['nitro_renderer_src'] ?? '/var/www/Nitro_Render_V3',
|
||||
];
|
||||
|
||||
$envExport = '';
|
||||
foreach ($env as $key => $value) {
|
||||
$envExport .= 'export ' . $key . '=' . escapeshellarg($value) . '; ';
|
||||
}
|
||||
|
||||
$result = Process::timeout(600)->run($envExport . 'bash ' . escapeshellarg($scriptPath) . ' 2>&1');
|
||||
$output = $result->output();
|
||||
$exitCode = $result->exitCode();
|
||||
|
||||
$title = $exitCode === 0 ? __('commandocentrum.success') : __('commandocentrum.error');
|
||||
$color = $exitCode === 0 ? 'success' : 'danger';
|
||||
$message = $exitCode === 0 ? '✅ Nitro V3 update voltooid' : '⚠️ Script fout (exit code ' . $exitCode . ')';
|
||||
|
||||
$this->notify($title, $message, $color);
|
||||
|
||||
Notification::make()
|
||||
->title(__('commandocentrum.nitro_update_output'))
|
||||
->body('<pre style="max-height:300px;overflow:auto;font-size:12px;background:#1e293b;color:#e2e8f0;padding:12px;border-radius:8px;">' . e($output) . '</pre>')
|
||||
->color($color)
|
||||
->persistent()
|
||||
->send();
|
||||
} catch (Exception $e) {
|
||||
$this->notify(__('commandocentrum.error'), $e->getMessage(), 'danger');
|
||||
}
|
||||
}
|
||||
|
||||
public function saveEmulator(): void
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user