aboutsummaryrefslogtreecommitdiffstats
path: root/util/upload-save.bash
diff options
context:
space:
mode:
authorIsaac Hill <eesocktmendez@gmail.com>2024-10-27 23:21:36 -0700
committerIsaac Hill <eesocktmendez@gmail.com>2024-10-27 23:45:38 -0700
commit6f38cde7661408ca953a96f79c9d404cea65e4db (patch)
tree155d931f46566c23b4f5ddee7e64346f13482a93 /util/upload-save.bash
parent11bdeb09d654abe2e4daa66c4315b6dc982564e6 (diff)
Add optional argument for ssh key path in utils
Diffstat (limited to 'util/upload-save.bash')
-rw-r--r--util/upload-save.bash14
1 files changed, 10 insertions, 4 deletions
diff --git a/util/upload-save.bash b/util/upload-save.bash
index 9c66030..d8a109f 100644
--- a/util/upload-save.bash
+++ b/util/upload-save.bash
@@ -1,14 +1,20 @@
#!/bin/bash
# Check if both arguments are provided
-if [ $# -ne 2 ]; then
- echo "Usage: $0 <path_to_MySave.zip> <ec2_address>"
+if [ $# -ne 2 -a $# -ne 3 ]; then
+ echo "Usage: $0 <path_to_MySave.zip> <ec2_address> [optional_path_to_MyKey.pem]"
exit 1
fi
# Get the file path and EC2 address from command line arguments
save_file="$1"
ec2_address="$2"
+key_path=""
+
+# Check if remote name is provided
+if [ $# -eq 3 ]; then
+ key_path="-i $3"
+fi
# Check if the file exists
if [ ! -f "$save_file" ]; then
@@ -18,10 +24,10 @@ fi
# Upload the save file to the EC2 instance
echo "Uploading save file to EC2 instance..."
-scp "$save_file" "ec2-user@$ec2_address:~/"
+scp $key_path "$save_file" "ec2-user@$ec2_address:~/"
# SSH into the EC2 instance and perform the required operations
-ssh "ec2-user@$ec2_address" << EOF
+ssh $key_path "ec2-user@$ec2_address" << EOF
# Get the Factorio container ID
container_id=\$(docker ps | grep factoriotools/factorio | awk '{print \$1}' | cut -c1-3)
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage