Let one host template upgrade any host's conf
The pull substituted only HOSTN_, so bare HOSTN in comments kept tripping conf_upgrade's own guard and no host conf had upgraded since the guard landed.
This commit is contained in:
+9
-8
@@ -343,15 +343,16 @@ elif [[ "$SYNC_SUCCESS" == true ]]; then
|
||||
# This server's host conf only — sparse checkout ensures we have it
|
||||
HOST_CONF="$CONF_DIR/${MY_ID,,}.conf"
|
||||
if [[ -f "$DEPLOY_DIR/host.conf.template" && -f "$HOST_CONF" ]]; then
|
||||
# Template uses HOSTN_ as generic prefix. Substitute MY_ID before merging
|
||||
# so keys match the target (HOST1_* or HOST2_*) and real values are preserved.
|
||||
TMPL_RESOLVED=$(mktemp)
|
||||
sed "s/HOSTN_/${MY_ID}_/g; s/REMOTE_ID/${REMOTE_ID}/g" "$DEPLOY_DIR/host.conf.template" > "$TMPL_RESOLVED"
|
||||
# The template is slot-generic; conf_upgrade resolves HOSTN/hostn to MY_ID and refuses
|
||||
# if that disagrees with the target's own keys. This used to be a local sed that only
|
||||
# replaced HOSTN_, which left bare HOSTN in comments — enough to trip conf_upgrade's
|
||||
# own guard, so the host conf silently never upgraded — and left lowercase hostn alone,
|
||||
# which would have installed an unreferenced hostn-appdata rsync profile.
|
||||
bash "$UPGRADE_SCRIPT" \
|
||||
--template "$TMPL_RESOLVED" \
|
||||
--target "$HOST_CONF" \
|
||||
--backup $_DRY
|
||||
rm -f "$TMPL_RESOLVED"
|
||||
--template "$DEPLOY_DIR/host.conf.template" \
|
||||
--target "$HOST_CONF" \
|
||||
--host-slot "$MY_ID" \
|
||||
--backup $_DRY
|
||||
else
|
||||
warn "${MY_ID,,}.conf or host.conf.template not found — skipping"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user