o
This commit is contained in:
1 parent
e03bb926e8
commit
df86400eb5
1 file changed
+5
-3
+5
-3
@@ -15,6 +15,11 @@ localfile="$1"
|
|||||||
remotefile="$2"
|
remotefile="$2"
|
||||||
remotetmp_base="/var/tmp/4server"
|
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
|
# Read hosts from file descriptor 3 to prevent ssh from consuming stdin
|
||||||
while read -r host <&3; do
|
while read -r host <&3; do
|
||||||
host_env_file="$host_vars_dir/$host/$host.env"
|
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_PRIVATE=$(<"$host_vars_dir/$host/$host")
|
||||||
SSH_PUBLIC=$(<"$host_vars_dir/$host/$host.pub")
|
SSH_PUBLIC=$(<"$host_vars_dir/$host/$host.pub")
|
||||||
|
|
||||||
content=$(<"$localfile")
|
content=$(<"$localfile")
|
||||||
|
|
||||||
for key in "${keys[@]}"; do
|
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
|
# Replace placeholder {{KEY}} with value using Bash's parameter expansion
|
||||||
content="${content//\{\{$key\}\}/$value}"
|
content="${content//\{\{$key\}\}/$value}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Copy content to remote temporary file
|
# Copy content to remote temporary file
|
||||||
remotetmp="${remotetmp_base}_${host}"
|
remotetmp="${remotetmp_base}_${host}"
|
||||||
echo "Copying to $host:$remotefile"
|
echo "Copying to $host:$remotefile"
|
||||||
@@ -52,4 +55,3 @@ while read -r host <&3; do
|
|||||||
ssh "$host" "doas mv '$remotetmp' '$remotefile'"
|
ssh "$host" "doas mv '$remotetmp' '$remotefile'"
|
||||||
|
|
||||||
done 3< /app/host_vars/hosts
|
done 3< /app/host_vars/hosts
|
||||||
|
|
||||||
Reference in new issue
Block a user