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