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_username' => $this->getSetting('emulator_database_username', ''),
|
||||||
'emulator_database_password' => $this->getSetting('emulator_database_password', ''),
|
'emulator_database_password' => $this->getSetting('emulator_database_password', ''),
|
||||||
'emulator_version' => $this->getSetting('emulator_version', 'Onbekend'),
|
'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' => '',
|
'hotel_alert_message' => '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -216,6 +225,73 @@ final class Commandocentrum extends Page implements HasForms
|
|||||||
->content(fn () => $this->renderEmulatorInfoView()),
|
->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'))
|
Section::make(__('commandocentrum.clothing_sync'))
|
||||||
->description(__('commandocentrum.clothing_sync_desc'))
|
->description(__('commandocentrum.clothing_sync_desc'))
|
||||||
->icon('heroicon-o-user')
|
->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
|
public function saveEmulator(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
+17
-1
@@ -303,5 +303,21 @@
|
|||||||
"radio.wizard.test_connection_fail": "Kon de test niet uitvoeren: ",
|
"radio.wizard.test_connection_fail": "Kon de test niet uitvoeren: ",
|
||||||
"radio.wizard.error": "Fout",
|
"radio.wizard.error": "Fout",
|
||||||
"radio.wizard.unknown_error": "Onbekende fout",
|
"radio.wizard.unknown_error": "Onbekende fout",
|
||||||
"Homepage": "Homepage"
|
"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"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
@php
|
||||||
|
use App\Services\SettingsService;
|
||||||
|
$settings = app(SettingsService::class);
|
||||||
|
@endphp
|
||||||
|
<div style="display:grid;grid-template-columns:repeat(2,1fr);gap:12px;">
|
||||||
|
<div style="background:#f8fafc;border-radius:10px;padding:12px;border:1px solid #e2e8f0;">
|
||||||
|
<div style="font-size:11px;color:#64748b;margin-bottom:4px;">{{ __('commandocentrum.nitro_emulator_path') }}</div>
|
||||||
|
<div style="font-size:14px;font-weight:600;color:#1e293b;font-family:monospace;">{{ $settings->getOrDefault('nitro_emulator_path', '/var/www/emulator') }}</div>
|
||||||
|
</div>
|
||||||
|
<div style="background:#f8fafc;border-radius:10px;padding:12px;border:1px solid #e2e8f0;">
|
||||||
|
<div style="font-size:11px;color:#64748b;margin-bottom:4px;">{{ __('commandocentrum.nitro_emulator_service') }}</div>
|
||||||
|
<div style="font-size:14px;font-weight:600;color:#1e293b;">{{ $settings->getOrDefault('nitro_emulator_service', 'emulator') }}</div>
|
||||||
|
</div>
|
||||||
|
<div style="background:#f8fafc;border-radius:10px;padding:12px;border:1px solid #e2e8f0;">
|
||||||
|
<div style="font-size:11px;color:#64748b;margin-bottom:4px;">{{ __('commandocentrum.nitro_db_name') }}</div>
|
||||||
|
<div style="font-size:14px;font-weight:600;color:#1e293b;font-family:monospace;">{{ $settings->getOrDefault('nitro_db_name', 'habbo') }}</div>
|
||||||
|
</div>
|
||||||
|
<div style="background:#f8fafc;border-radius:10px;padding:12px;border:1px solid #e2e8f0;">
|
||||||
|
<div style="font-size:11px;color:#64748b;margin-bottom:4px;">{{ __('commandocentrum.nitro_sql_dir') }}</div>
|
||||||
|
<div style="font-size:14px;font-weight:600;color:#1e293b;font-family:monospace;word-break:break-all;">{{ $settings->getOrDefault('nitro_sql_dir', '/var/www/emulator/Database Updates') }}</div>
|
||||||
|
</div>
|
||||||
|
<div style="background:#f8fafc;border-radius:10px;padding:12px;border:1px solid #e2e8f0;">
|
||||||
|
<div style="font-size:11px;color:#64748b;margin-bottom:4px;">Nitro-V3</div>
|
||||||
|
<div style="font-size:14px;font-weight:600;color:#1e293b;font-family:monospace;word-break:break-all;">{{ $settings->getOrDefault('nitro_client_src', '/var/www/Nitro-V3') }}</div>
|
||||||
|
</div>
|
||||||
|
<div style="background:#f8fafc;border-radius:10px;padding:12px;border:1px solid #e2e8f0;">
|
||||||
|
<div style="font-size:11px;color:#64748b;margin-bottom:4px;">Nitro Render</div>
|
||||||
|
<div style="font-size:14px;font-weight:600;color:#1e293b;font-family:monospace;word-break:break-all;">{{ $settings->getOrDefault('nitro_renderer_src', '/var/www/Nitro_Render_V3') }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Regular → Executable
+110
-15
@@ -3,10 +3,26 @@
|
|||||||
# Exit immediately if a command exits with a non-zero status
|
# Exit immediately if a command exits with a non-zero status
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# --- CONFIGURATION ---
|
# --- CONFIGURATION (overschrijfbaar via omgevingsvariabelen) ---
|
||||||
DB_NAME="JOUW_DATABASE_NAAM"
|
DB_NAME="${NITRO_DB_NAME:-habbo}"
|
||||||
EMULATOR_SERVICE="YOUR_SERVICE_NAME"
|
DB_HOST="${NITRO_DB_HOST:-127.0.0.1}"
|
||||||
SQL_DIR="/var/www/emulator/Emulator/sql"
|
DB_PORT="${NITRO_DB_PORT:-3306}"
|
||||||
|
DB_USER="${NITRO_DB_USER:-root}"
|
||||||
|
DB_PASS="${NITRO_DB_PASS:-}"
|
||||||
|
EMULATOR_SERVICE="${NITRO_EMULATOR_SERVICE:-emulator}"
|
||||||
|
EMULATOR_DIR="${NITRO_EMULATOR_PATH:-/var/www/emulator}"
|
||||||
|
SQL_DIR="${NITRO_SQL_DIR:-$EMULATOR_DIR/Database Updates}"
|
||||||
|
GAMEDATA_CONF_DIR="${NITRO_GAMEDATA_DIR:-/var/www/Gamedata/config}"
|
||||||
|
NITRO_SRC_DIR="${NITRO_CLIENT_DIR:-/var/www/Nitro-V3/public/configuration}"
|
||||||
|
BACKUP_DIR="${NITRO_BACKUP_DIR:-$EMULATOR_DIR/Database Updates/backups}"
|
||||||
|
NITRO_CLIENT="${NITRO_CLIENT_SRC:-/var/www/Nitro-V3}"
|
||||||
|
NITRO_RENDERER="${NITRO_RENDERER_SRC:-/var/www/Nitro_Render_V3}"
|
||||||
|
|
||||||
|
# Build MySQL/MariaDB credentials argument
|
||||||
|
MYSQL_CRED="-h $DB_HOST -P $DB_PORT -u $DB_USER"
|
||||||
|
if [ -n "$DB_PASS" ]; then
|
||||||
|
MYSQL_CRED="$MYSQL_CRED -p$DB_PASS"
|
||||||
|
fi
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
||||||
echo "=== Starting EPIC WEB CONTROL Update ==="
|
echo "=== Starting EPIC WEB CONTROL Update ==="
|
||||||
@@ -15,15 +31,20 @@ echo "=== Starting EPIC WEB CONTROL Update ==="
|
|||||||
# 1. Update and Build Emulator
|
# 1. Update and Build Emulator
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
echo "--> Updating Emulator..."
|
echo "--> Updating Emulator..."
|
||||||
cd /var/www/emulator/Emulator/
|
cd "$EMULATOR_DIR/Emulator/"
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
|
# --- Automatic Safe Database Backup ---
|
||||||
|
echo "--> Creating automatic database backup before update..."
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
mariadb-dump $MYSQL_CRED "$DB_NAME" > "$BACKUP_DIR/backup_$(date +%Y%m%d_%H%M%S).sql"
|
||||||
|
|
||||||
# --- Automatic SQL Import ---
|
# --- Automatic SQL Import ---
|
||||||
echo "--> Checking for new SQL files..."
|
echo "--> Checking for new SQL files..."
|
||||||
if [ -d "$SQL_DIR" ]; then
|
if [ -d "$SQL_DIR" ]; then
|
||||||
find "$SQL_DIR" -name "*.sql" -mmin -10 | while read -r sql_file; do
|
find "$SQL_DIR" -name "*.sql" -mmin -10 -print0 | while IFS= read -r -d '' sql_file; do
|
||||||
echo "--> Importing new SQL file: $(basename "$sql_file")"
|
echo "--> Importing new SQL file: $(basename "$sql_file")"
|
||||||
mysql "$DB_NAME" < "$sql_file"
|
mariadb $MYSQL_CRED --force "$DB_NAME" < "$sql_file" || echo "--> Opmerking: Sommige SQL-regels overgeslagen (bestonden waarschijnlijk al)."
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "--> SQL directory not found, skipping SQL import."
|
echo "--> SQL directory not found, skipping SQL import."
|
||||||
@@ -50,7 +71,7 @@ chmod +x emulator
|
|||||||
# 2. Update Nitro_Render_V3
|
# 2. Update Nitro_Render_V3
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
echo "--> Updating Nitro_Render_V3..."
|
echo "--> Updating Nitro_Render_V3..."
|
||||||
cd /var/www/Nitro_Render_V3/
|
cd "$NITRO_RENDERER/"
|
||||||
|
|
||||||
# Check if package.json will change after git pull
|
# Check if package.json will change after git pull
|
||||||
if git diff --name-only HEAD..@{u} | grep -q 'package.json'; then
|
if git diff --name-only HEAD..@{u} | grep -q 'package.json'; then
|
||||||
@@ -75,7 +96,7 @@ fi
|
|||||||
# 3. Update and Build Nitro-V3
|
# 3. Update and Build Nitro-V3
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
echo "--> Updating Nitro-V3..."
|
echo "--> Updating Nitro-V3..."
|
||||||
cd /var/www/Nitro-V3
|
cd "$NITRO_CLIENT"
|
||||||
|
|
||||||
# Check if package.json will change after git pull
|
# Check if package.json will change after git pull
|
||||||
if git diff --name-only HEAD..@{u} | grep -q 'package.json'; then
|
if git diff --name-only HEAD..@{u} | grep -q 'package.json'; then
|
||||||
@@ -95,17 +116,91 @@ else
|
|||||||
echo "--> No changes in package.json for Nitro-V3. Skipping yarn install."
|
echo "--> No changes in package.json for Nitro-V3. Skipping yarn install."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "--> Building Nitro-V3 with Yarn..."
|
echo "--> Building Nitro-V3 with Vite 8 / Yarn..."
|
||||||
yarn build
|
yarn build
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
# 4. Restart the Service
|
# 4. Sync Gamedata Configs & UITexts (.example logica)
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
echo "--> Restarting $EMULATOR_SERVICE service..."
|
echo "--> Synchronizing Gamedata configurations..."
|
||||||
systemctl restart $EMULATOR_SERVICE
|
mkdir -p "$GAMEDATA_CONF_DIR"
|
||||||
|
|
||||||
echo "--> Checking service status..."
|
# --- Renderer Config Sync ---
|
||||||
systemctl status $EMULATOR_SERVICE --no-pager -n 5
|
if [ ! -f "$GAMEDATA_CONF_DIR/renderer-config.json" ] || [ "$NITRO_SRC_DIR/renderer-config.example" -nt "$GAMEDATA_CONF_DIR/renderer-config.json" ]; then
|
||||||
|
if [ -f "$NITRO_SRC_DIR/renderer-config.example" ]; then
|
||||||
|
echo "--> Updating renderer-config.json from latest example..."
|
||||||
|
cp "$NITRO_SRC_DIR/renderer-config.example" "$GAMEDATA_CONF_DIR/renderer-config.json"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- UI Config Sync ---
|
||||||
|
if [ ! -f "$GAMEDATA_CONF_DIR/ui-config.json" ] || [ "$NITRO_SRC_DIR/ui-config.json.example" -nt "$GAMEDATA_CONF_DIR/ui-config.json" ]; then
|
||||||
|
if [ -f "$NITRO_SRC_DIR/ui-config.json.example" ]; then
|
||||||
|
echo "--> Updating ui-config.json from latest example..."
|
||||||
|
cp "$NITRO_SRC_DIR/ui-config.json.example" "$GAMEDATA_CONF_DIR/ui-config.json"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- UITexts Sync ---
|
||||||
|
if [ ! -f "$GAMEDATA_CONF_DIR/UITexts.json5" ] || [ "$NITRO_SRC_DIR/UITexts.json5.example" -nt "$GAMEDATA_CONF_DIR/UITexts.json5" ]; then
|
||||||
|
if [ -f "$NITRO_SRC_DIR/UITexts.json5.example" ]; then
|
||||||
|
echo "--> Updating UITexts.json5 from latest example..."
|
||||||
|
cp "$NITRO_SRC_DIR/UITexts.json5.example" "$GAMEDATA_CONF_DIR/UITexts.json5"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------
|
||||||
|
# 5. Automated Cleanup (Logs & Backups)
|
||||||
|
# ----------------------------------------
|
||||||
|
echo "--> Starting automated cleanup..."
|
||||||
|
|
||||||
|
# 1. Verwijder emulator logs ouder dan 14 dagen
|
||||||
|
echo "--> Removing emulator logs older than 14 days..."
|
||||||
|
find "$EMULATOR_DIR/" -name "*.log" -mtime +14 -exec rm -f {} \;
|
||||||
|
|
||||||
|
# 2. Hou maximaal de 5 nieuwste database backups, gooi oudere weg
|
||||||
|
echo "--> Managing update backups (keeping max 5)..."
|
||||||
|
if [ -d "$BACKUP_DIR" ]; then
|
||||||
|
# Zoekt alle .sql bestanden in de backup map, sorteert op datum (nieuwste eerst),
|
||||||
|
# slaat de eerste 5 over (tail -n +6) en verwijdert de rest.
|
||||||
|
ls -t "$BACKUP_DIR"/*.sql 2>/dev/null | tail -n +6 | xargs -r rm -f || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Clean Yarn cache om SSD ruimte te besparen
|
||||||
|
echo "--> Cleaning Yarn cache..."
|
||||||
|
yarn cache clean
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------
|
||||||
|
# 6. Fix Permissions (www-data) — alleen als sudo beschikbaar is
|
||||||
|
# ----------------------------------------
|
||||||
|
if command -v sudo &> /dev/null; then
|
||||||
|
echo "--> Setting permissions to www-data:www-data..."
|
||||||
|
sudo chown -R www-data:www-data "$NITRO_CLIENT" 2>/dev/null || echo "--> chown voor NITRO_CLIENT overgeslagen"
|
||||||
|
sudo chown -R www-data:www-data "$NITRO_RENDERER" 2>/dev/null || echo "--> chown voor NITRO_RENDERER overgeslagen"
|
||||||
|
sudo chown -R www-data:www-data "$EMULATOR_DIR" 2>/dev/null || echo "--> chown voor EMULATOR_DIR overgeslagen"
|
||||||
|
sudo chown -R www-data:www-data "$GAMEDATA_CONF_DIR" 2>/dev/null || echo "--> chown voor GAMEDATA_CONF_DIR overgeslagen"
|
||||||
|
else
|
||||||
|
echo "--> Sudo niet beschikbaar, overslaan van chown."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------
|
||||||
|
# 7. Restart the Service (Veilige Check)
|
||||||
|
# ----------------------------------------
|
||||||
|
if systemctl list-units --type=service --all | grep -q "$EMULATOR_SERVICE.service"; then
|
||||||
|
echo "--> Restarting $EMULATOR_SERVICE service..."
|
||||||
|
if command -v sudo &> /dev/null; then
|
||||||
|
sudo systemctl restart $EMULATOR_SERVICE 2>/dev/null || echo "--> Service restart via sudo mislukt (mogelijk geen sudo rechten)"
|
||||||
|
sudo systemctl status $EMULATOR_SERVICE --no-pager -n 5 2>/dev/null || true
|
||||||
|
else
|
||||||
|
echo "--> Sudo niet beschikbaar. Herstart de service handmatig: sudo systemctl restart $EMULATOR_SERVICE"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "--> Waarschuwing: Service '$EMULATOR_SERVICE' niet gevonden in systemd."
|
||||||
|
echo "--> Als je PM2 gebruikt, herstart je processen dan handmatig met: pm2 restart all"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=== Update successfully completed! ==="
|
echo "=== Update successfully completed! ==="
|
||||||
Reference in New Issue
Block a user