From 0a2f37fea53b5c3760cbbfd6b398a5a132dc7b45 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 24 Mar 2026 10:03:59 +0000 Subject: [PATCH] fix --- stages/stage1-1-get-remote-files.sh | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 stages/stage1-1-get-remote-files.sh diff --git a/stages/stage1-1-get-remote-files.sh b/stages/stage1-1-get-remote-files.sh new file mode 100755 index 0000000..a14b03c --- /dev/null +++ b/stages/stage1-1-get-remote-files.sh @@ -0,0 +1,34 @@ +#!/bin/bash +ssh_keyfile='/export/home/cloudian/cloudian-installation-key' +# Set the path to the remote file you want to download +remote_file='/root/manifest-*txt*' + +# Ensure variables are set +if [[ -z "$ssh_keyfile" || -z "$remote_file" ]]; then + echo "Error: Please set 'ssh_keyfile' and 'remote_file' variables." + exit 1 +fi + +# Extract hostnames/IPs from /etc/hosts, skipping comments and localhost +HOSTS=$(grep -v '^#' /etc/hosts | grep -v 'localhost' | awk '{print $2}') + +for HOST in $HOSTS; do + echo "--- Fetching from: $HOST ---" + + # Create a unique local directory for this host's file + #target_dir="remotes/$HOST" + target_dir="remotes/" + mkdir -p "$target_dir" + + # Use SCP to pull the file from the remote host to the local directory + # -i: Specifies the identity (private key) file + # -o StrictHostKeyChecking=no: Skips manual fingerprint verification prompts + scp -i "$ssh_keyfile" -o StrictHostKeyChecking=no "$HOST":"$remote_file" "$target_dir/" + + if [ $? -eq 0 ]; then + echo "--- Success: File saved to $target_dir/ ---" + else + echo "--- Failed: Could not fetch from $HOST ---" + fi +done +