From a58dd54ba831914053e4f7dadbb0963be857cf0b Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Sun, 4 Jan 2026 16:26:48 -0500 Subject: [PATCH] Add venv repair step to sanitize script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check if venv is broken or missing stegasoo module and rebuild if needed. Venv paths break when directory is moved. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- rpi/sanitize-for-image.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rpi/sanitize-for-image.sh b/rpi/sanitize-for-image.sh index 512e1f6..e3418ce 100755 --- a/rpi/sanitize-for-image.sh +++ b/rpi/sanitize-for-image.sh @@ -261,6 +261,21 @@ STEGASOO_USER=$(stat -c '%U' "$STEGASOO_DIR" 2>/dev/null || echo "pi") echo " Stegasoo directory: $STEGASOO_DIR" echo " Stegasoo user: $STEGASOO_USER" +# Check and repair venv if needed (paths break when moving directories) +if [ -n "$STEGASOO_DIR" ] && [ -d "$STEGASOO_DIR/venv" ]; then + VENV_PYTHON="$STEGASOO_DIR/venv/bin/python" + # Check if venv python works and has stegasoo installed + if ! "$VENV_PYTHON" -c "import stegasoo" 2>/dev/null; then + echo " Venv broken or stegasoo not installed, rebuilding..." + rm -rf "$STEGASOO_DIR/venv" + sudo -u "$STEGASOO_USER" python3 -m venv "$STEGASOO_DIR/venv" + sudo -u "$STEGASOO_USER" "$STEGASOO_DIR/venv/bin/pip" install --quiet -e "$STEGASOO_DIR[web]" + echo " Venv rebuilt and stegasoo installed" + else + echo " Venv OK" + fi +fi + if [ -n "$STEGASOO_DIR" ] && [ -f "$STEGASOO_DIR/rpi/stegasoo-wizard.sh" ]; then # Install the profile.d hook cp "$STEGASOO_DIR/rpi/stegasoo-wizard.sh" /etc/profile.d/stegasoo-wizard.sh