Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

fix(installer): say "existing install" only when there is one (#8308)

Mike Bradleyc330588589d7
diff --git a/ods/installers/phases/01-preflight.sh b/ods/installers/phases/01-preflight.sh
index a0bdd6a70..e3abbcf8e 100755
--- a/ods/installers/phases/01-preflight.sh
+++ b/ods/installers/phases/01-preflight.sh
@@ -242,9 +242,11 @@ if [[ ! -d "$INSTALL_DIR" ]] && ! _ods_truthy "${ODS_ALLOW_LEGACY_PARALLEL:-}";
fi
# Existing installation — update in place (secrets and data are preserved).
+# Its .env holds those secrets, as install-core's ODS_EXISTING_INSTALL reads
+# it: an empty folder or an unpacked source tree is not an installation.
# A --preflight-only run is checking a host whose installation is about to be
# replaced, not updated.
-if [[ -d "$INSTALL_DIR" && "${PREFLIGHT_ONLY:-false}" != "true" ]]; then
+if [[ -f "$INSTALL_DIR/.env" && "${PREFLIGHT_ONLY:-false}" != "true" ]]; then
log "Existing installation found at $INSTALL_DIR — updating in place"
signal "Existing install detected. Secrets and data will be preserved."
fi
diff --git a/ods/tests/bats-tests/preflight-phase.bats b/ods/tests/bats-tests/preflight-phase.bats
index 95c01f4f3..b6d9f6d93 100644
--- a/ods/tests/bats-tests/preflight-phase.bats
+++ b/ods/tests/bats-tests/preflight-phase.bats
@@ -197,6 +197,7 @@ MOCK
@test "preflight: detects existing installation" {
touch "$SCRIPT_DIR/docker-compose.base.yml"
mkdir -p "$INSTALL_DIR"
+ touch "$INSTALL_DIR/.env"
# Stub successful required-network probes and required tools.
install_preflight_tool_stubs
@@ -227,6 +228,40 @@ MOCK
assert_output --partial "Existing installation"
}
+@test "preflight: an install folder without .env is not an existing installation" {
+ touch "$SCRIPT_DIR/docker-compose.base.yml"
+ mkdir -p "$INSTALL_DIR"
+ install_preflight_tool_stubs
+
+ run bash -c '
+ export SCRIPT_DIR="'"$SCRIPT_DIR"'"
+ export INSTALL_DIR="'"$INSTALL_DIR"'"
+ export LOG_FILE="'"$LOG_FILE"'"
+ export INTERACTIVE=false
+ export DRY_RUN=false
+ export PKG_MANAGER="apt"
+ export VERSION="2.3.0"
+ export ODS_ALLOW_LEGACY_PARALLEL=1
+
+ log() { echo "LOG: $1"; }
+ warn() { :; }
+ error() { echo "ERROR: $1"; exit 1; }
+ ai() { :; }
+ ai_ok() { :; }
+ signal() { echo "SIGNAL: $1"; }
+ show_phase() { :; }
+ show_stranger_boot() { :; }
+ ods_progress() { :; }
+
+ source "'"$BATS_TEST_DIRNAME/../../installers/phases/01-preflight.sh"'"
+ echo "PHASE_COMPLETE"
+ '
+
+ # An empty folder or an unpacked source tree keeps no secrets to preserve.
+ assert_output --partial "PHASE_COMPLETE"
+ refute_output --partial "Existing install"
+}
+
# ── Optional tools warning ──────────────────────────────────────────────────
@test "preflight: warns about missing optional tools" {