From 18937f5274c7aa5dd7b99e4a8483633e148384d2 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 5 Jun 2026 22:56:20 +0200 Subject: [PATCH] Verbeter update-Nitrov3.sh: realtime output, strict yarn install, perms fix, extra validatie --- update-Nitrov3.sh | 103 ++++++++++++++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/update-Nitrov3.sh b/update-Nitrov3.sh index f71385a..f5d1e2a 100755 --- a/update-Nitrov3.sh +++ b/update-Nitrov3.sh @@ -3,6 +3,13 @@ # Exit immediately if a command exits with a non-zero status set -e +# Real-time output - disable buffering zodat je bij "run update" direct ziet wat er gebeurt +if command -v stdbuf &> /dev/null && [ -z "$_UNBUFFERED" ]; then + export _UNBUFFERED=1 + exec stdbuf -oL -eL bash "$0" "$@" +fi +exec 2>&1 + # --- CONFIGURATION (overridable via environment variables) --- DB_NAME="${NITRO_DB_NAME:-habbo}" DB_HOST="${NITRO_DB_HOST:-127.0.0.1}" @@ -73,23 +80,11 @@ chmod +x emulator echo "--> Updating Nitro_Render_V3..." cd "$NITRO_RENDERER/" -# Check if package.json will change after git pull -if git diff --name-only HEAD..@{u} | grep -q 'package.json'; then - NEED_YARN_RENDER=true -else - NEED_YARN_RENDER=false -fi - git pull -if [ "$NEED_YARN_RENDER" = true ]; then - echo "--> package.json changed! Cleaning node_modules from Nitro_Render_V3..." - rm -rf node_modules - echo "--> Running yarn install for Nitro_Render_V3..." - yarn install -else - echo "--> No changes in package.json for Nitro_Render_V3. Skipping yarn install." -fi +echo "--> Running yarn install for Nitro_Render_V3..." +rm -rf node_modules +yarn install # ---------------------------------------- @@ -98,23 +93,11 @@ fi echo "--> Updating Nitro-V3..." cd "$NITRO_CLIENT" -# Check if package.json will change after git pull -if git diff --name-only HEAD..@{u} | grep -q 'package.json'; then - NEED_YARN_V3=true -else - NEED_YARN_V3=false -fi - git pull -if [ "$NEED_YARN_V3" = true ]; then - echo "--> package.json changed! Cleaning node_modules from Nitro-V3..." - rm -rf node_modules - echo "--> Running yarn install for Nitro-V3..." - yarn install -else - echo "--> No changes in package.json for Nitro-V3. Skipping yarn install." -fi +echo "--> Running yarn install for Nitro-V3..." +rm -rf node_modules +yarn install echo "--> Building Nitro-V3 with Vite 8 / Yarn..." yarn build @@ -178,10 +161,14 @@ yarn cache clean # ---------------------------------------- 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" + for dir in "$NITRO_CLIENT" "$NITRO_RENDERER" "$EMULATOR_DIR" "$GAMEDATA_CONF_DIR"; do + if [ -d "$dir" ]; then + sudo chown -R www-data:www-data "$dir" || echo "--> chown voor $dir overgeslagen" + else + echo "--> Directory $dir bestaat niet, chown overgeslagen" + fi + done + echo "--> Permissions successfully set to www-data:www-data" else echo "--> Sudo not available, skipping chown." fi @@ -203,4 +190,50 @@ else echo "--> If you use PM2, restart your processes manually: pm2 restart all" fi -echo "=== Update successfully completed! ===" \ No newline at end of file +# ---------------------------------------- +# 8. Extra Validation — 100% check +# ---------------------------------------- +echo "--> Running extra validation..." + +ERRORS=0 + +# Check build output exists +if [ -d "$NITRO_CLIENT/public/assets" ]; then + echo "--> [OK] Nitro-V3 build assets found" +else + echo "--> [FAIL] Nitro-V3 build assets missing!" + ERRORS=$((ERRORS + 1)) +fi + +# Check permissions on key files +for dir in "$NITRO_CLIENT" "$NITRO_RENDERER" "$EMULATOR_DIR" "$GAMEDATA_CONF_DIR"; do + if [ -d "$dir" ]; then + OWNER=$(stat -c '%U:%G' "$dir" 2>/dev/null || echo "unknown") + if [ "$OWNER" = "www-data:www-data" ] || [ "$(id -u)" -ne 0 ]; then + echo "--> [OK] $dir ($OWNER)" + else + if command -v sudo &> /dev/null; then + echo "--> [WARN] $dir heeft eigenaar $OWNER ipv www-data:www-data" + sudo chown -R www-data:www-data "$dir" 2>/dev/null || true + echo "--> Hersteld" + fi + fi + fi +done + +# Check if emulator service is running +if systemctl list-units --type=service --all | grep -q "$EMULATOR_SERVICE.service"; then + SERVICE_STATUS=$(systemctl is-active "$EMULATOR_SERVICE" 2>/dev/null || echo "unknown") + if [ "$SERVICE_STATUS" = "active" ]; then + echo "--> [OK] $EMULATOR_SERVICE service is $SERVICE_STATUS" + else + echo "--> [WARN] $EMULATOR_SERVICE service is $SERVICE_STATUS" + ERRORS=$((ERRORS + 1)) + fi +fi + +if [ "$ERRORS" -eq 0 ]; then + echo "=== ✅ Update 100% successfully completed! ===" +else + echo "=== ⚠️ Update completed with $ERRORS warning(s) — check bovenstaande output ===" +fi \ No newline at end of file