fix: preserve installation id during updates

the telemetry id was being lost during updates because:
1. apply_update.sh didn't export INSTALLATION_ID
2. 03_generate_secrets.sh only checked env var, not existing .env

now checks both exported var and generated_values from existing .env,
and generates new id for pre-telemetry installations upgrading
This commit is contained in:
Yury Kossakovsky
2025-12-25 16:49:43 -07:00
parent ffca8693f7
commit 2f6516880b

View File

@@ -548,10 +548,14 @@ done
log_success ".env file generated successfully in the project root ($OUTPUT_FILE)."
# Save INSTALLATION_ID if passed from install.sh (for telemetry correlation)
if [[ -n "${INSTALLATION_ID:-}" ]]; then
write_env_var "INSTALLATION_ID" "$INSTALLATION_ID" "$OUTPUT_FILE"
# Save INSTALLATION_ID for telemetry correlation
# Priority: 1) exported from parent (install.sh), 2) existing .env (via generated_values), 3) generate new
existing_install_id="${INSTALLATION_ID:-${generated_values[INSTALLATION_ID]:-}}"
if [[ -z "$existing_install_id" ]]; then
# Generate new ID for existing installations upgrading from pre-telemetry version
existing_install_id=$(od -An -tx1 -N6 /dev/urandom | tr -d ' \n')
fi
write_env_var "INSTALLATION_ID" "$existing_install_id" "$OUTPUT_FILE"
# Uninstall caddy
apt remove -y caddy