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:
root
2026-06-06 14:11:50 +02:00
parent 2ac1264b93
commit ea2160132a
7 changed files with 59 additions and 175 deletions
+15 -6
View File
@@ -70,6 +70,21 @@ RCON_PORT=3001
EMULATOR_IP=127.0.0.1
EMULATOR_PORT=3000
# --- NITRO UPDATE (for update-Nitrov3.sh) ---
NITRO_EMULATOR_PATH=/var/www/emulator
NITRO_EMULATOR_SERVICE=emulator
NITRO_DB_HOST=127.0.0.1
NITRO_DB_PORT=3306
NITRO_DB_NAME=habbo
NITRO_DB_USER=root
NITRO_DB_PASS=
NITRO_SQL_DIR=/var/www/emulator/Database Updates
NITRO_BACKUP_DIR=/var/www/emulator/Database Updates/backups
NITRO_GAMEDATA_DIR=/var/www/Gamedata/config
NITRO_CLIENT_DIR=/var/www/Nitro-V3/public/configuration
NITRO_CLIENT_SRC=/var/www/Nitro-V3
NITRO_RENDERER_SRC=/var/www/Nitro_Render_V3
# --- CORS ---
CORS_ALLOWED_ORIGINS=https://yourhotel.nl,https://www.yourhotel.nl,http://localhost:3000
@@ -78,9 +93,3 @@ APP_LOCALE=nl
FORCE_HTTPS=true
PASSWORD_RESET_TOKEN_TIME=15
# --- NITRO PATHS ---
NITRO_CLIENT_PATH=/var/www/Nitro-V3
NITRO_RENDERER_PATH=/var/www/Nitro_Render_V3
NITRO_BUILD_PATH=/var/www/Nitro-V3/dist
NITRO_WEBROOT=/Client
GAMEDATA_PATH=/var/www/Gamedata
+3
View File
@@ -23,6 +23,9 @@
- XAMPP support removed (security warning added)
- `.env.example``.env.install` with step-by-step guide
- `.env.standard``.env.example.linux` + `.env.example.windows`
- Nitro V3 update moved from web UI to CLI (Linux-only)
- Nitro V3 settings moved from database to `.env` file
- `update-Nitrov3.sh` now loads `.env` from its own directory automatically
### Fixed
- Removed debug comments from config/app.php
+27 -34
View File
@@ -13,9 +13,9 @@ A modern Habbo retro CMS powered by Laravel 13, Filament 5, React 19, and Nitro.
| Feature | Description |
|---------|-------------|
| **Commandocentrum** | Central admin dashboard with one-click Nitro V3 updater |
| **Nitro V3 Update System** | Auto-update emulator, Nitro client & renderer from the HK |
| **Configurable Paths** | 9 paths fully adjustable via HK UI (no SSH needed) |
| **Commandocentrum** | Central admin dashboard with Nitro, emulator & hotel monitoring |
| **Nitro V3 Update System** | Auto-update emulator, Nitro client & renderer via CLI (Linux `.env`) |
| **Configurable Paths** | 13 paths fully adjustable via `.env` (no database needed) |
| **Emulator Control** | Start, stop, restart & check status from the admin panel |
| **Live Monitoring** | Online users, emulator status, DB status, server load, diagnostics |
| **Hotel Alerts** | Send messages to all online users in real-time |
@@ -63,44 +63,37 @@ yarn install && yarn build:all
---
## Nitro V3 Update
## Nitro V3 Update (Linux-only)
One-click update from **Commandocentrum** → "Configureer Paths" → "Run Update".
> ⚠️ **CLI only.** The web UI button has been removed. The script is configured via `.env` variables.
**What it does:** `git pull` emulator → DB backup → SQL imports → Maven build → `git pull` Nitro_Render_V3 + Nitro-V3 → `yarn build` → sync Gamedata → cleanup → restart emulator.
**Configurable paths** (9 settings, stored in DB):
| Setting | Default |
|---------|---------|
| Emulator map | `/var/www/emulator` |
| Service naam | `emulator` |
| Database | `habbo` |
| SQL updates | `{emulator}/Database Updates` |
| Backups | `{emulator}/Database Updates/backups` |
| Gamedata | `/var/www/Gamedata/config` |
| Nitro client | `{nitro}/public/configuration` |
| Nitro-V3 bron | `/var/www/Nitro-V3` |
| Nitro Render V3 | `/var/www/Nitro_Render_V3` |
**Sudoers** passwordless `systemctl` + `chown` for the web UI:
> ✅ **Completely safe.** Each command is pinned to a specific binary and (where possible) a specific path. The web user (`www-data`) cannot run arbitrary shell commands — only these exact operations. No shell, no arbitrary binary, no risk.
**Usage:**
```bash
sudo tee /etc/sudoers.d/www-data << 'EOF'
www-data ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart emulator
www-data ALL=(ALL) NOPASSWD: /usr/bin/systemctl status emulator
www-data ALL=(ALL) NOPASSWD: /usr/bin/chown -R www-data\:www-data /var/www/*
EOF
sudo chmod 440 /etc/sudoers.d/www-data
# Make sure .env contains all NITRO_* variables (see .env.example.linux)
cd /var/www/atomcms
bash update-Nitrov3.sh
```
| Entry | Why it's needed |
|-------|----------------|
| `systemctl restart emulator` | One-click emulator restart from the admin panel |
| `systemctl status emulator` | Live emulator status in the dashboard |
| `chown -R www-data:www-data /var/www/*` | Fix permissions after the updater clones/builds files as root |
**Configurable via `.env`:**
| Variable | Default | Description |
|----------|---------|-------------|
| `NITRO_EMULATOR_PATH` | `/var/www/emulator` | Emulator root directory |
| `NITRO_EMULATOR_SERVICE` | `emulator` | Systemd service name |
| `NITRO_DB_HOST` | `127.0.0.1` | Database host |
| `NITRO_DB_PORT` | `3306` | Database port |
| `NITRO_DB_NAME` | `habbo` | Database name |
| `NITRO_DB_USER` | `root` | Database user |
| `NITRO_DB_PASS` | — | Database password |
| `NITRO_SQL_DIR` | `{emulator}/Database Updates` | SQL updates directory |
| `NITRO_BACKUP_DIR` | `{emulator}/Database Updates/backups` | Backup directory |
| `NITRO_GAMEDATA_DIR` | `/var/www/Gamedata/config` | Gamedata config directory |
| `NITRO_CLIENT_DIR` | `{nitro}/public/configuration` | Nitro client config directory |
| `NITRO_CLIENT_SRC` | `/var/www/Nitro-V3` | Nitro-V3 source directory |
| `NITRO_RENDERER_SRC` | `/var/www/Nitro_Render_V3` | Nitro Render V3 source directory |
---
@@ -188,7 +181,7 @@ yarn build:all
sudo chown -R www-data:www-data storage bootstrap/cache public/build
sudo chmod -R 775 storage bootstrap/cache
# 12. Sudoers (for the Nitro updater — see section above)
# 12. Sudoers (for update-Nitrov3.sh — sudo chown + systemctl)
sudo tee /etc/sudoers.d/www-data << 'EOF'
www-data ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart emulator
www-data ALL=(ALL) NOPASSWD: /usr/bin/systemctl status emulator
@@ -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 {
+1
View File
@@ -52,6 +52,7 @@
"commandocentrum.emulator_backups_desc": "View and restore emulator backups",
"commandocentrum.restore": "Restore",
"commandocentrum.nitro_client": "Nitro Client",
"commandocentrum.nitro_cli_only": "This script can only be run via command line. Use: bash update-Nitrov3.sh\n\nSettings are configured in the .env file in the project root.",
"commandocentrum.clothing_sync": "Clothing Sync",
"commandocentrum.clothing_sync_desc": "Sync catalog clothing from FigureMap",
"commandocentrum.sync": "Sync",
+2 -15
View File
@@ -305,19 +305,6 @@
"radio.wizard.unknown_error": "Onbekende fout",
"Homepage": "Homepage",
"commandocentrum.nitro_update": "Nitro V3 Update",
"commandocentrum.nitro_update_desc": "Configureer paths en voer het update script uit voor Nitro V3, Render V3 en de Emulator",
"commandocentrum.run_update": "Run Update",
"commandocentrum.configure_nitro": "Configureer Paths",
"commandocentrum.save_nitro_config": "Save Config",
"commandocentrum.nitro_config_saved": "Nitro configuratie opgeslagen!",
"commandocentrum.nitro_update_output": "Update Output",
"commandocentrum.nitro_emulator_path": "Emulator hoofdmap",
"commandocentrum.nitro_emulator_service": "Emulator service naam",
"commandocentrum.nitro_db_name": "Database naam",
"commandocentrum.nitro_sql_dir": "SQL updates map",
"commandocentrum.nitro_backup_dir": "Backup map",
"commandocentrum.nitro_gamedata_dir": "Gamedata config map",
"commandocentrum.nitro_client_dir": "Nitro client config map (public/configuration)",
"commandocentrum.nitro_client_src": "Nitro-V3 bronmap",
"commandocentrum.nitro_renderer_src": "Nitro Render V3 bronmap"
"commandocentrum.nitro_update_desc": "Update alleen via command line — configureer instellingen in .env",
"commandocentrum.nitro_cli_only": "Dit script kan alleen via de command line worden uitgevoerd. Gebruik: bash update-Nitrov3.sh\n\nInstellingen worden geconfigureerd in het .env bestand in de project root."
}
+9 -2
View File
@@ -3,8 +3,15 @@
# Strict mode: exit on any error, undefined var, or pipe failure
set -euo pipefail
# Laad .env bestand uit dezelfde directory als dit script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/.env" ]; then
set -a
. "$SCRIPT_DIR/.env"
set +a
fi
# Real-time output via pseudo-terminal (unbuffer from expect)
# Dit forceert line-buffered output voor ALLE commands, ook in web interfaces
if [ -z "${_UNBUFFERED:-}" ] && command -v unbuffer &> /dev/null; then
export _UNBUFFERED=1
exec unbuffer bash "$0" "$@"
@@ -14,7 +21,7 @@ exec 2>&1
# Trap for clean error messages
trap 'echo "=== ❌ FOUT: Update mislukt op regel $LINENO (commando: $BASH_COMMAND) ===" >&2; exit 1' ERR
# --- CONFIGURATION (overridable via environment variables) ---
# --- CONFIGURATION (uit env vars, met defaults) ---
DB_NAME="${NITRO_DB_NAME:-habbo}"
DB_HOST="${NITRO_DB_HOST:-127.0.0.1}"
DB_PORT="${NITRO_DB_PORT:-3306}"