diff --git a/load_config.sh b/load_config.sh index 787da02..0280453 100755 --- a/load_config.sh +++ b/load_config.sh @@ -80,12 +80,14 @@ # Missing files are silently skipped — sparse checkout intentionally withholds some. # At least one host conf must be present or the ecosystem has no identity to work with. _host_confs_loaded=0 + declare -A _disk_conf_basenames=() # Use a sorted array glob — avoids word-splitting on paths with spaces while IFS= read -r _conf; do [[ -f "$_conf" ]] || continue source "$_conf" (( _host_confs_loaded++ )) + _disk_conf_basenames["$(basename "$_conf")"]=1 [[ "${ENABLE_LOGGING:-false}" == "true" ]] && \ echo "[LOG] Loaded host config: $(basename "$_conf")" >&2 done < <(printf '%s\n' "$LOAD_CONFIG_DIR/Configurations"/host*.conf 2>/dev/null | sort) @@ -96,6 +98,26 @@ exit 1 fi +# ━━━ Source partner confs from /tmp cache ━━━ +# conf_sync.sh pulls partner host*.conf files into /tmp/.vv/config/cached/.confs/ +# on array start and after any conf save. Sourcing them here makes partner vars +# (HOST2_*, HOST3_*, …) available without committing credentials to the git repo +# or violating sparse checkout — partner confs live in RAM only, cleared on reboot. +# Confs already loaded from disk are skipped — disk copy is authoritative. + _VV_CONF_CACHE="/tmp/.vv/config/cached/.confs" + if [[ -d "$_VV_CONF_CACHE" ]]; then + while IFS= read -r _conf; do + [[ -f "$_conf" ]] || continue + _conf_base="$(basename "$_conf")" + # Skip if already sourced from disk + [[ -n "${_disk_conf_basenames[$_conf_base]:-}" ]] && continue + source "$_conf" + [[ "${ENABLE_LOGGING:-false}" == "true" ]] && \ + echo "[LOG] Loaded cached partner config: $_conf_base" >&2 + done < <(printf '%s\n' "$_VV_CONF_CACHE"/host*.conf 2>/dev/null | sort) + fi + unset _VV_CONF_CACHE _conf_base _disk_conf_basenames + # ━━━ Source shared functions ━━━ # common.sh sourced last — it calls detect_hosts() which needs HOST* vars to be set. if [[ ! -f "$LOAD_CONFIG_DIR/common.sh" ]]; then