You've already forked Atomcms-edit
Nitro V3 Update: configureerbare paths via Commandocentrum + sudoers fix
This commit is contained in:
@@ -104,6 +104,15 @@ final class Commandocentrum extends Page implements HasForms
|
||||
'emulator_database_username' => $this->getSetting('emulator_database_username', ''),
|
||||
'emulator_database_password' => $this->getSetting('emulator_database_password', ''),
|
||||
'emulator_version' => $this->getSetting('emulator_version', 'Onbekend'),
|
||||
'nitro_emulator_path' => $this->getSetting('nitro_emulator_path', '/var/www/emulator'),
|
||||
'nitro_emulator_service' => $this->getSetting('nitro_emulator_service', 'emulator'),
|
||||
'nitro_db_name' => $this->getSetting('nitro_db_name', 'habbo'),
|
||||
'nitro_sql_dir' => $this->getSetting('nitro_sql_dir', '/var/www/emulator/Database Updates'),
|
||||
'nitro_backup_dir' => $this->getSetting('nitro_backup_dir', '/var/www/emulator/Database Updates/backups'),
|
||||
'nitro_gamedata_dir' => $this->getSetting('nitro_gamedata_dir', '/var/www/Gamedata/config'),
|
||||
'nitro_client_dir' => $this->getSetting('nitro_client_dir', '/var/www/Nitro-V3/public/configuration'),
|
||||
'nitro_client_src' => $this->getSetting('nitro_client_src', '/var/www/Nitro-V3'),
|
||||
'nitro_renderer_src' => $this->getSetting('nitro_renderer_src', '/var/www/Nitro_Render_V3'),
|
||||
'hotel_alert_message' => '',
|
||||
];
|
||||
}
|
||||
@@ -216,6 +225,73 @@ final class Commandocentrum extends Page implements HasForms
|
||||
->content(fn () => $this->renderEmulatorInfoView()),
|
||||
]),
|
||||
|
||||
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')
|
||||
->label('')
|
||||
->content(fn () => view('filament.components.commandocentrum.nitro-config-summary')),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.clothing_sync'))
|
||||
->description(__('commandocentrum.clothing_sync_desc'))
|
||||
->icon('heroicon-o-user')
|
||||
@@ -659,6 +735,64 @@ 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