Fix kill switch not cleared on reinstall; guard midclt delete; tighten sitecustomize imports

install.sh: running install.sh after a recover.sh left /data/truecloud-patch/disabled
in place, so apply.sh silently skipped all patching and middlewared restarted
without the patch. Clear the kill switch file before running apply.sh.

uninstall.sh: midclt initshutdownscript.delete was unguarded under set -euo pipefail,
so a delete failure (already-removed entry, transient API error) aborted the script
before sitecustomize.py was cleaned up or /data/truecloud-patch/ was removed. Now
guarded with an if/else that warns and continues.

sitecustomize.py: move importlib.machinery/.util imports inside the if block in
find_spec so they only execute when intercepting our two target modules, not on
every module import across the whole process. In _install(), import os before
importlib.util so the kill switch check (cheap) runs before the importlib import
(slightly heavier on first use). Remove the unused orig variable in _patch_restic.

patch_ui.py: add explicit encoding="utf-8" to both open() calls. errors="replace"
on read so malformed bytes in a bundle don't silently skip a candidate file.
This commit is contained in:
2026-06-15 02:39:34 +00:00
parent 48cf3a5601
commit 78f943a71b
4 changed files with 20 additions and 10 deletions
+8
View File
@@ -73,6 +73,14 @@ else
fi
echo ""
# ── Clear kill switch if set ──────────────────────────────────────────────────
if [ -f "$PATCH_DIR/disabled" ]; then
rm "$PATCH_DIR/disabled"
echo "Removed kill switch ($PATCH_DIR/disabled) left from a previous recovery."
echo ""
fi
# ── Apply now ─────────────────────────────────────────────────────────────────
echo "Applying patches ..."