Derive the pull target from the install location, so master.conf is safe to share between hosts

This commit is contained in:
Gmer4Lfe
2026-08-16 13:54:05 -04:00
parent 98fab394a1
commit 3c24550b19
2 changed files with 27 additions and 7 deletions
+17 -6
View File
@@ -281,12 +281,23 @@ echo "━━━ $ICON_GEAR Step 4: Update master.conf paths ━━━"
NEW_MASTER="$DST/Configurations/master.conf"
if [[ "$DRY_RUN" == false ]]; then
if [[ -f "$NEW_MASTER" ]]; then
sed -i "s|^\(\s*TARGET_DIR\s*=\s*\)\"[^\"]*\"|\1\"$DST\"|" "$NEW_MASTER"
sed -i "s|^\(\s*DATA_DIR\s*=\s*\)\"[^\"]*\"|\1\"$DST/data\"|" "$NEW_MASTER"
sed -i "s|^\(\s*STATE_DIR\s*=\s*\)\"[^\"]*\"|\1\"${DST}/data/state\"|" "$NEW_MASTER"
echo " TARGET_DIR → $DST"
echo " DATA_DIR → $DST/data ✅"
echo " STATE_DIR → $DST/data/state ✅"
# Only rewrite a path that is a literal. These three are derived from SCRIPTS_DIR in
# current confs, which load_config.sh exports from its own location — so after the move
# they already point at the new install and hardcoding them here would turn a
# self-correcting value back into one that has to be maintained. Older confs still carry
# literals, so the substitution stays for them.
_mig_path() { # $1=key $2=new value
if grep -qE "^\s*$1\s*=\s*\"[^\"]*\\\$\{?(SCRIPTS_DIR|DATA_DIR)" "$NEW_MASTER"; then
echo " $1 — already derived, left alone ✅"
else
sed -i "s|^\(\s*$1\s*=\s*\)\"[^\"]*\"|\1\"$2\"|" "$NEW_MASTER"
echo " $1$2"
fi
}
_mig_path TARGET_DIR "$DST"
_mig_path DATA_DIR "$DST/data"
_mig_path STATE_DIR "$DST/data/state"
unset -f _mig_path
else
error "master.conf not found at $NEW_MASTER"
exit 1