diff --git a/install.sh b/install.sh index 25fcae9..1f78325 100755 --- a/install.sh +++ b/install.sh @@ -98,7 +98,7 @@ echo "" echo "Patch log ($PATCH_DIR/apply.log):" tail -30 "$PATCH_DIR/apply.log" echo "" -if tail -c "+$((_log_start + 1))" "$PATCH_DIR/apply.log" 2>/dev/null | grep -q "WARNING:"; then +if tail -c "+$((_log_start + 1))" "$PATCH_DIR/apply.log" 2>/dev/null | grep -qE "WARNING:|ERROR:"; then echo "WARNING: apply.sh reported one or more issues — see log above for details." echo "" fi @@ -108,8 +108,10 @@ fi echo "Restarting middlewared so the backend patch takes effect ..." if ! systemctl restart middlewared; then echo "" >&2 - echo "ERROR: middlewared failed to restart. The patch files are installed but" >&2 - echo "the hook is not yet active. Check the system log for the root cause:" >&2 + echo "ERROR: middlewared failed to restart." >&2 + echo " The patch IS installed and will activate automatically on the next boot." >&2 + echo " To activate now, resolve the issue below and run: systemctl restart middlewared" >&2 + echo " Check the system log for the root cause:" >&2 echo " journalctl -u middlewared -n 50" >&2 echo "If the problem is unrelated to this patch, recover with:" >&2 echo " bash $PATCH_DIR/recover.sh" >&2 diff --git a/patch/apply.sh b/patch/apply.sh index 9fd9fa8..75a3368 100755 --- a/patch/apply.sh +++ b/patch/apply.sh @@ -97,8 +97,8 @@ else fi fi - if $_can_install; then - if cp "$PATCH_DIR/sitecustomize.py" "$SITE_PKG/sitecustomize.py" 2>/dev/null; then + if [ "$_can_install" = true ]; then + if cp "$PATCH_DIR/sitecustomize.py" "$SITE_PKG/sitecustomize.py"; then echo "OK: Installed sitecustomize.py → $SITE_PKG/sitecustomize.py" else echo "WARNING: Failed to write $SITE_PKG/sitecustomize.py (permission error?)" diff --git a/uninstall.sh b/uninstall.sh index 41ac44d..cf9e3b6 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -102,6 +102,7 @@ echo "" echo "Restoring UI bundle backup ..." RESTORED=0 +_restore_failed=0 while IFS= read -r backup; do original="${backup%.pre-truecloud-patch}" if mv "$backup" "$original"; then @@ -109,11 +110,20 @@ while IFS= read -r backup; do RESTORED=1 else echo " WARNING: Could not restore $original — backup left at $backup" + _restore_failed=1 fi # Keep these paths in sync with WEBUI_CANDIDATES in patch/patch_ui.py done < <(find /usr/share/truenas /usr/share/truenas-ui /var/www/truenas \ -name "*.js.pre-truecloud-patch" 2>/dev/null) +if [ "$_restore_failed" -eq 1 ]; then + echo "" + echo "ERROR: One or more UI bundle backups could not be restored." >&2 + echo " $PATCH_DIR has been left intact (recover.sh and patch files are safe)." >&2 + echo " Restore the backup(s) manually, then re-run uninstall.sh." >&2 + exit 1 +fi + if [ "$RESTORED" -eq 0 ]; then echo " No backup files found." echo " The UI patch will be undone automatically by the next TrueNAS update."