aboutsummaryrefslogtreecommitdiffstats
path: root/util/download-latest-save.bash
diff options
context:
space:
mode:
authorm-chandler <mchandler89@gmail.com>2024-11-09 09:20:15 +1000
committerGitHub <noreply@github.com>2024-11-09 09:20:15 +1000
commitd31e4f88b1409f2325220cd483c03e6b9bce878f (patch)
tree425b129470914ee341655021c2034ff9476af27a /util/download-latest-save.bash
parent11bdeb09d654abe2e4daa66c4315b6dc982564e6 (diff)
parent216c660cd1a1fcbd189880548c33f7846542698e (diff)
Merge pull request #43 from Isaac-T-Hill/optional-ssh-keys
Add optional argument for ssh key path in utils
Diffstat (limited to 'util/download-latest-save.bash')
-rw-r--r--util/download-latest-save.bash14
1 files changed, 11 insertions, 3 deletions
diff --git a/util/download-latest-save.bash b/util/download-latest-save.bash
index 2a84660..c1d0f0d 100644
--- a/util/download-latest-save.bash
+++ b/util/download-latest-save.bash
@@ -7,12 +7,20 @@ if [ $# -ne 1 ]; then
fi
remote_name="$1"
+key_path=""
+
+# Check if custom PEM file is provided
+if [ -n "$FACTORIO_PEM" ]; then
+ key_path="-i $FACTORIO_PEM"
+fi
# Generate a human-readable timestamp
timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
+
+
# SSH into the remote instance to find the most recent save file
-ssh_output=$(ssh "ec2-user@$remote_name" << EOF
+ssh_output=$(ssh $key_path "ec2-user@$remote_name" << EOF
# Record the current directory
current_dir=\$(pwd)
@@ -59,9 +67,9 @@ latest_file=$(basename "$latest_file_path")
# Download the file from the remote instance to the current local directory with the new filename
new_filename="${remote_name}_${timestamp}_${latest_file}"
-scp "ec2-user@$remote_name:$latest_file_path" "./$new_filename"
+scp $key_path "ec2-user@$remote_name:$latest_file_path" "./$new_filename"
# Clean up the temporary file on the remote instance
-ssh "ec2-user@$remote_name" "rm -f $latest_file_path"
+ssh $key_path "ec2-user@$remote_name" "rm -f $latest_file_path"
echo "Download complete. The latest save file has been saved as '$new_filename' in your current directory." \ No newline at end of file
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage