Skip to content

Commit

Permalink
chore: check connectivity at the beguinnig
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo Lorenzo <ariobolo@redhat.com>
  • Loading branch information
adrianriobo committed Mar 15, 2024
1 parent de21a75 commit e628e64
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ source remote.sh

# Default values
TARGET_CLEANUP="${TARGET_CLEANUP:-"true"}"
CHECK_CONNECTION="${CHECK_CONNECTION:-"true"}"
CHECK_CONNECTION_ATTEMPTS=${CHECK_CONNECTION_ATTEMPTS:-30}
CHECK_CONNECTION_DELAY=${CHECK_CONNECTION_DELAY:-10}

# Debug
if [ "${DEBUG:-}" = "true" ]; then
Expand All @@ -16,6 +19,14 @@ if [[ ! remote_required ]] || [[ ! mamp_required ]] || [[ -z "${ASSETS_FOLDER+x}
exit 1
fi

if [ "${CHECK_CONNECTION:-}" = "true" ]; then
check_connection ${CHECK_CONNECTION_ATTEMPTS} ${CHECK_CONNECTION_DELAY}
if [[ $? -gt 0 ]]
then
exit 1
fi
fi

# Create execution folder
echo "Create assets folder on target"
TARGET_FOLDER="${TARGET_FOLDER:-"deliverest-${RANDOM}"}"
Expand All @@ -28,13 +39,14 @@ $(scp_to_cmd "${ASSETS_FOLDER}/*" "${TARGET_FOLDER}/")
# Exec command
$(ssh_cmd "$@")

# Check ssh connection to target host
CHECK_CONNECTION_ATTEMPTS=${CHECK_CONNECTION_ATTEMPTS:-30}
CHECK_CONNECTION_DELAY=${CHECK_CONNECTION_DELAY:-10}
check_connection ${CHECK_CONNECTION_ATTEMPTS} ${CHECK_CONNECTION_DELAY}
if [[ $? -gt 0 ]]
then
exit 1
# If remote workload includes a reboot this is the only way to ensure we can
# copy results if any or cleanup
if [ "${CHECK_CONNECTION:-}" = "true" ]; then
check_connection ${CHECK_CONNECTION_ATTEMPTS} ${CHECK_CONNECTION_DELAY}
if [[ $? -gt 0 ]]
then
exit 1
fi
fi

# Copy results
Expand Down

0 comments on commit e628e64

Please sign in to comment.