diff --git a/install.sh b/install.sh index dc74f8c..1766fa2 100755 --- a/install.sh +++ b/install.sh @@ -182,6 +182,23 @@ if [ -d "$HOME/imports" ] && ls "$HOME/imports"/*.json &>/dev/null; then fi fi +# Clean generated files from existing site directories so rebuild-all +# regenerates them from the current template. Preserves: +# config.json — site content and settings +# .onionshare-session — Tor domain identity key +# server.pid — running process marker +# onionshare.log — current log (may be in use) +# Everything else is regenerated by build_assets(). +if [ -d "$HOME/host" ]; then + for site_dir in "$HOME"/host/*/; do + [ -f "${site_dir}config.json" ] || continue + msg "Cleaning generated files in ${site_dir}..." + rm -f "${site_dir}index.html" 2>/dev/null || true + rm -f "${site_dir}qrcode-content.png" "${site_dir}qrcode-tear-offs.png" 2>/dev/null || true + rm -rf "${site_dir}download" 2>/dev/null || true + done +fi + # --- Helper: build pip flags for this distro --- pip_flags() { local flags="--user --upgrade" diff --git a/voxvera/cli.py b/voxvera/cli.py index 69ff4bc..51aec64 100644 --- a/voxvera/cli.py +++ b/voxvera/cli.py @@ -731,6 +731,12 @@ def serve(config_path: str) -> str | None: if not dir_path.is_dir(): print(f"Directory {dir_path} not found", file=sys.stderr) sys.exit(1) + + # Auto-rebuild if index.html is missing (e.g. after install cleanup) + if not (dir_path / "index.html").exists(): + print(f"Rebuilding {folder_name} from current template...") + build_assets(config_path) + logfile = dir_path / "onionshare.log" # Set environment variables for OnionShare to use the detected Tor ports