From 824f3cce99efd8b0c22dc650cb1f05ebbee6fdc2 Mon Sep 17 00:00:00 2001 From: bunker-admin Date: Thu, 16 Apr 2026 14:25:53 -0600 Subject: [PATCH] install: preserve extracted dir when config wizard can't start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/install.sh cleanup trap previously removed $INSTALL_DIR on any non-zero exit if .env wasn't written yet. That made sense for half-extracted state, but also bit us when config.sh failed at /dev/tty (the common "curl | ssh bash" non-interactive case) — the 15MB tarball had already extracted cleanly and the user was forced to re-download to retry on a console. New EXTRACT_COMPLETE state flag: - Set to true after the tar xzf step verifies docker-compose.yml. - cleanup() distinguishes "extract OK, config wizard didn't run" from "extraction never completed": * First case: preserve the dir, print a resumption hint (cd $INSTALL_DIR && bash config.sh on an interactive console). * Second case: unchanged behaviour — remove the partial dir. Typical SSH-without-tty recovery path now costs zero re-download. Bunker Admin --- scripts/install.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 2e219d97..f1aea9ad 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -27,6 +27,7 @@ HEALTH_INTERVAL=5 # --- State flags for cleanup --- TARBALL_PATH="" +EXTRACT_COMPLETE=false CONFIG_COMPLETE=false # --- Colors --- @@ -50,7 +51,26 @@ cleanup() { if [[ -z "$LOCAL_TARBALL" ]] && [[ -n "$TARBALL_PATH" ]] && [[ -f "$TARBALL_PATH" ]]; then rm -f "$TARBALL_PATH" fi - # Remove install dir only if config wizard never ran (no user data to lose) + + # Post-extract state: tarball unpacked OK but config wizard didn't complete + # (common case: /dev/tty unavailable over non-interactive SSH). The expensive + # step succeeded, so preserve the dir and tell the user how to resume instead + # of forcing a full re-download. + if [[ "$EXTRACT_COMPLETE" == "true" ]] \ + && [[ "$CONFIG_COMPLETE" == "false" ]] \ + && [[ -d "$INSTALL_DIR" ]] \ + && [[ ! -f "$INSTALL_DIR/.env" ]]; then + echo "" + echo -e "${YELLOW}[INFO]${NC} Tarball extracted to $INSTALL_DIR — preserving." + echo -e "${YELLOW}[INFO]${NC} To finish setup on an interactive console:" + echo -e " ${BOLD}cd $INSTALL_DIR && bash config.sh${NC}" + echo "" + error "Configuration wizard could not run (likely no TTY available)." + return 0 + fi + + # Extraction failed or never happened — discard the partial dir so the next + # run-through starts from a clean slate. if [[ "$CONFIG_COMPLETE" == "false" ]] && [[ -d "$INSTALL_DIR" ]] && [[ ! -f "$INSTALL_DIR/.env" ]]; then rm -rf "$INSTALL_DIR" fi @@ -244,6 +264,7 @@ if [[ ! -f "$INSTALL_DIR/docker-compose.yml" ]]; then error "Tarball extraction failed — docker-compose.yml not found" exit 1 fi +EXTRACT_COMPLETE=true # Clean up downloaded tarball if [[ -z "$LOCAL_TARBALL" ]] && [[ -f "$TARBALL_PATH" ]]; then