This commit is contained in:
oliver committed 2026-10-13 09:04:10 -03:00
1 parent e03bb926e8
commit df86400eb5
1 file changed
+5 -3
+5 -3
View File
@@ -15,6 +15,11 @@ localfile="$1"
remotefile="$2"
remotetmp_base="/var/tmp/4server"
# If the destination is a directory (trailing slash), keep the local file name
case "$remotefile" in
*/) remotefile="${remotefile}$(basename "$localfile")" ;;
esac
# Read hosts from file descriptor 3 to prevent ssh from consuming stdin
while read -r host <&3; do
host_env_file="$host_vars_dir/$host/$host.env"
@@ -34,7 +39,6 @@ while read -r host <&3; do
SSH_PRIVATE=$(<"$host_vars_dir/$host/$host")
SSH_PUBLIC=$(<"$host_vars_dir/$host/$host.pub")
content=$(<"$localfile")
for key in "${keys[@]}"; do
@@ -42,7 +46,6 @@ while read -r host <&3; do
# Replace placeholder {{KEY}} with value using Bash's parameter expansion
content="${content//\{\{$key\}\}/$value}"
done
# Copy content to remote temporary file
remotetmp="${remotetmp_base}_${host}"
echo "Copying to $host:$remotefile"
@@ -52,4 +55,3 @@ while read -r host <&3; do
ssh "$host" "doas mv '$remotetmp' '$remotefile'"
done 3< /app/host_vars/hosts