From e12784daec24a3d9b6b03dd0b393270127618ef2 Mon Sep 17 00:00:00 2001 From: srueda99 Date: Mon, 18 Apr 2022 13:19:39 -0500 Subject: [PATCH] Change on Dockerfile --- Dockerfile | 2 +- entrypoint.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d03cec..c16e69d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,4 @@ COPY entrypoint.sh /home/entrypoint.sh # Grant executable permission on the script. RUN ["chmod", "+x", "/home/entrypoint.sh"] # Runs the script. -ENTRYPOINT [ "/entrypoint.sh" ] \ No newline at end of file +ENTRYPOINT [ "/home/entrypoint.sh" ] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 542cfb7..88e362e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,12 +1,17 @@ #!/bin/sh -l +# Checking if the key input is not empty if [[ "$INPUT_KEY" ]]; then - echo -e "${INPUT_KEY}" > key - chmod 400 key + # If it is not emty, it uses the key for the SCP + echo -e "${INPUT_KEY}" > key # Creates a file with the key content + chmod 400 key # Set the key as Read-Only echo "Trying SCP process with SSH key" + # Runs the SCP command scp -P $INPUT_PORT -o StrictHostKeyChecking=no -i key $INPUT_ORIGIN "$INPUT_USERNAME"@"$INPUT_HOST":"$INPUT_DESTINATION" else + # If the keyis emty, it uses the password for the SCP echo "Trying SCP process with password" + # Runs the SCP command sshpass -p $INPUT_PASSWORD scp -P $INPUT_PORT -o StrictHostKeyChecking=no $INPUT_ORIGIN "$INPUT_USERNAME"@"$INPUT_HOST":"$INPUT_DESTINATION" fi echo "Files successfully copied" \ No newline at end of file