Commit 4e8cf16b authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Añade comprobación inicial de conexión SSH

parent e96b9731
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -6,7 +6,8 @@ then
	exit 1
fi

remoteHost=$(echo "${SSH_REMOTE}" | cut -f 2 -d '@')
remoteUser=$(echo "${SSH_REMOTE}" | cut -d '@' -f 1)
remoteHost=$(echo "${SSH_REMOTE}" | cut -d '@' -f 2)

if [ -z "${remoteHost}" ]
then
@@ -25,3 +26,11 @@ eval "$(ssh-agent)" > /dev/null
echo "${DEPLOY_KEY}" | tr -d '\r' | ssh-add - > /dev/null 2>&1

closeSshCmd="ssh ${SSH_PARAMS} -q -O exit \"${SSH_REMOTE}\""

# Se comprueba si está disponible la conexión hacia el entorno donde se va a desplegar.
if ! ssh ${SSH_PARAMS} "${SSH_REMOTE}" : &> /dev/null
then
	echo -e "\n${FAIL_COLOR}Failed to connect to host ${DATA_COLOR}${remoteHost}${INFO_COLOR} at port ${DATA_COLOR}${SSH_PORT}${INFO_COLOR} with user ${DATA_COLOR}${remoteUser}${INFO_COLOR}!${NULL_COLOR}"
	eval "${closeSshCmd}"
	exit 1
fi