load_config: source partner confs from /tmp cache
conf_sync.sh has always populated /tmp/.vv/config/cached/.confs/ with partner host*.conf files pulled via SCP, but load_config.sh never read from it — leaving HOST2_* vars undefined on HOST1 and vice versa. After the disk host*.conf loop, source any cached conf whose basename wasn't already loaded from disk. Disk copy always wins (authoritative); cache supplies partner vars that sparse checkout intentionally withholds. Cache is tmpfs, cleared on reboot, repopulated by conf_sync.sh on array start.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user